Esempio n. 1
0
    //When a Green Cube dies Scene Controller gets notified and calls another event to update the HUD
    #region Scene Controller Subscribed to Cube Death events handling
    private void ScoreBroker_GreenCubeKilled()
    {
        //When a Green Cube Dies reduce the greenScore value by 1 and call the event to update the HUD as well
        greenScore -= 1;
        ScoreBroker.CallUpdateGreenCubeScore(greenScore);

        //if there are no more green cubes in the game then the RED team is winning the fight
        if (greenScore <= 0 && currentState == GameState.RUNNING)
        {
            ScoreBroker.CallTeamIsWinning("RED");
        }
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        GameStateManager(GameState.IDLE);

        greenScore = 0;
        redScore   = 0;

        ScoreBroker.CallUpdateGreenCubeScore(greenScore);
        ScoreBroker.CallUpdateRedCubeScore(redScore);

        //Scene controller Subscribes to Cube Death as an Observer.
        ScoreBroker.GreenCubeKilled += ScoreBroker_GreenCubeKilled;
        ScoreBroker.RedCubeKilled   += ScoreBroker_RedCubeKilled;
    }
Esempio n. 3
0
    public void SpawnGreenCube()
    {
        //If this is the first cube in the game, change the state of the game to RUNNING
        if (currentState == GameState.IDLE)
        {
            GameStateManager(GameState.RUNNING);
        }

        //CHECK IF CUBE IS ABOUT TO SPAWN NEAR A COLLIDER (PLANET OR OTHER CUBES)
        do
        {
            randomSpawnPoint = Random.insideUnitSphere * warZoneRadius;
        }while (Physics.CheckSphere(randomSpawnPoint, checkRadius));

        //Spawn a GREEN Cube Prefab
        Instantiate(greenCubePrefab, randomSpawnPoint, Quaternion.identity);

        //increase GREEN SCORE as a value
        greenScore++;

        //EVENT UPDATE GREENSCORE to update the score on the HUD
        ScoreBroker.CallUpdateGreenCubeScore(greenScore);
    }