void Start() { m_value = m_tower1Data.value; m_attackRadius = m_tower1Data.attackRadius; m_damage = m_tower1Data.damage; m_attackRate = m_tower1Data.attackRate; m_towerType = m_tower1Data.towerType; m_towerStatus = m_tower1Data.towerStatus; m_sprite = m_tower1Data.sprite; upgradeCost = m_tower1Data.upgradeCost; m_attackTimer = m_attackRate; m_spriteRenderer = GetComponent <SpriteRenderer>(); CircleCollider2D circle = gameObject.GetComponent <CircleCollider2D>(); if (circle) { circle.radius = m_attackRadius; } else { SphereCollider ball = gameObject.GetComponent <SphereCollider>(); if (ball) { ball.radius = m_attackRadius; } } }
// Cost to build a level 1 tower of this type protected string CreateTowerBuildCost(eTowerType type) { string str = ""; int cost = 0; switch (type) { case (eTowerType.Projectile): cost = Balance.ProjectileTower[0].BuildCost; break; case (eTowerType.Slow): cost = Balance.SlowTower[0].BuildCost; break; } GameState g = GameState.Get(); if (cost > g.Money) { str = String.Format("<font color='#ff0000'>${0:N0}</font>", cost); } else { str = String.Format("${0:N0}", cost); } return(str); }
// Try to build a building as requested protected void TryBuild(eTowerType type) { bool bSuccess = GameState.Get().TryBuild(type); if (bSuccess) { SoundManager.Get().PlaySoundCue("Build"); SwitchGrid(eGridState.Upgrade); } }
// Amount of time it takes to build a level 1 tower of this type protected string CreateTowerBuildTime(eTowerType type) { string str = ""; float time = 0.0f; switch (type) { case (eTowerType.Projectile): time = Balance.ProjectileTower[0].BuildTime; break; case (eTowerType.Slow): time = Balance.SlowTower[0].BuildTime; break; } str = String.Format("{0:F1}", time); return(str); }
/// <summary> /// Prevents a default instance of the <see cref="Missle"/> class from being created. /// </summary> /// <param name="aimID">The aim ID.</param> /// <param name="damadge">The damadge.</param> /// <param name="missleType">Type of the missle.</param> /// <param name="misslePenColor">Color of the missle pen.</param> /// <param name="missleBrushColor">Color of the missle brush.</param> /// <param name="modificator">The modificator.</param> /// <param name="position">The position.</param> /// <param name="progress">The progress.</param> private Missle(int aimID, int damadge, eTowerType missleType, Color misslePenColor, Color missleBrushColor, eModificatorName modificator, PointF position, int progress = 30) { _aimID = aimID; _damadge = damadge; _missleType = missleType; _missleBrushColor = missleBrushColor; _misslePenColor = misslePenColor; _modificator = modificator; DestroyMe = false; _position = new PointF(position.X, position.Y); _progress = progress; }
// Amount of time it takes to build a level 1 tower of this type protected string CreateTowerBuildTime(eTowerType type) { string str = ""; float time = 0.0f; switch (type) { case (eTowerType.Projectile): time = Balance.ProjectileTower[0].BuildTime; break; case (eTowerType.Slow): time = Balance.SlowTower[0].BuildTime; break; } str = String.Format("{0:F1}", time); return str; }
// Cost to build a level 1 tower of this type protected string CreateTowerBuildCost(eTowerType type) { string str = ""; int cost = 0; switch (type) { case (eTowerType.Projectile): cost = Balance.ProjectileTower[0].BuildCost; break; case (eTowerType.Slow): cost = Balance.SlowTower[0].BuildCost; break; } GameState g = GameState.Get(); if (cost > g.Money) { str = String.Format("<font color='#ff0000'>${0:N0}</font>", cost); } else { str = String.Format("${0:N0}", cost); } return str; }
// Returns a list of towers that are of type 'type' // // player is the towers owner to look for. // // type is the tower type to look for public TowerState[] getTowersByType(ePlayer player, eTowerType type) { Debug.LogError("getTowersByType not initilized"); return(this.mtowers); }
// Try to build the specified tower at the current tile. // Returns true if succeeds public bool TryBuild(eTowerType type) { // Check and make sure we can afford this building int BuildCost = 0; switch (type) { case (eTowerType.Projectile): BuildCost = Balance.ProjectileTower[0].BuildCost; break; case (eTowerType.Slow): BuildCost = Balance.SlowTower[0].BuildCost; break; } if (BuildCost > Money) { m_UIGameplay.ShowErrorMessage(Localization.Get().Text("ui_err_money")); return(false); } // Create the tower // We don't use SpawnGameObject here because the Tower is a child of its Tile Objects.Tower tower = null; switch (type) { case (eTowerType.Projectile): tower = new Objects.ProjectileTower(m_Game); break; case (eTowerType.Slow): tower = new Objects.SlowTower(m_Game); break; } tower.Load(); // Check whether or not there still is a route for enemies to take // before building this! m_SelectedTile.PreviewBuild(tower); if (!Pathfinder.Get().ComputeAStar()) { m_UIGameplay.ShowErrorMessage(Localization.Get().Text("ui_err_block")); // Clear out this tower and recompute old path m_SelectedTile.ClearTower(); Pathfinder.Get().ComputeAStar(); return(false); } else { // Any active enemies need to compute new paths, in case the old one is blocked foreach (Objects.Enemy e in m_Enemies) { Pathfinder.Get().ComputeAStar(e); } m_SelectedTile.Build(tower, false); m_UIGameplay.FinishBuild(); } return(true); }