Exemplo n.º 1
0
    private void LoadNextLevel()
    {
        currentLevelIndex++;
        currentLevel = new Level(maps[currentLevelIndex])
        {
            victoryCallback = OnEnemiesDefeat,
            defeatCallback  = OnPlayerDefeat,
            enemyController = enemyController,
        };

        currentLevel.BuildMap();
        PositionCamera();
        PathFinder.CreateInstance(currentLevel.grid);

        var playerPosition = currentLevel.map.PlayerSpawnPoint();

        playerController = Instantiate(playerTankPrefab, playerPosition, Quaternion.identity);
        playerController.GetComponent <Breakable>().OnBreak += OnPlayerDefeat;

        enemyController.playerTransform = playerController.transform;

        // TODO: read these from map
        int[] enemyCounts = currentLevel.GetEnemyCounts();
        int   hunterCount = enemyCounts[(int)TankType.Hunter];
        int   pummelCount = enemyCounts[(int)TankType.Pummel];
        int   heavyCount  = enemyCounts[(int)TankType.Heavy];

        playerHpBar.SetPlayer(playerController.GetComponent <Breakable>());
        playerHpBar.SetBase(currentLevel.playerBaseBreakable);

        // Setup done, start systems
        enemyController.Begin(hunterCount, pummelCount, heavyCount);
        levelSpawner = StartCoroutine(currentLevel.Spawn());
        backGroundMusic.Play(backGroundMusic.Game);
        playUpdate = StartCoroutine(UpdatePlay());
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (player != null)
     {
         state = player.GetComponent <TankAimingComponent>().GetFiringState();
     }
     if (state == TankAimingComponent.FiringState.Reloading)
     {
         graphic.sprite = reloading;
     }
     else if (state == TankAimingComponent.FiringState.Moving)
     {
         graphic.sprite = moving;
     }
     else
     {
         graphic.sprite = firing;
     }
 }