Example #1
0
 void Update()
 {
     if (spawnCooldown.ResetTimer())
     {
         EventBroker.CallAsteroidSpawn();
     }
 }
Example #2
0
    void Update()
    {
        // nwm czy to potrzebne
        StayOnScreen();
        //targetRotation = transform.localRotation.eulerAngles + new Vector3(0f, Input.GetAxis("Horizontal") * rotSpeed, 0f);
        //thrust = transform.forward * Input.GetAxis("Vertical") * maxThrust;

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (shootCooldown.ResetTimer())
            {
                EventBroker.CallProjectileShot(cannon);
            }
        }

        // CONTROLS CHANGE
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            controlsChange *= -1;
        }

        // FORWARD
        if (Input.GetKey(KeyCode.W))
        {
            thrust = transform.forward * maxThrust;
        }
        else if (Input.GetKey(KeyCode.S))
        {
            thrust = -transform.forward * maxThrust;
        }
        else
        {
            thrust = Vector3.zero;
        }

        //Rotation
        //zbieram deltę w kątach na poszczególnych osiach

        pitchDelta = 0;
        yawDelta   = 0;
        rollDelta  = 0;

        // SIDES
        if (Input.GetKey(KeyCode.A))
        {
            yawDelta = -rotSpeed;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            yawDelta = rotSpeed;
        }



        // FORWARD - UP/DOWN
        if (Input.GetKey(KeyCode.UpArrow))
        {
            pitchDelta = -rotSpeed * controlsChange;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            pitchDelta = rotSpeed * controlsChange;
        }

        // SIDES - UP/DOWN
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            rollDelta = rotSpeed;
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            rollDelta = -rotSpeed;
        }
    }