public SpawnGroup(int numberOfCreatures, Creature creature, int spawnFrequency, int spawnDuration) { ParentGame = creature.ParentGame; ParentMap = CurrentGame.currentMap; ExampleCreature = creature; Creatures = new Creature[numberOfCreatures]; if (creature.Spritesheet != null && File.Exists(CurrentGame.ContentDir + "Creatures\\Smalls\\NEXTWAVE" + creature.Spritesheet.Name + ".xnb")) { InfoTexture = ParentGame.Content.Load <Texture2D>("Creatures\\Smalls\\NEXTWAVE" + creature.Spritesheet.Name); } else { InfoTexture = CurrentGame.pixel; } infoTexOrigin = new Vector2(InfoTexture.Width * 0.5f, InfoTexture.Height * 0.5f); //SpawnTimetable = new int[numberOfCreatures]; SpawnPointIndex = creature.SpawnPointIndex; GoalPointIndex = creature.GoalPointIndex; AliveCreatures = new List <Creature>(); for (int i = 0; i < numberOfCreatures; i++) { //Creatures[i] = creatureType.Clone(); //---------------------------------------YKSILÖT?!------------- Creatures[i] = Creature.Clone(creature); Creatures[i].Alive = true; Creatures[i].ParentGroup = this; Creatures[i].FindPath(); //-----------------------------pitäs kattoo reittivaihtoehdot vain kerran, jakaa niitä rndisti öröille ja sit individualisoida AliveCreatures.Add(Creatures[i]); //SpawnTimetable[i] = spawnFrequency; } SpawnFrequency = spawnFrequency; GroupDuration = spawnDuration; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (CurrentGame game = new CurrentGame()) { game.Run(); } }
public Wave(HexMap map, SpawnGroup[] groups) { ParentMap = map; Groups = groups; ParentGame = map.ParentGame; Initialize(); }
//--------------------------Constructors------------------------------------ //---------------------------------------------------muista että tuki useammalle maalille on! public Creature(HexMap map, string creatureType, int spawnPointIndex, int goalPointIndex, Texture2D texture) { ParentGame = map.ParentGame; ParentMap = map; OrigPath = new List <Vector2>(); Type = creatureType; SpawnPointIndex = spawnPointIndex; GoalPointIndex = goalPointIndex; Location = map.SpawnPoints.Length > 0 ? map.ToScreenLocation(map.SpawnPoints[spawnPointIndex]) : Vector2.Zero; nextWaypoint = 1; Spritesheet = texture; SpriteScale = 1f; SpritesheetRows = 1; if (texture != null) { SpritesheetColumns = texture.Width / texture.Height <= 1 ? 1 : texture.Width / texture.Height; } totalFrames = SpritesheetRows * SpritesheetColumns; animationCycles = 30; //Angle = (float)Math.Atan2(PosY - Path[nextWaypoint].Y, PosX - Path[nextWaypoint].X); //Angle = AnglesBetweenWaypoints[0]; //------------------------------------------------------fix //AngleOffset = (float)Math.PI; Origin = texture != null ? new Vector2(Width / 2, Height / 2) : Vector2.Zero; Alive = false; LifeDmg = 1; hpBarWidth = 25; spin = (float)(ParentMap.rnd.NextDouble() - 0.5f) * 0.08f; TowersTargetingThis = new List <Tower>(); CurrentSlowEffect = new float[2]; DmgHeadedThisWay = new List <KeyValuePair <uint, int> >(); ElemArmors = new GeneSpecs(); HpBarColor = new Color(0, 255, 0); }
public Wave(HexMap map) { ParentMap = map; ParentGame = map.ParentGame; Initialize(); }
public MainMenu(CurrentGame game) { ParentGame = game; Font = CurrentGame.font; //if (!System.IO.Directory.Exists(game.SaveDir)) //--------------------Necessary? // System.IO.Directory.CreateDirectory(game.SaveDir); FileInfo[] pfiles = new DirectoryInfo(CurrentGame.SaveDir).GetFiles(); Array.Sort(pfiles, (y, x) => Comparer <DateTime> .Default.Compare(x.CreationTime, y.CreationTime)); //------------------------------lambdaa!!!!!!!!!!!!! //PlayerFilePaths = Directory.GetFiles(game.SaveDir); PlayerFilePaths = new string[pfiles.Length]; for (int f = 0; f < pfiles.Length; f++) { PlayerFilePaths[f] = pfiles[f].FullName; } CurrentPlayerIndexes = new int[2]; PlayerNames = Array.ConvertAll <string, string>(PlayerFilePaths, Path.GetFileNameWithoutExtension); // in one line! string longestName = ""; for (int n = 0; n < PlayerNames.Length; n++) { if (PlayerNames[n].Length > longestName.Length) { longestName = PlayerNames[n]; } } padding = 10; rootButtonWidth = (int)Math.Round(Font.MeasureString("Map editor").X) + 2 * padding; //padding 10 x 2 playerButtonWidth = (int)Math.Max(Font.MeasureString("Min.koko").X, Font.MeasureString(longestName).X) + 2 * padding; mapButtonWidth = (int)Math.Round(Font.MeasureString("12345678901234567890").X); buttonHeight = Font.LineSpacing + padding; //rootButtonX = (int)(game.GraphicsDevice.Viewport.Width/2 - rootButtonWidth -1); //-----Buttonses have their right side on the screen x center rootButtonX = (int)(game.GraphicsDevice.Viewport.Width / 2.8); //-----uus vasemmal rootButtonY = (int)(game.GraphicsDevice.Viewport.Height * 0.5); //----------VANH: rootbuttons stack vertically down starting from 0.6 screenheight playerButtonX = (int)(rootButtonX + rootButtonWidth + 2); //-----right side of rootbuttons //mapButtonX = (int)(game.GraphicsDevice.Viewport.Width/2 - rootButtonWidth - mapButtonWidth -3); //-----Maps are on the left side of the rootbuttons mapButtonX = (int)(playerButtonX + playerButtonWidth + 2); //-----right side of players mapButtonY = (int)(rootButtonY - 7 * buttonHeight); buttonColors = new Color[] { new Color(10, 20, 30), new Color(20, 30, 40), new Color(30, 40, 50) }; //----passive,hovered,pressed buttonTextColors = new Color[] { Color.SlateGray, Color.Orange, Color.Orange }; //----passive,hovered,pressed RootButtons = new Button[5]; for (int i = 0; i < RootButtons.Length; i++) { switch (i) { case 0: RootButtons[i] = new Button("New Game", rootButtonX, rootButtonY + i * buttonHeight, rootButtonWidth, buttonHeight, padding, TextAlignment.Right, buttonColors, buttonTextColors, CurrentGame.pixel); break; case 1: RootButtons[i] = new Button("Continue", rootButtonX, rootButtonY + i * buttonHeight, rootButtonWidth, buttonHeight, padding, TextAlignment.Right, buttonColors, buttonTextColors, CurrentGame.pixel); break; case 2: RootButtons[i] = new Button("Options", rootButtonX, rootButtonY + i * buttonHeight, rootButtonWidth, buttonHeight, padding, TextAlignment.Right, buttonColors, buttonTextColors, CurrentGame.pixel); break; case 3: RootButtons[i] = new Button("Map editor", rootButtonX, rootButtonY + i * buttonHeight, rootButtonWidth, buttonHeight, padding, TextAlignment.Right, buttonColors, buttonTextColors, CurrentGame.pixel); break; case 4: RootButtons[i] = new Button("Quit", rootButtonX, rootButtonY + i * buttonHeight, rootButtonWidth, buttonHeight, padding, TextAlignment.Right, buttonColors, buttonTextColors, CurrentGame.pixel); break; } } PlayerButtons = new Button[PlayerNames.Length]; for (int p = 0; p < PlayerNames.Length; p++) { PlayerButtons[p] = new Button(PlayerNames[p], playerButtonX, rootButtonY + buttonHeight + p * buttonHeight, playerButtonWidth, buttonHeight, padding, TextAlignment.Left, buttonColors, buttonTextColors, CurrentGame.pixel); } NewPlayerButtons = new Button[3]; NewPlayerButtons[0] = new Button("Player name", playerButtonX, rootButtonY, playerButtonWidth, buttonHeight, 15, TextAlignment.Left, Color.Transparent, Color.Orange, CurrentGame.pixel); NewPlayerButtons[1] = new Button("text entry", playerButtonX + playerButtonWidth / 4, rootButtonY + buttonHeight, playerButtonWidth, buttonHeight, padding, TextAlignment.Left, buttonColors[1], Color.Orange, CurrentGame.pixel); NewPlayerButtons[2] = new Button("Name already exists", playerButtonX, rootButtonY + 2 * buttonHeight, playerButtonWidth, buttonHeight, 15, TextAlignment.Left, Color.Transparent, Color.Orange, CurrentGame.pixel); string[] mapNames = Array.ConvertAll <string, string>(Directory.GetFiles(CurrentGame.MapDir), Path.GetFileNameWithoutExtension); MapButtons = new Button[mapNames.Length]; for (int m = 0; m < mapNames.Length; m++) { MapButtons[m] = new Button(mapNames[m], mapButtonX, mapButtonY + m * buttonHeight, mapButtonWidth, buttonHeight, padding, TextAlignment.Center, buttonColors, buttonTextColors, CurrentGame.pixel); } MapEditorButtons = new Button[] { new Button("New map", playerButtonX, rootButtonY + 3 * buttonHeight, rootButtonWidth, buttonHeight, padding, TextAlignment.Left, buttonColors, buttonTextColors, CurrentGame.pixel) }; #region OLD BUTTONSYSTEM /*ButtonWords = new string[8 + PlayerNames.Length]; * for (int i = 0; i < 8 + PlayerNames.Length; i++) * { * switch (i) * { * case 0: ButtonWords[i] = "New Game"; break; * case 1: ButtonWords[i] = "Continue"; break; * //case 2: ButtonWords[i] = "Map editor"; break; * case 3: ButtonWords[i] = "Options"; break; * case 4: ButtonWords[i] = "Quit"; break; * case 4: ButtonWords[i] = "1"; break; * case 5: ButtonWords[i] = "2"; break; * case 6: ButtonWords[i] = "3"; break; * case 7: ButtonWords[i] = "Resolution"; break; * default: ButtonWords[i] = PlayerNames[i - 8]; break; * } * } * * * ButtonBoundses = new Rectangle[RootButtonWords.Length]; * ButtonStates = new MenuButtonState[RootButtonWords.Length]; * * for (int i = 0; i < RootButtonWords.Length; i++) * { * if (i <= 4) ButtonBoundses[i] = new Rectangle(rootButtonX, (int)(game.GraphicsDevice.Viewport.Height * 0.6 + i * buttonHeight), rootButtonWidth, buttonHeight); // Main buttons * else if (i >= 4 && i <= 6) ButtonBoundses[i] = new Rectangle(mapButtonX, (int)(game.GraphicsDevice.Viewport.Height * 0.4 + (i - 4) * buttonHeight), mapButtonWidth, buttonHeight); // Map buttons * else if (i >= 8) ButtonBoundses[i] = new Rectangle(playerButtonX, (int)(game.GraphicsDevice.Viewport.Height * 0.6 + (i - 8) * buttonHeight + buttonHeight), playerButtonWidth, buttonHeight); // Player buttons * else ButtonBoundses[i] = new Rectangle(mapButtonX, (int)(game.GraphicsDevice.Viewport.Height * 0.4 + (i - 4) * buttonHeight), mapButtonWidth, buttonHeight); // Option buttons * }*/ #endregion }
public HexMap(CurrentGame game, char[,] initLayout, Point[] spawnPoints, Point[] goalPoints, /*int[] goalPointTimetable,*/ Player[] players) { ParentGame = game; CurrentGame.currentMap = this; //tileTextures = new Texture2D[]{ ParentGame.Content.Load<Texture2D>("Tiles\\patternhex-66-57BOU2"/*"hex-66-57-04e"*/), //-----0: Seinä1 // ParentGame.Content.Load<Texture2D>("Tiles\\polkuhex-66-57borderless"/*"hex-66-57-00"*/), //-----1: Polku /* ParentGame.Content.Load<Texture2D>("Tiles\\hex-66-57-04c"), //----2: Seinä2 * ParentGame.Content.Load<Texture2D>("Tiles\\hex-66-57-04purpl"), * ParentGame.Content.Load<Texture2D>("Tiles\\hex-66-57-overlay"), * ParentGame.Content.Load<Texture2D>("Tilering\\tileringGlow"), * ParentGame.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1"), * ParentGame.Content.Load<Texture2D>("pixel"), * ParentGame.Content.Load<Texture2D>("Tilering\\ringpartFill2"), * ParentGame.Content.Load<Texture2D>("Tilering\\tileringPohj")};*/ wallTextures = new Texture2D[] { ParentGame.Content.Load <Texture2D>("Tiles\\patternhex-66-57BOU2" /*"hex-66-57-04e"*/), ParentGame.Content.Load <Texture2D>("Tiles\\hex-66-57-04c"), //----1: Seinä2 ParentGame.Content.Load <Texture2D>("Tiles\\hex-66-57-outline") }; //------grid pathTexture = ParentGame.Content.Load <Texture2D>("Tiles\\polkuhex-66-57borderless" /*"hex-66-57-00"*/); tileTexCenter = new Vector2((float)Math.Round(wallTextures[0].Width / 2f), (float)Math.Round(wallTextures[0].Height / 2f)); TileWidth = wallTextures[0].Width; TileHalfWidth = TileWidth / 2; stackedWidth = (int)(TileWidth * 0.75); //OLD: (int)Math.Round(TileWidth * 0.75) -1; //-----MINUS for texture tesselation!! TileHeight = wallTextures[0].Height % 2 == 1 ? wallTextures[0].Height - 1 : wallTextures[0].Height; //-----MINUS for ODD-dimensioned texture tesselation!! //TileWidth * (float)Math.Sqrt(3) / 2 or width * Math.Sin(60 * Math.PI/180) TileHalfHeight = TileHeight / 2; //wallNorm = Vector2.Subtract(ToScreenLocation(1, 1), ToScreenLocation(0, 0)); //wallNorm.Normalize(); //wallPerpNorm = new Vector2(-wallNorm.X, wallNorm.Y); rnd = new Random(); InitLayout = initLayout; Layout = new char[initLayout.GetLength(0), initLayout.GetLength(1)]; Array.Copy(InitLayout, Layout, InitLayout.Length); drawPos = new Point((int)(ParentGame.GraphicsDevice.Viewport.Width / 2 - Layout.GetUpperBound(1) * stackedWidth / 2), (int)(ParentGame.GraphicsDevice.Viewport.Height / 2 - Layout.GetUpperBound(0) * TileHeight / 2)); SpawnPoints = spawnPoints; GoalPoints = goalPoints; //GoalPointTimetable = goalPointTimetable; /*for (int i = 0; i < spawnPoints.Length; i++) * InitLayout[spawnPoints[i].Y, spawnPoints[i].X] = 4; * for (int i = 0; i < goalPoints.Length; i++) * InitLayout[goalPoints[i].Y, goalPoints[i].X] = 5;*/ Pathfinder = new Pathfinder(this); AliveCreatures = new List <Creature>(); //before: max 20 (why?) currentWave = -1; //ExampleTowers = new Tower[6] { new Tower("0", this, ParentGame.HUD.activeTileCoord, 75, 55, new Texture2D[] { game.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1") }, (float)Math.PI * 0.5f, CurrentGame.pixel, 12f, 1, 0, new int[] { 0, 0 }, Element.None, 10, 200), // new Tower("1", this, ParentGame.HUD.activeTileCoord, 110, 20, new Texture2D[] { game.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1") }, (float)Math.PI * 0.5f, CurrentGame.pixel, 12f, 25, 0, new int[] { 0, 0 }, Element.None, 100, 200), // new Tower("2", this, ParentGame.HUD.activeTileCoord, 80, 20, new Texture2D[] { game.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1") }, (float)Math.PI * 0.5f, CurrentGame.pixel, 12f, 25, 0, new int[] { 0, 0 }, Element.None, 100, 200), // new Tower("3", this, ParentGame.HUD.activeTileCoord, 90, 20, new Texture2D[] { game.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1") }, (float)Math.PI * 0.5f, CurrentGame.pixel, 12f, 25, 0, new int[] { 0, 0 }, Element.None, 100, 200), // new Tower("4", this, ParentGame.HUD.activeTileCoord, 120, 20, new Texture2D[] { game.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1") }, (float)Math.PI * 0.5f, CurrentGame.pixel, 12f, 25, 0, new int[] { 0, 0 }, Element.None, 100, 200), // new Tower("5", this, ParentGame.HUD.activeTileCoord, 150, 20, new Texture2D[] { game.Content.Load<Texture2D>("Towers\\TORN-66-57-väri1") }, (float)Math.PI * 0.5f, CurrentGame.pixel, 12f, 25, 0, new int[] { 0, 0 }, Element.None, 100, 200)}; //new Tower(ParentGame, "2", this, ParentGame.HUD.activeTileCoord, 100, 20, tileTextures[6], (float)Math.PI * 0.5f, tileTextures[7], null, 12f, 25, 0, new int[] { 0, 0 }, 0, 0, 0, 100, 200), ExampleTowers = new Tower[18] { new Tower('A', "Pruiter 1", Point.Zero, 75, 55, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri1") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 10, 200, true), new Tower('E', "Splasher 1", Point.Zero, 110, 50, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN1") }, new GeneSpecs(), CurrentGame.ball, 2f, 1, DmgType.Splash, 15, new float[] { 0, 0 }, 20, 200, true), new Tower('I', "Sniper 1", Point.Zero, 80, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\solubug") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 30, 200, true), new Tower('O', "Slower 1", Point.Zero, 90, 60, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri3") }, new GeneSpecs(), CurrentGame.ball, 12f, 10, 0, 0, new float[] { 0, 0 }, 10, 200, true), new Tower('U', "Grabber 1", Point.Zero, 120, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri4") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 50, 200, true), new Tower('|', "Booster 1", Point.Zero, 350, 60, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57") }, new GeneSpecs(), CurrentGame.ball, 8f, 1, 0, 0, new float[] { 0, 0 }, 15, 200, true), new Tower('Ä', "Pruiter 2", Point.Zero, 75, 55, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri6") }, new GeneSpecs(), CurrentGame.ball, 12f, 0, 0, 0, new float[] { 0.8f, 200 }, 10, 200, true), new Tower('Ë', "Splasher 2", Point.Zero, 250, 50, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN2") }, new GeneSpecs(), CurrentGame.ball, 2f, 1, DmgType.Splash, 25, new float[] { 0, 0 }, 20, 200, true), new Tower('Ï', "Sniper 2", Point.Zero, 85, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\solubug") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 30, 200, true), new Tower('Ö', "Slower 2", Point.Zero, 95, 60, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri5") }, new GeneSpecs(1f, 0, 0), CurrentGame.ball, 12f, 10, 0, 0, new float[] { 0, 0 }, 10, 200, true), new Tower('Ü', "Grabber 2", Point.Zero, 125, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri4") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 50, 200, true), new Tower('†', "Booster 2", Point.Zero, 155, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 15, 200, true), new Tower('Â', "Pruiter 3", Point.Zero, 125, 70, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri7") }, new GeneSpecs(), CurrentGame.ball, 18f, 3, 0, 0, new float[] { 0, 0 }, 10, 200, true), new Tower('Ê', "Splasher 3", Point.Zero, 120, 50, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN4") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, DmgType.Splash, 40, new float[] { 0, 0 }, 20, 200, true), new Tower('Î', "Sniper 3", Point.Zero, 90, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\solubug") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 30, 200, true), new Tower('Ô', "Slower 3", Point.Zero, 100, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri5") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 10, 200, true), new Tower('Û', "Grabber 3", Point.Zero, 130, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57-väri4") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 50, 200, true), new Tower('‡', "Booster 3", Point.Zero, 160, 20, new Texture2D[] { ParentGame.Content.Load <Texture2D>("Towers\\TORN-66-57") }, new GeneSpecs(), CurrentGame.ball, 12f, 1, 0, 0, new float[] { 0, 0 }, 15, 200, true) }; Players = players; AvailableTowers = new byte[6] { 3, 3, 3, 3, 3, 3 }; cubeCoords = new Vector3[Layout.GetLength(0) * Layout.GetLength(1)]; int i = 0; for (int row = 0; row < Layout.GetLength(0); row++) { for (int col = 0; col < Layout.GetLength(1); col++) { cubeCoords[i].X = col; cubeCoords[i].Z = row - (col - (col & 1)) / 2; cubeCoords[i].Y = -cubeCoords[i].X - cubeCoords[i].Z; i++; } } }