public FlagDroppedEvent(GamePlayState _game, int droppedId, VTankObject.Point where, GameSession.Alliance flagColor) : base(_game) { this.droppedId = droppedId; this.where = where; this.flagColor = flagColor; }
public SetBaseHealthEvent(GameSession.Alliance color, int eventId, int health, VTankBot _game) : base(_game) { this.baseColor = color; this.baseEventId = eventId; this.newBaseHealth = health; }
/// <summary> /// Adds a base to the game. /// </summary> /// <param name="color">Team color of the base.</param> /// <param name="eventId">Event ID of the base.</param> /// <param name="position">Position of the base.</param> public void AddBase(GameSession.Alliance color, int eventId, Vector3 position) { Model baseModel = ServiceManager.Resources.GetModel("events\\base"); Base newBase = new Base(color, position, eventId, baseModel); AddBase(newBase); }
/// <summary> /// Set the health of a base to a new value. /// </summary> /// <param name="eventId">The event id of the base.</param> /// <param name="health">The new health of the base.</param> public void SetBaseHealth(int eventId, int health, GameSession.Alliance baseColor) { if (!bases.ContainsKey(eventId)) { return; } if (bases[eventId].Destroyed == true && health > 0) { bases[eventId].Destroyed = false; } if (health == 0) { bases[eventId].Destroyed = true; } if (bases[eventId].BaseColor != baseColor) { bases[eventId].BaseColor = baseColor; } bases[eventId].Health = health; this.UpdateInConflictStatuses(); }
public BaseCapturedEvent(int eventId, GameSession.Alliance newBaseColor, int capturerId, GameSession.Alliance oldBaseColor, VTankBot _game) : base(_game) { this.baseEventId = eventId; this.newBaseColor = newBaseColor; this.capturerId = capturerId; this.oldBaseColor = oldBaseColor; }
public Base(int baseId, Point _position, GameSession.Alliance _team) { const int OFFSET = 8; // Offset the base ID for zero-based indexing. BaseID = baseId - OFFSET; health = DEFAULT_BASE_HEALTH; position = _position; Team = _team; }
public BaseCapturedEvent(int eventId, GameSession.Alliance newBaseColor, int capturerId, GameSession.Alliance oldBaseColor, GamePlayState _game) : base(_game) { this.baseEventId = eventId; this.newBaseColor = newBaseColor; this.capturerId = capturerId; this.oldBaseColor = oldBaseColor; }
public DamageBaseByEnvironmentEvent(VTankBot _game, GameSession.Alliance baseColor, int baseId, int envId, int damage, bool isDestroyed) : base(_game) { this.baseColor = baseColor; this.baseId = baseId; this.environmentEffectId = envId; this.damage = damage; this.isDestroyed = isDestroyed; }
public DamageBaseByEnvironmentEvent(GamePlayState _game, GameSession.Alliance baseColor, int baseId, int envId, int damage, bool isDestroyed) : base(_game) { this.baseColor = baseColor; this.baseId = baseId; this.environmentEffectId = envId; this.damage = damage; this.isDestroyed = isDestroyed; }
public void DespawnFlag(GameSession.Alliance alliance) { if (!flags.ContainsKey(alliance)) { this.AddFlag(alliance, Vector3.Zero); } flags[alliance].Unattach(); flags[alliance].ParticleEmitter0.Emitting = false; flags[alliance].ParticleEmitter1.Emitting = false; flags[alliance].Hidden = true; }
public void ResetFlag(GameSession.Alliance alliance) { if (!flags.ContainsKey(alliance)) { this.AddFlag(alliance, Vector3.Zero); } flags[alliance].ParticleEmitter0.Emitting = true; flags[alliance].ParticleEmitter1.Emitting = true; flags[alliance].Hidden = false; flags[alliance].Unattach(); flags[alliance].Position = flags[alliance].SpawnPosition; //Todo, start continuous emitter from base }
public static Color GetColor(Color defaultColor, GameSession.Alliance team) { switch (team) { case GameSession.Alliance.BLUE: return(Color.Blue); case GameSession.Alliance.RED: return(Color.Red); default: return(defaultColor); } }
public void PositionFlag(GameSession.Alliance alliance, Vector3 position) { if (!flags.ContainsKey(alliance)) { this.AddFlag(alliance, position); } flags[alliance].ParticleEmitter0.Emitting = true; flags[alliance].ParticleEmitter1.Emitting = true; flags[alliance].Unattach(); flags[alliance].Hidden = false; flags[alliance].Position = position; //TODO stop emitter from flag }
public void FlagPickedUp(GameSession.Alliance alliance, Object3 tank) { if (!flags.ContainsKey(alliance)) { this.AddFlag(alliance, tank.Position); } flags[alliance].ParticleEmitter0.Emitting = true; flags[alliance].ParticleEmitter1.Emitting = true; flags[alliance].MimicPosition(tank, new Vector3(0, 0, 70)); flags[alliance].Hidden = false; //TODO add continuous particle emitter to flag //TODO stop emitter from base }
/// <summary> /// Add a player to the scoreboard. /// </summary> /// <param name="name"></param> /// <param name="team"></param> public void AddPlayer(string name, GameSession.Alliance team) { if (team == GameSession.Alliance.BLUE) { team2[name] = new Score(customBlue, new Statistics(0, 0, 0, 0, 0, 0, name)); } else if (team == GameSession.Alliance.RED) { team1[name] = new Score(Color.Red, new Statistics(0, 0, 0, 0, 0, 0, name)); } else { team1[name] = new Score(neutralTeamColor, new Statistics(0, 0, 0, 0, 0, 0, name)); } }
/// <summary> /// Captures a base for the given team. Resets the base to undestroyed, and /// sets the base's color to its new team. /// </summary> /// <param name="newColor">The new color of the base.</param> public void CaptureBase(GameSession.Alliance newColor) { if (this.Destroyed) { this.Destroyed = false; } if (this.arrowRenderId != -1) { this.RemoveArrow(); } this.Health = Constants.MAX_BASE_HEALTH; this.BaseColor = newColor; }
/// <summary> /// One team has captured the base, so it will swap possession. /// </summary> /// <param name="eventId">Event id of the base.</param> /// <param name="newColor">The color of the new owner.</param> public void CaptureBase(int eventId, GameSession.Alliance newColor) { if (!bases.ContainsKey(eventId)) { return; } bases[eventId].CaptureBase(newColor); foreach (Base _base in bases.Values) { _base.ResetToFullHealth(); } this.UpdateInConflictStatuses(); }
/// <summary> /// Generate bases and their positions. /// </summary> private void GenerateBases() { bases.Clear(); int tileSize = AIFramework.Bot.Game.Tile.TILE_SIZE_IN_PIXELS; int mapWidth = (int)CurrentMap.Width; int mapHeight = (int)CurrentMap.Height; const int EVENT_ID_MINIMUM = 8; const int EVENT_ID_MAXIMUM = 13; int basesFound = 0; for (int y = 0; y < mapHeight; ++y) { for (int x = 0; x < mapWidth; ++x) { AIFramework.Bot.Game.Tile tile = CurrentMap.GetTile(x, y); if (tile.EventID >= EVENT_ID_MINIMUM && tile.EventID <= EVENT_ID_MAXIMUM) { // Found base tile. ++basesFound; Point position = new Point(x * tileSize + (tileSize / 2), -(y * tileSize + (tileSize / 2))); GameSession.Alliance team = tile.EventID > 10 ? GameSession.Alliance.RED : GameSession.Alliance.BLUE; Base nextBase = new Base(tile.EventID, position, team); bases[nextBase.BaseID] = nextBase; } if (basesFound == BASE_COUNT) { goto done; } } } done: if (basesFound != BASE_COUNT) { Console.Error.WriteLine("[WARNING] Bases found = {0}", basesFound); } DetectAttackableBases(); }
/// <summary> /// Add a round victory to a given team's score. /// </summary> /// <param name="team">The team to award a round win to.</param> public void AddRoundWin(GameSession.Alliance team) { if (team == GameSession.Alliance.NONE) { return; } //Red is 1, Blue is 2 if (team == GameSession.Alliance.RED) { team1stats.roundWins++; } else if (team == GameSession.Alliance.BLUE) { team2stats.roundWins++; } drawingRoundWinner = true; roundWinningTeam = team.ToString().ToLower(); }
public void AddFlag(GameSession.Alliance alliance, Vector3 spawnPosition) { if (!flags.ContainsKey(alliance)) { string a = Enum.GetName(typeof(GameSession.Alliance), alliance); a = a.ToLower(); Model mBase = ServiceManager.Resources.GetModel("events\\" + a + "_flag_spawn"); Flag nFlag = new Flag(ServiceManager.Resources.GetModel("events\\flag_" + a), spawnPosition); //setup emitters nFlag.ParticleEmitter0 = new ParticleEmitter(a + "_flag"); nFlag.ParticleEmitter0.Attach(nFlag, "Emitter0"); ServiceManager.Scene.Add(nFlag.ParticleEmitter0, 3); nFlag.ParticleEmitter1 = new ParticleEmitter(a + "_flag"); nFlag.ParticleEmitter1.Attach(nFlag, "Emitter1"); ServiceManager.Scene.Add(nFlag.ParticleEmitter1, 3); //end emitters flags.Add(alliance, nFlag); flags[alliance].RenderID = ServiceManager.Scene.Add(flags[alliance], 0); nFlag.BaseRenderID = ServiceManager.Scene.Add(mBase, spawnPosition + new Vector3(0, 0, 0.1f), 0); } }
/// <summary> /// Constructor for a Base /// </summary> /// <param name="color">The team color of the base</param> /// <param name="position">The position to place the base at</param> /// <param name="eventId">The event ID of the base</param> /// <param name="_model">The model of the base.</param> public Base(GameSession.Alliance color, Vector3 position, int eventId, Model _model) : base(_model, position) { this.originalOwner = color; this.BaseColor = color; this.Position = position; this.eventId = eventId; this.health = Constants.MAX_BASE_HEALTH; this.destroyed = false; previousDamageState = DamageState.None; ParticleEmitter0 = new ParticleEmitter("DamagedBaseFire"); ParticleEmitter1 = new ParticleEmitter("DamagedBaseFire"); ParticleEmitter2 = new ParticleEmitter("DamagedBaseFire"); ParticleEmitter3 = new ParticleEmitter("DamagedBaseFire"); StopEmitters(); ServiceManager.Scene.Add(ParticleEmitter0, 3); ServiceManager.Scene.Add(ParticleEmitter1, 3); ServiceManager.Scene.Add(ParticleEmitter2, 3); ServiceManager.Scene.Add(ParticleEmitter3, 3); }
public FlagPickedUpEvent(VTankBot _game, int pickedUpById, GameSession.Alliance flagColor) : base(_game) { this.pickedUpById = pickedUpById; this.flagColor = flagColor; }
public override void FlagSpawned(VTankObject.Point where, GameSession.Alliance flagColor, Ice.Current current__) { buffer.Enqueue(new FlagSpawnedEvent(Game, where, flagColor)); }
public FlagDespawnedEvent(GamePlayState _game, GameSession.Alliance flagColor) : base(_game) { this.flagColor = flagColor; }
/// <summary> /// Calculates parameters for tiles with height and creates DrawableTiles from them /// </summary> private void FillTiles() { Random random = new Random(); Dictionary <uint, int> borderTileCounter = new Dictionary <uint, int>(); for (uint y = 0; y < map.Height; y++) { if (borderTileCounter.ContainsKey(map.GetTile(0, y).ID) && map.GetTile(0, y).Height == 0) { borderTileCounter[map.GetTile(0, y).ID]++; } else if (map.GetTile(0, y).Height == 0) { borderTileCounter.Add(map.GetTile(0, y).ID, 1); } if (borderTileCounter.ContainsKey(map.GetTile(map.Width - 1, y).ID) && map.GetTile(map.Width - 1, y).Height == 0) { borderTileCounter[map.GetTile(map.Width - 1, y).ID]++; } else if (map.GetTile(map.Width - 1, y).Height == 0) { borderTileCounter.Add(map.GetTile(map.Width - 1, y).ID, 1); } } for (uint x = 0; x < map.Width - 1; x++) { if (borderTileCounter.ContainsKey(map.GetTile(x, 0).ID) && map.GetTile(x, 0).Height == 0) { borderTileCounter[map.GetTile(x, 0).ID]++; } else if (map.GetTile(x, 0).Height == 0) { borderTileCounter.Add(map.GetTile(x, 0).ID, 1); } if (borderTileCounter.ContainsKey(map.GetTile(x, map.Height - 1).ID) && map.GetTile(x, map.Height - 1).Height == 0) { borderTileCounter[map.GetTile(x, map.Height - 1).ID]++; } else if (map.GetTile(x, map.Height - 1).Height == 0) { borderTileCounter.Add(map.GetTile(x, map.Height - 1).ID, 1); } } int maxValue = 0; uint maxValueTile = 0; foreach (KeyValuePair <uint, int> element in borderTileCounter) { if (element.Value > maxValue) { maxValue = element.Value; maxValueTile = element.Key; } } //Load floor float minX = -10000f; float maxX = 100000f; float minY = -100000f; float maxY = 10000f; float Xspread = (maxX - minX) / Constants.TILE_SIZE; float Yspread = (maxY - minY) / Constants.TILE_SIZE; List <VertexPositionNormalTexture> verts = new List <VertexPositionNormalTexture>(); verts.Add(new VertexPositionNormalTexture(new Vector3(minX, minY, -0.75f), Vector3.UnitZ, Vector2.UnitY * Yspread)); verts.Add(new VertexPositionNormalTexture(new Vector3(minX, maxY, -0.75f), Vector3.UnitZ, Vector2.Zero)); verts.Add(new VertexPositionNormalTexture(new Vector3(maxX, minY, -0.75f), Vector3.UnitZ, new Vector2(Xspread, Yspread))); verts.Add(new VertexPositionNormalTexture(new Vector3(maxX, maxY, -0.75f), Vector3.UnitZ, Vector2.UnitX * Xspread)); verts.Add(new VertexPositionNormalTexture(new Vector3(maxX, minY, -0.75f), Vector3.UnitZ, new Vector2(Xspread, Yspread))); verts.Add(new VertexPositionNormalTexture(new Vector3(minX, maxY, -0.75f), Vector3.UnitZ, Vector2.Zero)); VertexGroup floor = new VertexGroup(TileList.GetTile((int)maxValueTile), verts); floor.Technique = RendererAssetPool.UniversalEffect.Techniques.TexturedWrap; floor.CastsShadow = false; floor.TransparencyEnabled = false; floor.Ready(); renderer.ActiveScene.Add(floor, 0); //Loads the tiles into the background array for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); // Figure out the height of each tile in each direction relative to this one. int positionNorth = (int)(y - 1); int positionSouth = (int)(y + 1); int positionWest = (int)(x - 1); int positionEast = (int)(x + 1); if (positionNorth >= 0) { tempTile.heightN = map.GetTile(x, y - 1).Height; } if (positionSouth < map.Height) { tempTile.heightS = map.GetTile(x, y + 1).Height; } if (positionWest >= 0) { tempTile.heightW = map.GetTile(x - 1, y).Height; } if (positionEast < map.Width) { tempTile.heightE = map.GetTile(x + 1, y).Height; } map.SetTile(x, y, tempTile); Texture2D texture = TileList.GetTile((int)tempTile.ID); DrawableTile tile = new DrawableTile( texture, tempTile, (int)x, (int)y, tempTile.heightN, tempTile.heightW, tempTile.heightE, tempTile.heightS); Vector3 pos = new Vector3( x * Constants.TILE_SIZE + (Constants.TILE_SIZE / 2), -(y * Constants.TILE_SIZE + (Constants.TILE_SIZE / 2)), 0); if (tempTile.ObjectID != 0) { Model objectModel = TileList.GetObject(tempTile.ObjectID); Object3 newTileObj = new Object3(objectModel, pos + (Vector3.UnitZ * tempTile.Height * Constants.TILE_SIZE)); newTileObj.TransparencyEnabled = true; Scene.Add(newTileObj, 1); } switch (tempTile.EventID) { case 4: case 5: GameSession.Alliance team = tempTile.EventID == 4 ? GameSession.Alliance.RED : GameSession.Alliance.BLUE; if (currentGameMode == VTankObject.GameMode.CAPTURETHEFLAG) { Flags.AddFlag(team, pos); } break; case 8: case 9: case 10: if (currentGameMode == VTankObject.GameMode.CAPTURETHEBASE) { Bases.AddBase(GameSession.Alliance.BLUE, tempTile.EventID, pos); } break; case 11: case 12: case 13: if (currentGameMode == VTankObject.GameMode.CAPTURETHEBASE) { Bases.AddBase(GameSession.Alliance.RED, tempTile.EventID, pos); } break; default: break; } visibleTiles[y * map.Width + x] = tile; } } #region Make Flat Tiles for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); Vector3 pos = new Vector3(x * Constants.TILE_SIZE, (-(y + 1) * Constants.TILE_SIZE), 0); Tiles.AddFloor(pos, tempTile.Height, (int)tempTile.ID); } } #endregion #region Make North Walls int height = 0; int tileID = 0; int width = 0; int Hdir = 0; //Make north facing walls for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightN)) && (x + 1) < map.Width) { height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightN; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3(x * Constants.TILE_SIZE, (-y * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, Vector3.UnitY, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightN; } } width = 0; } #endregion #region Make South Walls height = 0; tileID = 0; width = 0; Hdir = 0; uint startX = 0; //Make south facing walls for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightS)) && (x + 1) < map.Width) { if (width == 0) { startX = x; } height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightS; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3(startX * Constants.TILE_SIZE, (-(y + 1) * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, -Vector3.UnitY, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightS; startX = x; } } width = 0; } #endregion #region Make East Walls height = 0; tileID = 0; width = 0; Hdir = 0; //Make east facing walls for (uint x = 0; x < map.Width; x++) { for (uint y = 0; y < map.Height; y++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightE)) && (y + 1) < map.Height) { height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightE; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3((x + 1) * Constants.TILE_SIZE, (-y * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, Vector3.UnitX, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightE; } } width = 0; } #endregion #region Make West Walls height = 0; tileID = 0; width = 0; Hdir = 0; uint startY = 0; //Make south facing walls for (uint x = 0; x < map.Width; x++) { for (uint y = 0; y < map.Height; y++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightW)) && (y + 1) < map.Height) { if (width == 0) { startY = y; } height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightW; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3(x * Constants.TILE_SIZE, (-startY * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, -Vector3.UnitX, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightW; startY = y; } } width = 0; } #endregion Tiles.AllReady(); //////////////////////////////////////////// ///TODO:::: FOR EACH TILE GOING LEFT TO RIGHT // // IF height = height and tileID = tileID // if Hnorth = Hnorth // NorthWidth ++; // else // TexturedTileGroupManager.AddWall(lowerLeftNorth, Vector3.UnitY, NorthWidth, height, tileID) // NorthWidth = 0; // height = -1 // // if Hsouth = Hsouth // SouthWidth ++; // else // TexturedTileGroupManager.AddWall(lowerLeftSouth, -Vector3.UnitY, SouthhWidth, height, tileID) //etc }
public override void EndRound(GameSession.Alliance winner, Ice.Current current__) { buffer.Enqueue(new ResetBasesEvent(Game, winner)); }
public override void DamageBase(GameSession.Alliance baseColor, int baseId, int damage, int projectileId, int playerId, bool isDestroyed, Ice.Current current__) { buffer.Enqueue(new DamageBaseEvent(baseId, damage, playerId, projectileId, isDestroyed, Game)); }
public override void SetBaseHealth(GameSession.Alliance baseColor, int baseId, int newHealth, Ice.Current current__) { buffer.Enqueue(new SetBaseHealthEvent(baseColor, baseId, newHealth, Game)); }
public override void FlagPickedUp(int pickedUpById, GameSession.Alliance flagColor, Ice.Current current__) { buffer.Enqueue(new FlagPickedUpEvent(Game, pickedUpById, flagColor)); }
public FlagSpawnedEvent(GamePlayState _game, VTankObject.Point where, GameSession.Alliance flagColor) : base(_game) { this.where = where; this.flagColor = flagColor; }
public override void FlagDropped(int droppedId, VTankObject.Point where, GameSession.Alliance flagColor, Ice.Current current__) { buffer.Enqueue(new FlagDroppedEvent(game, droppedId, where, flagColor)); }
public ResetBasesEvent(GamePlayState _game, GameSession.Alliance winner) : base(_game) { this.winner = winner; }
public FlagDespawnedEvent(VTankBot _game, GameSession.Alliance flagColor) : base(_game) { this.flagColor = flagColor; }
public ResetBasesEvent(VTankBot _game, GameSession.Alliance winner) : base(_game) { this.winner = winner; }
public FlagReturnedEvent(GamePlayState _game, int returnedById, GameSession.Alliance flagColor) : base(_game) { this.returnedById = returnedById; this.flagColor = flagColor; }
public FlagSpawnedEvent(VTankBot _game, VTankObject.Point where, GameSession.Alliance flagColor) : base(_game) { this.where = where; this.flagColor = flagColor; }
/// <summary> /// Resets the base to it's original state. /// </summary> public void Reset() { Team = BaseID < 3 ? GameSession.Alliance.BLUE : GameSession.Alliance.RED; health = DEFAULT_BASE_HEALTH; }
public override void FlagDespawned(GameSession.Alliance flagColor, Ice.Current current__) { buffer.Enqueue(new FlagDespawnedEvent(Game, flagColor)); }
public override void FlagCaptured(int capturedById, GameSession.Alliance flagColor, Ice.Current current__) { buffer.Enqueue(new FlagCapturedEvent(Game, capturedById, flagColor)); }
public override void BaseCaptured(GameSession.Alliance oldBaseColor, GameSession.Alliance newBaseColor, int baseId, int capturerId, Ice.Current current__) { buffer.Enqueue(new BaseCapturedEvent(baseId, newBaseColor, capturerId, oldBaseColor, Game)); }
public FlagCapturedEvent(VTankBot _game, int capturedById, GameSession.Alliance flagColor) : base(_game) { this.capturedById = capturedById; this.flagColor = flagColor; }