public TrickManager(LevelManager levelManager, Plane plane) { this.levelManager = levelManager; this.plane = plane; tricks = new List <ITrick>(); DriftTrick = new DriftTrick(plane, plane.PlaneMovement, this); BarrelRoll = new BarrelRoll(plane, plane.PlaneMovement, this); CobraFlip = new CobraFlip(plane, plane.PlaneMovement, this); tricks.Add(DriftTrick); tricks.Add(BarrelRoll); tricks.Add(CobraFlip); }
Vector3 v3_leftVec; // So every rotation doesn't have to be negative protected override void SetupState() { FlapTheWings(); f_energyCurrent = Vector3.SqrMagnitude(G.rigid.velocity); f_pitchAngle = 0f; f_rollAngle = 0f; f_wingFlapTimer = 0f; b_airborne = true; b_upsideDown = false; f_prevXinput = 0f; e_barrelRolling = BarrelRoll.None; //b_barrelRoll = false; //f_barrelRollTargetAngle = 0f; }
protected void RollRotation() { Vector3 myLeft = -MC.transform.right; Vector3 axis; if (e_barrelRolling == BarrelRoll.None) { G.v3list_rotateTo[1] = Quaternion.AngleAxis(-f_rollAngle, G.v3list_rotateTo[0]) * v3_leftVec; axis = Vector3.Cross(G.v3list_rotateTo[1], myLeft); ApplyTorqueTowards(myLeft, G.v3list_rotateTo[1], axis, G.f_rollSpeed); } else if (e_barrelRolling == BarrelRoll.Left || e_barrelRolling == BarrelRoll.LeftOver) { axis = MC.transform.forward; G.rigid.AddTorque(G.f_barrelRollTorque * axis, ForceMode.Acceleration); // Barrel roll over or done? if (Vector3.Dot(MC.transform.up, Vector3.up) < 0f) { e_barrelRolling = BarrelRoll.LeftOver; } else if (Vector3.Dot(MC.transform.up, Vector3.up) > 0f && e_barrelRolling == BarrelRoll.LeftOver) { e_barrelRolling = BarrelRoll.None; b_upsideDown = false; } } else if (e_barrelRolling == BarrelRoll.Right || e_barrelRolling == BarrelRoll.RightOver) { axis = MC.transform.forward; G.rigid.AddTorque(-G.f_barrelRollTorque * axis, ForceMode.Acceleration); // Barrel roll over or done? if (Vector3.Dot(MC.transform.up, Vector3.up) < 0f) { e_barrelRolling = BarrelRoll.RightOver; } else if (Vector3.Dot(MC.transform.up, Vector3.up) > 0f && e_barrelRolling == BarrelRoll.RightOver) { e_barrelRolling = BarrelRoll.None; b_upsideDown = false; } } }
public void PostConstruct() { barrelRoll = plane.TrickManager.BarrelRoll; driftTrick = plane.TrickManager.DriftTrick; cobraFlip = plane.TrickManager.CobraFlip; }
void Start() { collisionSound = GetComponent <AudioSource>(); roll = FindObjectOfType <BarrelRoll>(); }
public static BarrelRollWrapper Wrap(BarrelRoll barrelRoll) => new BarrelRollWrapper { BarrelRoll = barrelRoll };
private void Awake() { enemyHealth = FindObjectOfType <EnemyHealth>(); barrelroll = FindObjectOfType <BarrelRoll>(); }