示例#1
0
    // Update is called once per frame
    void Update()
    {
        Targeting();
        while (!target.GetComponent <Check>().active)
        {
            Targeting();
        }
        if (state == PlayerState.Playing && target)
        {
            //transform.LookAt(target.transform);
            Vector3 pos = target.transform.position - transform.position;
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(pos), 10f * Time.deltaTime);

            LaserCannon.CheckTime();
            MissileCannon.CheckTime();
            LaserCannon.Shoot();
            MissileCannon.Shoot(target.transform);
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (myController.GetButtonDown(2) && PlayerNumber == 0)
        {
            Application.LoadLevel(0);
        }
        if (state == PlayerState.Playing)
        {
            myController.CheckSlidersTurners();
            myController.CheckAccelerator();
            myController.CheckButtons();

            if (SeekerList.Count > 0)
            {
                targetNumber  = (int)(myController.GetTurner(0) * SeekerList.Count);
                targetNumber %= SeekerList.Count;
                target        = (GameObject)SeekerList[targetNumber];
                if (target.transform)
                {
                    indicator.GetComponent <Crosshair>().SetTarget(target.transform);
                }
            }


            if (myController.GetTurner(1) == 1f)
            {
                weaponState = Weaponstate.Missile;
            }
            else if (myController.GetTurner(1) == 0f)
            {
                weaponState = Weaponstate.Laser;
            }
            LeftThruster  = myController.GetSlider(0);
            RightThruster = myController.GetSlider(1);


            yRot = (myController.yAcc) * RotationAngle;
            xRot = myController.xAcc * RotationAngle;
            transform.Rotate(Vector3.forward, Time.deltaTime * yRot * RotationSpeed / 2);
            transform.Rotate(Vector3.right, Time.deltaTime * xRot * RotationSpeed);

            LaserCannon.CheckTime();
            MissileCannon.CheckTime();

            if ((myController.GetButton(5) || myController.GetButton(6)) && weaponState == Weaponstate.Laser)
            {
                if (LaserCannon.Shoot())
                {
                    audio.PlayOneShot(laserSound);
                }
            }


            else if ((myController.GetButton(5) || myController.GetButton(6)) && weaponState == Weaponstate.Missile)
            {
                if (target != null)
                {
                    if (MissileCannon.Shoot(target.transform))
                    {
                        audio.PlayOneShot(missileSound);
                    }
                }
                if (target == null)
                {
                    if (MissileCannon.Shoot(null))
                    {
                        audio.PlayOneShot(missileSound);
                    }
                }
            }

            if (weaponState == Weaponstate.Laser)
            {
                if (!LaserCannon.overheated)
                {
                    HUDWeapon.Animate(1);
                }
                else if (LaserCannon.overheated)
                {
                    HUDWeapon.Animate(0.75f);
                }
            }

            else if (weaponState == Weaponstate.Missile)
            {
                if (!MissileCannon.overheated)
                {
                    HUDWeapon.Animate(0.4f);
                }
                else if (MissileCannon.overheated)
                {
                    HUDWeapon.Animate(0f);
                }
            }

            /*
             * Mathf.Clamp(TurnerSimulatorLeft, 0f, 1f);
             * Mathf.Clamp(TurnerSimulatorRight, 0f, 1f);
             * if (Input.GetKey(KeyCode.O))
             *  TurnerSimulatorRight += 0.1f;
             * if (Input.GetKey(KeyCode.L))
             *  TurnerSimulatorRight -= 0.1f;
             * if (Input.GetKey(KeyCode.I))
             *  TurnerSimulatorLeft += 0.1f;
             * if (Input.GetKey(KeyCode.K))
             *  TurnerSimulatorLeft -= 0.1f;
             *
             * if (SeekerList.Count > 0)
             * {
             *  targetNumber = (int)(TurnerSimulatorLeft * SeekerList.Count);
             *  targetNumber %= SeekerList.Count;
             *  target = (GameObject)SeekerList[targetNumber];
             *  if(target.transform)
             *  indicator.GetComponent<Crosshair>().SetTarget(target.transform);
             * }
             *
             *
             * if (TurnerSimulatorRight > 0.5f)
             * {
             *  weaponState = Weaponstate.Missile;
             * }
             * else if (TurnerSimulatorRight <= 0.5f)
             * {
             *  weaponState = Weaponstate.Laser;
             * }
             *
             * xRot = Input.GetAxisRaw("Vertical") * RotationAngle;
             * transform.Rotate(Vector3.right, Time.deltaTime * xRot * RotationSpeed);
             * yRot = Input.GetAxisRaw("Horizontal") * RotationAngle;
             * transform.Rotate(Vector3.up, Time.deltaTime * yRot * RotationSpeed / 2);
             *
             * LaserCannon.CheckTime();
             * MissileCannon.CheckTime();
             * LeftThruster = Input.GetAxisRaw("Vertical2");
             * RightThruster = Input.GetAxisRaw("Vertical2");
             *
             * if (Input.GetKey(KeyCode.Space) && weaponState == Weaponstate.Laser)
             * {
             *  if (LaserCannon.Shoot())
             *  {
             *      audio.PlayOneShot(laserSound);
             *  }
             * }
             *
             *
             * else if (Input.GetKey(KeyCode.Space) && weaponState == Weaponstate.Missile)
             * {
             *  if (MissileCannon.Shoot(target.transform))
             *  {
             *      audio.PlayOneShot(missileSound);
             *  }
             *
             * }
             *
             * if (weaponState == Weaponstate.Laser) {
             *  if(!LaserCannon.overheated)
             *      HUDWeapon.Animate(1);
             *  else if (LaserCannon.overheated)
             *      HUDWeapon.Animate(0.75f);
             * }
             *
             * else if (weaponState == Weaponstate.Missile)
             * {
             *  if(!MissileCannon.overheated)
             *      HUDWeapon.Animate(0.4f);
             *  else if (MissileCannon.overheated)
             *      HUDWeapon.Animate(0f);
             * }
             *
             */

            /*
             * if (myController.GetButton(5) || myController.GetButton(6))
             * {
             *  LaserCannon.Shoot();
             * }
             */
        }
    }