protected void Update() { if (Time.time - makeIntervalCount >= makeInterval) { if (ControlKeys.GetBool(MAKE_FIGHTER)) { MakeFighter(); makeIntervalCount = Time.time; } } }
protected void Update() { if (Controllable) { if ((Time.time - fireIntervalCount > fireInterval) && ControlKeys.GetBool(FIRE)) { fireIntervalCount = Time.time; Sys.Stable.ObjectPool.Alloc <NormalBullet>(Bullet, x => { x.ObjectPoolInit(shipTrans, trans.position, trans.rotation); }); } } }
//todo 测试操控模块 protected void FixedUpdate() { if (Controllable) { float accMultiply = 1; Vector3 tempControlVector = ControlKeys.GetVector(JOYSTICK, Vector3.positiveInfinity); if (!tempControlVector.Equals(Vector3.positiveInfinity)) { ParseDir(tempControlVector, ref accMultiply); } tempControlVector = ControlKeys.GetVector(SHOOTING_JOYSTICK, Vector3.positiveInfinity); if (!tempControlVector.Equals(Vector3.positiveInfinity)) { aimmingPos += tempControlVector * AimmingPosAcce * Time.fixedDeltaTime; } Vector3 curPos = trans.position; Quaternion curRot = trans.rotation; tempControlVector = ControlKeys.GetVector(STARING_AT, Vector3.positiveInfinity); if (tempControlVector.Equals(Vector3.positiveInfinity)) { if (ControlKeys.GetBool(TURN_RIGHT)) { curRot = TurnRight(curRot); } if (ControlKeys.GetBool(TURN_LEFT)) { curRot = Turnleft(curRot); } } else { curRot = StaringAt(curRot, tempControlVector, curPos); } trans.rotation = curRot; Vector3 curDir = (curRot * Vector3.up).normalized; Vector3 curVelocity = rb2d.velocity; curVelocity -= drag * Time.fixedDeltaTime * rb2d.velocity.magnitude * curVelocity.normalized; if (ControlKeys.GetBool(ACC_FRONT)) { curVelocity = SpeedUpFront(curVelocity, curDir, accMultiply); } if (ControlKeys.GetBool(ACC_BACK)) { curVelocity = SpeedUpBack(curVelocity, curDir, accMultiply); } if (ControlKeys.GetBool(ACC_LEFT)) { curVelocity = SpeedUpLeft(curVelocity, curDir, accMultiply); } if (ControlKeys.GetBool(ACC_RIGHT)) { curVelocity = SpeedUpRight(curVelocity, curDir, accMultiply); } if (ForceTurn) { curVelocity = ForceTurnParse(curVelocity); } rb2d.velocity = curVelocity; } }