예제 #1
0
파일: Ship.cs 프로젝트: Akahei/Asteroids
 public void Fire()
 {
     if (Time.time > fireCooldown)
     {
         fireCooldown = Time.time + 1f / MaxProjectilePerSec;
         ShipCannon.Fire(gameObject);
     }
 }
예제 #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();
 }
예제 #3
0
    private IEnumerator MakeFireRoutine()
    {
        var delay = new WaitForSeconds(shotDelay);

        while (active)
        {
            cannon.Fire();
            yield return(delay);
        }
    }
예제 #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;
     }
 }
예제 #6
0
    private IEnumerator procFire()
    {
        while (!isHittable())
        {
            yield return(null);
        }

        yield return(null);

        cannon.Fire();

        yield return(null);

        StartCoroutine(procFire());
    }
예제 #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;
     }
 }
예제 #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();
        }
    }
예제 #9
0
    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();
        }
    }
예제 #10
0
 private void CannonFire()
 {
     cannon.Fire();
 }
예제 #11
0
 private void Fire(Vector3 currentPosition)
 {
     Cannon.Fire(currentPosition);
 }