Example #1
0
 public void Fire()
 {
     if (Time.time > fireCooldown)
     {
         fireCooldown = Time.time + 1f / MaxProjectilePerSec;
         ShipCannon.Fire(gameObject);
     }
 }
Example #2
0
 void Fire()
 {
     if (playerShip)
     {
         var fireDirection = playerShip.transform.position - transform.position;
         UfoCannon.transform.rotation = Quaternion.LookRotation(Vector3.forward, fireDirection);
         UfoCannon.Fire(gameObject);
     }
     ScheduleNextFire();
 }
Example #3
0
    private IEnumerator MakeFireRoutine()
    {
        var delay = new WaitForSeconds(shotDelay);

        while (active)
        {
            cannon.Fire();
            yield return(delay);
        }
    }
Example #4
0
    // ---- event handlers ----

    protected void mouseClickHandler(int buttonID)
    {
        if (buttonID == MouseButton.LEFT)
        {
            if (cannon)
            {
                cannon.Fire();
            }
        }
    }
 void Update()
 {
     if (lastMsg != null)
     {
         var   tokens = lastMsg.Split('|');
         float x      = float.Parse(tokens[0]);
         float y      = -float.Parse(tokens[1]);
         float time   = int.Parse(tokens[2]);
         cannon.Fire(x, y, time);
         lastMsg = null;
     }
 }
Example #6
0
    private IEnumerator procFire()
    {
        while (!isHittable())
        {
            yield return(null);
        }

        yield return(null);

        cannon.Fire();

        yield return(null);

        StartCoroutine(procFire());
    }
Example #7
0
 // Update is called once per frame
 void Update()
 {
     switch (GameManager.state)
     {
     case GameManager.GameState.running:
         if (life <= 0)
         {
             GameManager.state = GameManager.GameState.gameOver;
         }
         if (Input.GetMouseButtonDown(0)) //press left click
         {
             Vector3 clickPos = Camera.main.ScreenToWorldPoint(
                 new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
             cannon.Fire(clickPos);
         }
         break;
     }
 }
Example #8
0
    void Update()
    {
        // movement
        moveUp    = Input.GetKey(KeyCode.UpArrow);
        moveDown  = Input.GetKey(KeyCode.DownArrow);
        moveLeft  = Input.GetKey(KeyCode.LeftArrow);
        moveRight = Input.GetKey(KeyCode.RightArrow);
        if (moveUp || moveDown || moveLeft || moveRight)
        {
            updateMove();
        }

        // fire
        fire = Input.GetKeyDown(KeyCode.Space);
        if (fire)
        {
            cannon.Fire();
        }
    }
    void Rndnum()
    {
        randomNumber = Random.Range(1, 5);

        if (randomNumber == 1)
        {
            Cannon1.Fire();
        }
        if (randomNumber == 2)
        {
            Cannon2.Fire();
        }
        if (randomNumber == 3)
        {
            Cannon3.Fire();
        }
        if (randomNumber == 4)
        {
            Cannon4.Fire();
        }
    }
 private void CannonFire()
 {
     cannon.Fire();
 }
Example #11
0
 private void Fire(Vector3 currentPosition)
 {
     Cannon.Fire(currentPosition);
 }