Esempio n. 1
0
    private IEnumerator SpawnRoutine()
    {
        int            i          = 0;
        Collider2D     collider   = GetComponent <Collider2D>();
        ShipController controller = GetComponent <ShipController>();
        ShipMovement   movement   = GetComponent <ShipMovement>();

        collider.enabled   = false;
        controller.enabled = false;
        while (i < 64)
        {
            movement.MoveForward();
            i++;
            yield return(new WaitForSeconds(0.01f));
        }
        collider.enabled   = true;
        controller.enabled = true;
        Destroy(this);
    }
Esempio n. 2
0
    private void HandleMovement()
    {
        var ship = GameObject.FindGameObjectWithTag("Player");

        if (ship.transform.position.x > ENDGAMEPOSITION)
        {
            if (!hasWin)
            {
                TextEnable.EnableFaseCompleta();
                hasWin = true;
            }
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            shipMovement.RotateLeft();
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            shipMovement.RotateRight();
        }
        if (Input.GetKey(KeyCode.UpArrow) && (ship.transform.position.x > ENDGAMEPOSITION) && (shipMovement.HasWarp))
        {
            shipMovement.Warp();
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            shipMovement.MoveForward();
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            shipMovement.MoveBackward();
        }
        else
        {
            shipMovement.Decelerate();
        }
        if (!Input.GetKey(KeyCode.UpArrow) || !(ship.transform.position.x > ENDGAMEPOSITION))
        {
            shipMovement.DeWarp();
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxis("Horizontal") != 0)
        {
            shipMovement.MoveRight(Input.GetAxis("Horizontal"));
        }
        if (Input.GetAxis("Vertical") != 0)
        {
            shipMovement.MoveForward(Input.GetAxis("Vertical"));
        }
        if (Input.GetAxis("UpDown") != 0)
        {
            shipMovement.MoveUp(Input.GetAxis("UpDown"));
        }
        if (Input.GetAxis("Roll") != 0)
        {
            shipMovement.Roll(Input.GetAxis("Roll"));
        }
        Vector2 turn;

        turn = new Vector2(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"));
        shipMovement.Turn(turn);
    }