public abstract void UndoEffect( Tower tower );
public override void UndoEffect( Tower tower ) { tower.Dmg = tower.DefaultDmg; tower.Range = tower.DefaultRange; }
public abstract void ApplyEffect( Tower tower );
protected float Distance(Tower tower) { return (tower.Center - mCenter).Length(); }
public override void ApplyEffect( Tower tower ) { if( tower.DefaultDmg != 0 ) tower.Dmg = (int)( tower.DefaultDmg * ( 1 + mDamageInc ) ); tower.Range = (int)( tower.DefaultRange * ( 1 + mRangeInc ) ); }
private void ExitBuildMode() { mBuildType = null; mTowerToBeBuilt = null; mBuildMode = false; mCanBuild = false; foreach (Button b in mButtonsDirect) b.Release(); foreach (Button b in mButtonsSplash) b.Release(); foreach (Button b in mButtonsUtility) b.Release(); }
private void UpdateKeyboard() { if (Input.WasKeyPressed(Keys.D)) { // Debug info [D] DebugInfo = !DebugInfo; } else if (Input.WasKeyPressed(Keys.Tab) && Input.IsKeyDown(Keys.LeftShift) == false) { // Jump to next tower [Tab] if (World.Towers.Count > 0) { if (mSelectedTower != null) { int i = World.Towers.IndexOf(mSelectedTower); if (i != -1) { // Previous tower if (Input.IsKeyDown(Keys.LeftControl) || Input.IsKeyDown(Keys.RightControl)) { i = ((i - 1) < 0 ? World.Towers.Count - 1 : i - 1); } else { i = ((i + 1) < World.Towers.Count ? i + 1 : 0); } mSelectedTower = World.Towers[i] as Tower; } } else { mSelectedTower = World.Towers[0] as Tower; } } } else if (Input.WasKeyPressed(Keys.Tab) && Input.IsKeyDown(Keys.LeftShift)) { // Jump to next tower without full upgrade [SHIFT+Tab] if (World.Towers.Count > 0) { if (mSelectedTower != null) { int i = World.Towers.IndexOf(mSelectedTower); if (i != -1) { for (i++; i < World.Towers.Count; i++) { if ((World.Towers[i] as Tower).Level < Tower.MAX_LVL) { break; } } if (i >= World.Towers.Count) { int iBase = World.Towers.IndexOf(mSelectedTower) + i; for (i = 0; i < iBase; i++) { if ((World.Towers[i] as Tower).Level < Tower.MAX_LVL) { break; } } if (i >= World.Towers.Count) { // Failed to find a tower without upgrade? i = 0; } } mSelectedTower = World.Towers[i] as Tower; } } else { mSelectedTower = World.Towers[0] as Tower; } } } else if (Input.WasKeyPressed(Keys.U)) { // Uprade selected tower [U] if (mSelectedTower != null) { mButtonUpgrade.Press(); } } else if (Input.WasKeyPressed(Keys.Delete)) { // Delete tower [DEL] if (mSelectedTower != null) { World.Status.Money += mSelectedTower.CurrentWorth(); World.Map.RemoveTower(mSelectedTower.TowerBase); World.Towers.Remove(mSelectedTower); mSelectedTower = null; } } else if (Input.WasKeyPressed(Keys.Escape)) { // Menu [ESC] if (mBuildMode) { ExitBuildMode(); } mDrawMenu = !mDrawMenu; mDisplayControls = false; World.GamePaused = mDrawMenu; } else if (Input.WasKeyPressed(Keys.M) && !Input.IsKeyDown(Keys.C)) { // Minimap extend [M] ExpandMinimap(); } else if (Input.WasKeyPressed(Keys.LeftAlt) || Input.WasKeyPressed(Keys.RightAlt)) { // Tower level [ALT] World.GameDisplayTowerLvls = !World.GameDisplayTowerLvls; } else if (Input.WasKeyPressed(Keys.P)) { // Pause [P] if (!mDrawMenu) { World.GamePaused = !World.GamePaused; } } else if (Input.WasKeyPressed(Keys.S)) { // Sound on/off [S] World.Status.Sound = !World.Status.Sound; } else if (Input.WasKeyPressed(Keys.T)) { // Unit paths hide/show [T] DrawPaths = !DrawPaths; } else if (Input.IsKeyDown(Keys.G) && Input.WasKeyPressed(Keys.OemPlus)) { // Graphic quality increase [G+] if (World.Status.GraphicsQuality < 1f) { World.Status.GraphicsQuality += 0.1f; } } else if (Input.IsKeyDown(Keys.G) && Input.WasKeyPressed(Keys.OemMinus)) { // Graphic quality decrease [G-] if (World.Status.GraphicsQuality > 0.1f) { World.Status.GraphicsQuality -= 0.1f; } } else if (Input.IsKeyDown(Keys.C) && Input.WasKeyPressed(Keys.N)) { // Easy mode World.SetGameDifficult(EGameDifficult.Easy); } else if (Input.IsKeyDown(Keys.C) && Input.WasKeyPressed(Keys.M)) { // Medium mode World.SetGameDifficult(EGameDifficult.Medium); } else if (Input.IsKeyDown(Keys.C) && Input.WasKeyPressed(Keys.H)) { // Hard mode World.SetGameDifficult(EGameDifficult.Hard); } else if (Input.IsKeyDown(Keys.C) && Input.IsKeyDown(Keys.W) && Input.WasKeyPressed(Keys.OemPlus)) { // Wave num increase World.Status.Wave++; World.SpawnHealth = 100 + (World.Status.Wave * 10); World.UpdateWaveSpawnSize(); } else if (Input.IsKeyDown(Keys.C) && Input.IsKeyDown(Keys.M) && Input.WasKeyPressed(Keys.OemPlus)) { // Money increase World.Status.Money += 10000; } // Movement using arrows, increased while hold CTRL int scrollValue = ScrollValue * (Input.IsKeyDown(Keys.LeftControl) || Input.IsKeyDown(Keys.RightControl) ? 5 : 1); if (Input.IsKeyDown(Keys.Down)) { mCamera.Move(new Vector2(0, scrollValue)); } else if (Input.IsKeyDown(Keys.Up)) { mCamera.Move(new Vector2(0, -scrollValue)); } if (Input.IsKeyDown(Keys.Left)) { mCamera.Move(new Vector2(-scrollValue, 0)); } else if (Input.IsKeyDown(Keys.Right)) { mCamera.Move(new Vector2(scrollValue, 0)); } if (Input.IsKeyDown(Keys.G) == false && Input.IsKeyDown(Keys.OemPlus)) { // Zoom in [+] mCamera.ZoomIn(ZoomValue); } else if (Input.IsKeyDown(Keys.G) == false && Input.IsKeyDown(Keys.OemMinus)) { // Zoom out [-] mCamera.ZoomOut(ZoomValue); } else if (Input.ScrollWheelDelta != 0) { // Zoom [Scroll] float zoom = Input.ScrollWheelDelta / 10; if (zoom > 0) { mCamera.ZoomIn(zoom); } else { mCamera.ZoomOut(-zoom); } } }
private void UpdateSelection() { if (!Input.BoundsReal.Intersects(World.Map.Bounds) || mBuildMode) return; foreach (Tower t in World.Towers) if (Input.Bounds.Intersects(t.TowerBase)) { mSelectedTower = t; break; } }
public virtual void TowerType(string buildType) { switch (buildType) { default: mTowerToBeBuilt = null; mCanBuild = false; break; } }
private void UpdateMouse() { if (mBuildMode) mCanBuild = CanBuild(); if (Input.IsButtonDown(EMouseButtons.LeftButton)) MoveCam(); else if (Input.WasButtonPressed(EMouseButtons.LeftButton)) { if (!World.StartWaves && !mBuildMode && startButtonArea.Contains(Input.PositionReal)) World.StartWaves = true; UpdateSelection(); CheckButtons(); CheckBuilding(); } else if (Input.WasButtonPressed(EMouseButtons.RightButton)) { if (mBuildMode) ExitBuildMode(); else mSelectedTower = null; } }