Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            slowBomb = 1;
            bombsManager.SetSelected(true);
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            slowBomb = 0;
            bombsManager.SetSelected(false);
        }

        if (Input.GetButtonDown("Fire1"))
        {
            if (bombsManager.GetSelected() > 0)
            {
                Shoot();
                bombsManager.SubtractSelected(1);
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Q))
        {
            if (move.RequestFreeze())
            {
                if (!bombHeld && bombsManager.GetSelected() > 0 && pick.SpawnBomb())
                {
                    bombHeld = true;
                    bomb     = Instantiate(SelectBomb(bombSelector), move.transform.position, Quaternion.identity);
                    pick.SetPayload(bomb);
                    bombsManager.SubtractSelected(1);
                    startingBomb = bombSelector;
                }
                else if (!bombHeld && bombsManager.GetSelected() < 1 && bombsManager.GetNonSelected() > 0 && pick.SpawnBomb())
                {
                    bombSelector = !bombSelector;
                    bombsManager.ToggleSelected();

                    bombHeld = true;
                    bomb     = Instantiate(SelectBomb(bombSelector), move.transform.position, Quaternion.identity);
                    pick.SetPayload(bomb);
                    bombsManager.SubtractSelected(1);
                    startingBomb = bombSelector;
                }
                else if (bombHeld)
                {
                    bombsManager.AddSelected(1);
                    Destroy(bomb);

                    if (bombSelector != startingBomb || bombsManager.GetNonSelected() < 1)
                    {
                        pick.TossBomb();
                        bombHeld = false;
                        bomb     = null;
                    }
                    else
                    {
                        bombSelector = !bombSelector;
                        bombsManager.ToggleSelected();
                        bombsManager.SubtractSelected(1);
                        bomb = Instantiate(SelectBomb(bombSelector), move.transform.position, Quaternion.identity);
                        pick.SetPayload(bomb);
                    }
                }
                Invoke("CallReleaseFreeze", delay);
            }
        }
        else if (Input.GetKeyDown("space"))
        {
            if (bombHeld && move.RequestFreeze())
            {
                pick.TossBomb();
                bombHeld = false;
                bomb.GetComponent <BombFlight2>().target = move.transform.position + move.DirectionToVector(move.FaceDirection);
                bombSpeed = bomb.GetComponent <BombFlight2>().Speed;
                bomb.GetComponent <BombFlight2>().Fly();
                bomb = null;
                Invoke("CallReleaseFreeze", delay);
            }
        }
    }