Exemple #1
0
    public override bool TrainEngineEnemyTrigger(Collider other)
    {
        if (other.tag == "EnemyPlayer")
        {
            TrainEngineEnemy enemy = (TrainEngineEnemy)other.gameObject.GetComponent(typeof(TrainEngineEnemy));

            if (!enemy.destroyed)
            {
                if (!destroyLastTrainCar())
                {
                    DestroyTrain(other.gameObject);
                }
            }

            enemy.DestroyTrain(gameObject);
            AkCallEvent("");
            if (!destroyed)
            {
                if (gameState == 0 || gameState == 3)//train wreck mode(1) or boss/survival(3)
                {
                    PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score", 0) + 1);
                }
            }
            return(true);
        }
        return(false);
    }
Exemple #2
0
 public override bool TrainEngineEnemyTrigger(Collider other)
 {
     if (other.tag == "EnemyPlayer")
     {
         TrainEngineEnemy enemy = (TrainEngineEnemy)other.gameObject.GetComponent(typeof(TrainEngineEnemy));
         if (!enemy.destroyed && !this.destroyed)
         {
             if (gameState == 0 || gameState == 3)                                //train wreck mode(1) or boss/survival(3)
             {
                 PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score", 0) + 2); //add 2 for both trains being destroyed
             }
         }
         enemy.DestroyTrain(gameObject);
         Destroy(enemy.gameObject);
         return(true);
     }
     return(false);
 }
Exemple #3
0
    void Start()
    {
        MainTrain           = (TrainEngineMainPlayer)GameObject.FindGameObjectWithTag("MainPlayer").GetComponent(typeof(TrainEngineMainPlayer));
        MainTrain.gameState = gameState;

        GameObject[] enemyTrains = GameObject.FindGameObjectsWithTag("EnemyPlayer");
        trainsSpawned += enemyTrains.Length;
        foreach (GameObject enemys in enemyTrains)
        {
            TrainEngineEnemy enemy = (TrainEngineEnemy)enemys.GetComponent(typeof(TrainEngineEnemy));
            enemy.gameState = gameState;
        }

        GameObject[] TrainCars = GameObject.FindGameObjectsWithTag("TrainCar");
        foreach (GameObject trainCar in TrainCars)
        {
            TrainCarController trainC = (TrainCarController)trainCar.GetComponent(typeof(TrainCarController));
            trainC.gameState = gameState;
        }

        GameObject[] TrainSpawners = GameObject.FindGameObjectsWithTag("TrainSpawner");
        foreach (GameObject TrainSpawner in TrainSpawners)
        {
            TrainSpawner spawner = (TrainSpawner)TrainSpawner.GetComponent(typeof(TrainSpawner));
            spawner.gameState = gameState;
        }

        GameObject[] CoalSpawners = GameObject.FindGameObjectsWithTag("CoalSpawner");
        foreach (GameObject CoalSpawner in CoalSpawners)
        {
            CoalSpawner spawner = (CoalSpawner)CoalSpawner.GetComponent(typeof(CoalSpawner));
            spawner.gameState = gameState;
        }

        PlayerPrefs.SetInt("Level", Application.loadedLevel - 2);
        timeOfLastTrainSpawn = 0;

        scoreText.text = "score: " + PlayerPrefs.GetInt("Score", 0);
        switch (gameState)
        {
        case 0:
            //scoreText.text = "trains to Destroy: " + PlayerPrefs.GetInt("Score", 0) + "/" + (totalTrainsSpawned);
            break;

        case 1:

            break;

        case 2:

            break;

        case 3:
            totalTrainsSpawned = 30 - PlayerPrefs.GetInt(Zone + "0", 0);
            scoreText.text     = "trains to Destroy: " + PlayerPrefs.GetInt("Score", 0) + "/" + (totalTrainsSpawned);
            MainTrain.coal     = (PlayerPrefs.GetInt(Zone + "1", 0));
            int CarsCollected = PlayerPrefs.GetInt(Zone + "2", 0);
            PlayerPrefs.SetString("zone", Zone);
            break;
        }

        Time.timeScale = 0;             //pause game

        PlayerPrefs.SetInt("Score", 0); //set score for the game to zero (reset it)

        //load sound bank
        uint bankID;

        AkSoundEngine.LoadBank("Trainwrex.bnk", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
        AkSoundEngine.PostEvent("Gameplay_Train_Loop_Stop", MainTrain.gameObject);
    }