Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (reachedExit && CurrentObjective.IsAchieved())
        {
            ScoreManager.SaveScore();
            EndLevel(true);
        }

        if (PlayersDead)
        {
            ScoreManager.SaveScore();
            if (CurrentObjective.GetComponent <Endless>() != null)
            {
                EndLevel(true);
            }
            EndLevel(false);
        }
    }
Ejemplo n.º 2
0
    private void setObjective()
    {
        // Create an Objective based on the type provided by the TileMap
        switch (GameTileMapReference.ObjectiveType)
        {
        case Objectives.Type.KillAll:
            CurrentObjective         = gameObject.AddComponent <Kill_Enemy>();
            CurrentObjective.Manager = this;
            break;

        case Objectives.Type.CollectCoins:
            CurrentObjective         = gameObject.AddComponent <Collect_Coins>();
            CurrentObjective.Manager = this;
            break;

        case Objectives.Type.NoDamage:
            CurrentObjective         = gameObject.AddComponent <No_Dmg_Taken>();
            CurrentObjective.Manager = this;
            break;

        case Objectives.Type.Endless:
            CurrentObjective = gameObject.AddComponent <Endless>();
            Endless mode = CurrentObjective.GetComponent <Endless>();
            mode.RefPlayer1          = PlayerList[0];
            mode.RefPlayer2          = PlayerList[1];
            mode.RefEnemyManager     = EnemiesManager;
            mode.RefWaypointManager  = GetComponentInChildren <WaypointManager>();
            CurrentObjective.Manager = this;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        // Initialize the Objective with the string provided
        if (CurrentObjective.ParseParamString(GameTileMapReference.ObjectiveParams) == false)
        {
            throw new UnityException("Failed to load Objective parameters!");
        }

        // Tie the Objective with this GameManager
        CurrentObjective.Manager = this;
    }
Ejemplo n.º 3
0
    private void setObjective()
    {
        // Create an Objective based on the type provided by the TileMap
        switch (GameTileMapReference.ObjectiveType)
        {
            case Objectives.Type.KillAll:
                CurrentObjective = gameObject.AddComponent<Kill_Enemy>();
                CurrentObjective.Manager = this;
                break;
            case Objectives.Type.CollectCoins:
                CurrentObjective = gameObject.AddComponent<Collect_Coins>();
                CurrentObjective.Manager = this;
                break;
            case Objectives.Type.NoDamage:
                CurrentObjective = gameObject.AddComponent<No_Dmg_Taken>();
                CurrentObjective.Manager = this;
                break;
            case Objectives.Type.Endless:
                CurrentObjective = gameObject.AddComponent<Endless>();
                Endless mode = CurrentObjective.GetComponent<Endless>();
                mode.RefPlayer1 = PlayerList[0];
                mode.RefPlayer2 = PlayerList[1];
                mode.RefEnemyManager = EnemiesManager;
                mode.RefWaypointManager = GetComponentInChildren<WaypointManager>();
                CurrentObjective.Manager = this;
                break;
            default:
                throw new ArgumentOutOfRangeException();
        }

        // Initialize the Objective with the string provided
        if (CurrentObjective.ParseParamString(GameTileMapReference.ObjectiveParams) == false)
        {
            throw new UnityException("Failed to load Objective parameters!");
        }

        // Tie the Objective with this GameManager
        CurrentObjective.Manager = this;
    }