コード例 #1
0
    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.RightArrow))
        {
            direction = TankController.goDirection.right;
        }
        else if (Input.GetKey(KeyCode.LeftArrow))
        {
            direction = TankController.goDirection.left;
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            direction = TankController.goDirection.up;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            direction = TankController.goDirection.down;
        }
        else
        {
            direction = TankController.goDirection.stay;
        }

        MobileMove();

        if (Input.GetKeyDown(KeyCode.Space) || CnInputManager.GetButtonDown("Jump"))
        {
            controller.Shoot();
        }

        controller.direction = direction;
    }
コード例 #2
0
    void Update()
    {
        CameraSmooth2D.startingTarget = this.transform;         //I hope this works fine :)
        if (Input.GetKey(KeyCode.RightArrow))
        {
            direction = TankController.goDirection.right;
        }
        else if (Input.GetKey(KeyCode.LeftArrow))
        {
            direction = TankController.goDirection.left;
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            direction = TankController.goDirection.up;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            direction = TankController.goDirection.down;
        }
        else
        {
            direction = TankController.goDirection.stay;
        }

        controller.direction = direction;
    }
コード例 #3
0
        public void Update()
        {
            if (Input.GetKey(RightKey))
            {
                Direction = TankController.goDirection.right;
            }
            else if (Input.GetKey(LeftKey))
            {
                Direction = TankController.goDirection.left;
            }
            else if (Input.GetKey(UpKey))
            {
                Direction = TankController.goDirection.up;
            }
            else if (Input.GetKey(DownKey))
            {
                Direction = TankController.goDirection.down;
            }
            else
            {
                Direction = TankController.goDirection.stay;
            }

            if (Input.GetKeyDown(ShootKey) /*&& !Bullet.isBulletAlive*/)
            {
                Controller.Shoot();
            }
            Controller.direction = Direction;
        }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.RightArrow))
        {
            direction = TankController.goDirection.right;
        }
        else if (Input.GetKey(KeyCode.LeftArrow))
        {
            direction = TankController.goDirection.left;
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            direction = TankController.goDirection.up;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            direction = TankController.goDirection.down;
        }
        else
        {
            direction = TankController.goDirection.stay;
        }

        if (Input.GetKeyDown(KeyCode.Space) /*&& !Bullet.isBulletAlive*/)
        {
            controller.Shoot();
        }

        controller.direction = direction;
    }
コード例 #5
0
    private void MobileMove()
    {
        Vector3 movement = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f, CnInputManager.GetAxis("Vertical"));

        if (movement != Vector3.zero)
        {
            float x = movement.x;
            float y = movement.z;

            if (x < 0 && y < 0)
            {
                if (Math.Abs(x) > Math.Abs(y))
                {
                    direction = TankController.goDirection.left;
                }
                else
                {
                    direction = TankController.goDirection.down;
                }
            }
            else if (x > 0 && y > 0)
            {
                if (Math.Abs(x) > y)
                {
                    direction = TankController.goDirection.right;
                }
                else
                {
                    direction = TankController.goDirection.up;
                }
            }
            else if (x > 0 && y < 0)
            {
                if (Math.Abs(x) > Math.Abs(y))
                {
                    direction = TankController.goDirection.right;
                }
                else
                {
                    direction = TankController.goDirection.down;
                }
            }
            else if (x < 0 && y > 0)
            {
                if (Math.Abs(x) > y)
                {
                    direction = TankController.goDirection.left;
                }
                else
                {
                    direction = TankController.goDirection.up;
                }
            }
        }
    }
コード例 #6
0
ファイル: InputHandlers.cs プロジェクト: kennson/Tanky
    void Update()
    {
        if (Input.GetKey (KeyCode.RightArrow)) {
            direction = TankController.goDirection.right;
        } else if (Input.GetKey (KeyCode.LeftArrow)) {
            direction = TankController.goDirection.left;
        } else if (Input.GetKey (KeyCode.UpArrow)) {
            direction = TankController.goDirection.up;
        } else if (Input.GetKey (KeyCode.DownArrow)) {
            direction = TankController.goDirection.down;
        } else {
            direction = TankController.goDirection.stay;
        }

        if(Input.GetKeyDown(KeyCode.Space)){
            controller.Shoot();
        }

        controller.direction = direction;
    }