首先感谢我们组的两位大佬,认真负责又很有耐心地指导我们,跟着他们学到了不少东西。
先设计好初稿,然后再分析实现步骤,比如列出数学物理公式,最后就是编码实现阶段了。下面是我的代码:
BulletCenterDance:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletCenterDance : BulletTypeB {
public Vector2 Valocity;
// Update is called once per frame
void Update () {
transform.Translate(Valocity * Time.deltaTime);
}
}
RevolveCircle:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RevolveCircle : SpellCard {
public RevolveCircle() : base(new Circle(), new Vector2(-1.5f, 2.4f), 78f, 15000, "想起「旋转圆舞」 ")
{
}
}
class Circle : State<Boss>{
float time = 2f;
float timeC = 4f;
float t = -4f;
GameObject Revolve;
public override void Enter(Boss owner)
{
Revolve = ((Satori)owner).RevolveCircleResources.GetComponent<RevolveCircleResource>().RevolveCircle;
owner.transform.position = new Vector3(-1.53f, 0, 0);
}
public override void Execute(Boss owner)
{
timeC -= Time.deltaTime;
time -= Time.deltaTime;
t += Time.deltaTime;
if (time < 0) {
time += 0.1f;
Vector2 StartLo;
if (GameManager.player != null) {
StartLo = GameManager.player.transform.position - owner.transform.position;
} else {
StartLo = new Vector2 (0, 1);
}
StartLo.Normalize ();
for (int i = -1; i <= 1; i++) {
float routeAngle = 30 * Mathf.Deg2Rad * i;
Vector2 valocity = new Vector2(StartLo.x*Mathf.Cos(routeAngle)-StartLo.y*Mathf.Sin(routeAngle),StartLo.x*Mathf.Sin(routeAngle)+StartLo.y*Mathf.Cos(routeAngle));
valocity *= 3.0f;
BulletCenterDance c = GameObject.Instantiate (((Satori)owner).RevolveCircleResources.GetComponent<RevolveCircleResource> ().RevolveCircle, owner.transform.position, Quaternion.identity).GetComponent<BulletCenterDance> ();
c.Valocity = valocity;
GameObject.Destroy (c.gameObject, 5f);
}
}
if (timeC<0) {
timeC += 0.3f;
for (int i = 0; i < 4; i++) {
Vector2 StartLocation = new Vector2 (Mathf.Cos (t), Mathf.Sin (t));
Vector2 valocity = new Vector2 (2f * Mathf.Cos (2f * t + i * Mathf.PI / 2), 2f * Mathf.Sin (2f * t + i * Mathf.PI / 2));
BulletCenterDance r = GameObject.Instantiate (((Satori)owner).RevolveCircleResources.GetComponent<RevolveCircleResource> ().BulletTriangle, owner.transform.position + (Vector3)StartLocation, Quaternion.identity).GetComponent<BulletCenterDance> ();
r.Valocity = valocity;
GameObject.Destroy (r.gameObject, 10f);
}
for (int i = 0; i < 4; i++) {
Vector2 StartLocation = new Vector2 (-Mathf.Cos (t), Mathf.Sin (t));
Vector2 valocity = new Vector2 (-2f * Mathf.Cos (2f * t + i * Mathf.PI / 2), 2f * Mathf.Sin (2f * t + i * Mathf.PI / 2));
BulletCenterDance r = GameObject.Instantiate (((Satori)owner).RevolveCircleResources.GetComponent<RevolveCircleResource> ().BulletTriangle, owner.transform.position + (Vector3)StartLocation, Quaternion.identity).GetComponent<BulletCenterDance> ();
r.Valocity = valocity;
GameObject.Destroy (r.gameObject, 10f);
}
}
}
}
RevolveCircleResources:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RevolveCircleResource : MonoBehaviour {
public GameObject RevolveCircle; //
public GameObject BulletTriangle; //
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}