private bool CanCast()
 {
     return(LevelManagerService.GetInstance().CurrentPlayerMana >= 3);
 }
 public override void StartSpawning()
 {
     LevelManagerService.GetInstance().SetTimeRemaining(180);
     SpawnRoutine = StartCoroutine(SpawnLoop());
 }
Exemple #3
0
    void Update()
    {
        if (FreezeUpdateLoop)
        {
            return;
        }
        if (Input.GetKey(KeyCode.Space))
        {
            UnitSpawner.SpawnSoldier();
        }
        List <Tile> tilesToRemove = GetRemovableTiles();
        Dictionary <string, int> removedTileCounts = new Dictionary <string, int>();

        if (tilesToRemove.Count > 0)
        {
            foreach (Tile ttr in tilesToRemove)
            {
                if (!removedTileCounts.ContainsKey(ttr.Name))
                {
                    removedTileCounts[ttr.Name] = 0;
                }
                removedTileCounts[ttr.Name]++;
                Vector2 ttrc = GetTileCoordinates(ttr);
                TileMap[(int)ttrc.y][(int)ttrc.x].Tile.Remove();
                TileMap[(int)ttrc.y][(int)ttrc.x].Tile = null;
            }
            if (removedTileCounts.ContainsKey("Sword") ||
                removedTileCounts.ContainsKey("Arrow") ||
                removedTileCounts.ContainsKey("Thunder") ||
                removedTileCounts.ContainsKey("Shield") ||
                removedTileCounts.ContainsKey("Void")
                )
            {
                SfxManagerService.GetInstance().PlayTilePop();
            }
            if (removedTileCounts.ContainsKey("Skull"))
            {
                SfxManagerService.GetInstance().PlaySkullPop();
            }
            if (removedTileCounts.ContainsKey("Sword"))
            {
                while (removedTileCounts["Sword"] >= 3)
                {
                    UnitSpawner.SpawnSoldier();
                    removedTileCounts["Sword"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Arrow"))
            {
                while (removedTileCounts["Arrow"] >= 3)
                {
                    UnitSpawner.SpawnArcher();
                    removedTileCounts["Arrow"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Thunder"))
            {
                while (removedTileCounts["Thunder"] >= 3)
                {
                    UnitSpawner.SpawnWizard();
                    removedTileCounts["Thunder"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Void"))
            {
                while (removedTileCounts["Void"] >= 3)
                {
                    if (LevelManagerService.GetInstance().CurrentPlayerMana < 3)
                    {
                        StartCoroutine(IncreaseManaByXOverT(1, 0.5f));
                    }
                    removedTileCounts["Void"] -= 3;
                }
            }
            if (removedTileCounts.ContainsKey("Skull"))
            {
                float skullDamage = Mathf.Min(removedTileCounts["Skull"] / 2);
                while (removedTileCounts["Skull"] >= 3)
                {
                    removedTileCounts["Skull"] -= 3;
                    List <GameObject> PlayerSpawnedUnits = UnitSpawner.GetAllSpawnedUnits();
                    foreach (GameObject u in PlayerSpawnedUnits)
                    {
                        if (u != null)
                        {
                            DamagableUnit d = u.GetComponent <DamagableUnit>();
                            if (d != null)
                            {
                                d.TakeDamage(skullDamage);
                            }
                        }
                    }
                }
            }
            StartCoroutine(PushTiles());
        }
    }