Esempio n. 1
0
    void Update()
    {
        switch (gameManager.getState())
        {
        case (BaseGM.GAMESTATE.PREGAME):
            PregameInputs();
            StandardInputs();
            break;

        //In countdown player can only rotate, no firing.
        case (BaseGM.GAMESTATE.COUNTDOWN):
            GetRotationInput();
            RestrictAngle();
            break;

        case (BaseGM.GAMESTATE.INGAME):
            if (gameManager.GetPaused() == false && !pauseMenu.activeSelf)
            {
                StandardInputs();
                CheckOpenPauseMenu();
            }
            else if (gameManager.GetPaused())
            {
                GetMenuInput();
            }

            else
            {
                StandardInputs();
            }
            break;

        case (BaseGM.GAMESTATE.POSTGAME):


            if (gameManager.getState() == BaseGM.GAMESTATE.POSTGAME && rewiredPlayer.GetButtonDown("StartGame"))
            {
                Debug.Log("changing to menu");
                gameManager.returnToMenu();
            }
            break;
        }
    }
Esempio n. 2
0
    IEnumerator RecursiveSpawner()
    {
        if (gameManager.getState() == BaseGM.GAMESTATE.INGAME)
        {
            Bounds     spawnerBounds   = this.GetComponentInChildren <BoxCollider2D> ().bounds;
            float      newX            = Random.Range(spawnerBounds.min.x, spawnerBounds.max.x);
            float      newY            = Random.Range(spawnerBounds.min.y, spawnerBounds.max.y);
            Vector3    powerUpLocation = new Vector3(newX, newY, 0);
            GameObject powerUp         = Instantiate(powerUpPrefabs [Random.Range(0, powerUpPrefabs.Length - 1)], powerUpLocation, Quaternion.identity) as GameObject;
            powerUp.transform.SetParent(this.transform);
        }

        yield return(new WaitForSeconds(Random.Range(spawner * 0.5f, spawner * 1.5f)));

        StartCoroutine(RecursiveSpawner());
    }
Esempio n. 3
0
    IEnumerator RecursiveSpawner()
    {
        if (gameManager.getState() == BaseGM.GAMESTATE.INGAME)
        {
            Bounds  spawnerBounds = this.GetComponentInChildren <BoxCollider2D> ().bounds;
            float   newX          = Random.Range(spawnerBounds.min.x, spawnerBounds.max.x);
            float   newY          = Random.Range(spawnerBounds.min.y, spawnerBounds.max.y);
            Vector3 itemLocation  = new Vector3(newX, newY, 0);
            Instantiate(itemPrefab, itemLocation, Quaternion.identity);

            //yield return new WaitForSeconds (Random.Range (spawnCooldown * 0.5f, spawnCooldown * 1.5f));
            yield return(new WaitForSeconds(spawnCooldown));
        }
        else
        {
            yield return(new WaitForSeconds(0.5f));
        }

        StartCoroutine("RecursiveSpawner");
    }
Esempio n. 4
0
    void Update()
    {
        if (rewiredPlayer.GetButtonDown("Fire"))
        {
            if (!taken)
            {
                GameObject obj = Instantiate(playerRef, transform.position, transform.rotation);
                obj.GetComponent <Cannon>().SetID(playerID);
                obj.GetComponent <Cannon>().spawnPoint = this.gameObject;
                obj.GetComponentInChildren <Laser>().setGameMode(gameManager.gameMode);
                obj.GetComponent <Cannon>().SetPauseMenu(gameManager.GetPauseMenu());
                gameManager.playerCount++;
                taken = true;
            }
        }

        if (gameManager.getState() == BaseGM.GAMESTATE.INGAME)
        {
            this.gameObject.SetActive(false);
        }
    }