コード例 #1
0
 public void Fire()
 {
     if (_cannonController != null)
     {
         _cannonController.Fire();
     }
 }
コード例 #2
0
    public void HandleShootEvent()
    {
        CannonController jp = Player.GetComponent <CannonController> ();

        if (jp)
        {
            Debug.Log("EXISTO");
        }
        if (!angulo)
        {
            return;
        }
        if (!fuerza)
        {
            return;
        }
        float angle = float.Parse(angulo.text.ToString());
        float force = float.Parse(fuerza.text.ToString());

        jp.handleRotation(angle);
        if (force < 0.0f)
        {
            force = force * -1;
        }
        jp.Fire(force);
        //Debug.Log ("Force:" + force + "," + "Angle: " + angle);
        angulo.text = "";
        fuerza.text = "";
    }
コード例 #3
0
    void Update()
    {
        if (useInitialAngle)
        {
            cannon.SetTargetWithAngle(targetCursor.transform.position, initialFireAngle);
        }
        else
        {
            cannon.SetTargetWithSpeed(targetCursor.transform.position, initialFireSpeed, useLowAngle);
        }

        if (Input.GetButtonDown("Fire1") && !EventSystem.current.IsPointerOverGameObject())
        {
            cannon.Fire();

            Text destroy = GameObject.Find("usedBomb").GetComponent <Text>();
            destroy.text = (int.Parse(destroy.text) - 1) + "";

            if ((int.Parse(destroy.text)) <= 0)
            {
                endGameScreen.SetActive(true);
                GameObject gamesatus = GameObject.Find("GameStatus");


                gamesatus.transform.position = new Vector3(endGameScreen.transform.position.x + 130, endGameScreen.transform.position.y + 200, 0);
                Time.timeScale = 0;
            }
        }

        timeOfFlightText.text = Mathf.Clamp(cannon.lastShotTimeOfFlight - (Time.time - cannon.lastShotTime), 0, float.MaxValue).ToString("F3");
    }
コード例 #4
0
 public JsonResult Fire()
 {
     if (CannonController.Fire())
     {
         return(this.Json("Fired!"));
     }
     else
     {
         return(this.Json("Couldn't Fire?..."));
     }
 }
コード例 #5
0
ファイル: DebugObject.cs プロジェクト: laiqiqi/mortar
    void controlCannon()
    {
        // Rotate cannon
        int x = 0, y = 0;

        if (Input.GetKey(KeyCode.I))
        {
            y = 1;
        }
        else if (Input.GetKey(KeyCode.K))
        {
            y = -1;
        }

        if (Input.GetKey(KeyCode.J))
        {
            x = -1;
        }
        else if (Input.GetKey(KeyCode.L))
        {
            x = 1;
        }

        if (x != 0 || y != 0)
        {
            // FIXME needs a better way for figuring out which rotator is which
            CannonRotator[] rotators = gameManager.CurrentPlayer.Cannon.GetComponentsInChildren <CannonRotator>();
            if (x != 0)
            {
                rotators[1].Rotate(360 * x * Time.deltaTime);
            }
            if (y != 0)
            {
                rotators[0].Rotate(360 * y * Time.deltaTime);
            }
        }

        // Fire current cannon
        if (Input.GetKeyDown(KeyCode.Keypad0) || Input.GetKeyDown(KeyCode.Alpha0))
        {
            GameManager.Player player = gameManager.CurrentPlayer;
            CannonController   cannon = player.Cannon.GetComponent <CannonController>();
            cannon.Fire();
        }

        if (Input.GetKeyDown(KeyCode.Keypad3) || Input.GetKeyDown(KeyCode.Alpha3))
        {
            Debug.Log("DEBUG suicide");
            GameManager.Player player      = gameManager.CurrentPlayer;
            IDestroyableObject destroyable = player.Cannon.GetComponent <IDestroyableObject>();
            destroyable.OnDestroyObject();
        }
    }
コード例 #6
0
 public void OnTriggerStay(Collider other)
 {
     if (other.tag == "Controller")
     {
         SteamVR_TrackedObject controller = other.GetComponent <SteamVR_TrackedObject>();
         if (controller != null && controller.index != SteamVR_TrackedObject.EIndex.None)
         {
             if (SteamVR_Controller.Input((int)controller.index).GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
             {
                 Cannon.Fire();
             }
         }
     }
 }
コード例 #7
0
    void Update()
    {
        if (useInitialAngle)
        {
            cannon.SetTargetWithAngle(targetCursor.transform.position, initialFireAngle);
        }
        else
        {
            cannon.SetTargetWithSpeed(targetCursor.transform.position, initialFireSpeed, useLowAngle);
        }

        if (Input.GetButtonDown("Fire1") && !EventSystem.current.IsPointerOverGameObject())
        {
            cannon.Fire();
        }
    }
コード例 #8
0
    void Update()
    {
        if (useInitialAngle)
        {
            cannon.SetTargetWithAngle(targetCursor.transform.position, initialFireAngle);
        }
        else
        {
            cannon.SetTargetWithSpeed(targetCursor.transform.position, initialFireSpeed, useLowAngle);
        }

        if (Input.GetButtonDown("Fire1") && !EventSystem.current.IsPointerOverGameObject())
        {
            cannon.Fire();
        }

        timeOfFlightText.text = Mathf.Clamp(cannon.lastShotTimeOfFlight - (Time.time - cannon.lastShotTime), 0, float.MaxValue).ToString("F3");
    }
コード例 #9
0
    void FixedUpdate()
    {
        float mouseXMovement = Input.GetAxis("Mouse X");
        float mouseYMovement = Input.GetAxis("Mouse Y");
        float tankMovement   = Input.GetAxis("Horizontal");
        float bodyMovement   = Input.GetAxis("Vertical");

        body.Turn(tankMovement);
        turret.Turn(mouseXMovement);
        MoveTank(bodyMovement);
        cannon.Turn(mouseYMovement);



        if (Input.GetButton("Fire1") && cannonTimer >= cannonFireRate && cannon.CanFire())
        {
            cannonTimer = 0f;
            cannon.Fire();
        }

        if (Input.GetButtonDown("Fire2") && gun.currentState != FireMode.Auto)
        {
            gun.Fire();
        }
        else if (Input.GetButton("Fire2") && !isGunShooting && gun.currentState == FireMode.Auto)
        {
            isGunShooting = true;
            gun.Auto();
        }
        else if (Input.GetButtonUp("Fire2") && isGunShooting && gun.currentState == FireMode.Auto)
        {
            isGunShooting = false;
            gun.StopFire();
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            gun.ChangeState();
            gun.StopFire();
            isGunShooting = false;
        }
    }
コード例 #10
0
    private void Update()
    {
        if (!hasAuthority)
        {
            return;
        }
        if (_isDead)
        {
            _cannonController.AimHigh(Vector3.zero);
            return;
        }

        var input = JoystickInput.Left.CurrentJoystickDirection3;

        _chassisController.Move(input);

        // if (_joystickInput.CurrentJoystickDirection3 != Vector3.zero)
        // {
        // }
        // else
        // {
        //  _turretController.LookAt(transform.forward);
        // }
        _turretController.LookAt(JoystickInput.Right.CurrentJoystickDirection3);
        _cannonController.AimHigh(JoystickInput.Right.CurrentJoystickDirection3);

        if (Input.GetKeyDown(KeyCode.Space) || JoystickInput.Right.Released && JoystickInput.Right.CurrentJoystickDirection3.magnitude > InputMagnitudeForShotCancel)
        {
            _cannonController.Fire();
        }
        if (Input.GetKeyDown(KeyCode.V) || JoystickInput.Right.Pressed)
        {
            _teslaShield.Activate();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            TakeDamage(Player, 20);
        }
    }
コード例 #11
0
 public void Click(object h)
 {
     Cannon.Fire(t.Percentage);
 }