void shootPlayer()
 {
     this.transform.LookAt(player.transform);
     this.transform.Rotate(Random.Range(-30, -80), 0, 0);
     power = Random.Range(30, 70);
     cannonC.Shoot(power);
 }
Beispiel #2
0
 public void Fire()
 {
     if (isHeld)
     {
         Debug.Log("RemoteController: Fire");
         cannonController.Shoot();
     }
 }
Beispiel #3
0
    public void OnShootButtonClick()
    {
        int    angle;
        int    force;
        string strAngle = GameUIManager.Instance.AngleInput;
        string strForce = GameUIManager.Instance.ForceInput;

        if (int.TryParse(strAngle, out angle) && int.TryParse(strForce, out force))
        {
            if (actualPlayerTurn == PlayerTurn.Player1)
            {
                player1.Shoot(angle, force);
            }
            else
            {
                player2.Shoot(angle, force);
            }
            GameUIManager.Instance.HideInputsMenu();
        }
        else
        {
            Debug.LogError("Los campos están vacios");
        }
    }
    // Update is called once per frame
    void Update()
    {
        //do end of game check for cannons here
        if (GameObject.Find("FriendLeft") == null && GameObject.Find("FriendCenter") == null && GameObject.Find("FriendRight") == null)
        {
            gameEnd.text   = "Game Over!";
            Time.timeScale = 0;
        }
        else if (GameObject.Find("EnemyLeft") == null && GameObject.Find("EnemyCenter") == null && GameObject.Find("EnemyRight") == null)
        {
            gameEnd.text   = "You Win!";
            Time.timeScale = 0;
        }

        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        myAnim.SetFloat("HAXIS", 0);
        myAnim.SetFloat("VAXIS", 0);

        if (mode == 0)
        {
            myAnim.SetFloat("HAXIS", h);
            myAnim.SetFloat("VAXIS", v);

            mainCamera.transform.position = transform.position - 5 * transform.forward + 2 * Vector3.up;
            mainCamera.transform.LookAt(transform.position);
        }
        else if (mode == 1)
        {
            //exit when cannon is destroyed (rare, not sure how to test)
            if (cannonC == null)
            {
                startMoving();
            }
            cannonC.transform.Rotate(Vector3.up, h * rotateSpeed * Time.deltaTime, Space.World);
            cannonC.transform.Rotate(cannonC.transform.right, v * rotateSpeed * Time.deltaTime, Space.World);

            //set camera pos
            mainCamera.transform.position = cannonC.spawnPoint.transform.position;
            mainCamera.transform.forward  = cannonC.transform.forward;

            //shoot
            if (Input.GetButtonDown("Fire1"))
            {
                cannonBall = cannonC.Shoot(shootPower);
                mode       = -1;
                Invoke("startFollowing", 0.2f);
            }
            else if (Input.GetButtonDown("Fire2"))
            {
                startMoving();
            }
        }
        else if (mode == 2)//shot follow mode
        {
            if (cannonBall != null)
            {
                mainCamera.transform.position = cannonBall.transform.position - cannonBall.velocity * 0.25f;
                mainCamera.transform.LookAt(cannonBall.position);
            }

            else
            {
                mode = -1; //do nothing
                Invoke("startAiming", 2);
            }
        }
        else //null mode
        {
        }
    }
Beispiel #5
0
 private void Shoot()
 {
     cannonController.Shoot();
 }