internal void RecalculateObstacleIds() { int obstacleIndex = 0; for (int i = 0; i < this.GameObjects[3][0].Count; i++) { Obstacle Obstacle = (Obstacle)this.GameObjects[3][0][i]; if (Obstacle.Destructed) { this.GameObjects[3][0].Remove(Obstacle); } else { Obstacle.Id = GlobalId.Create(503, obstacleIndex++); } } int obstacle2Index = 0; for (int i = 0; i < this.GameObjects[3][1].Count; i++) { Obstacle Obstacle = (Obstacle)this.GameObjects[3][1][i]; if (Obstacle.Destructed) { this.GameObjects[3][1].Remove(Obstacle); } else { Obstacle.Id = GlobalId.Create(503, obstacle2Index++); } } }
internal void AddGameObject(Level Level) { Deco GameObject = new Deco(this.DecoData, Level) { Position = { X = this.X << 9, Y = this.Y << 9 }, Id = GlobalId.Create(506, Level.GameObjectManager.DecoIndex[this.DecoData.VillageType]++) }; Level.GameObjectManager.GameObjects[6][this.DecoData.VillageType].Add(GameObject); }
internal void RecalculateAllIds() { for (int i = 0; i < this.GameObjects[0][0].Count; i++) { Building Building = (Building)this.GameObjects[0][0][i]; Building.Id = GlobalId.Create(500, i); } for (int i = 0; i < this.GameObjects[0][1].Count; i++) { Building Building = (Building)this.GameObjects[0][1][i]; Building.Id = GlobalId.Create(500, i); } int obstacleIndex = 0; for (int i = 0; i < this.GameObjects[3][0].Count; i++) { Obstacle Obstacle = (Obstacle)this.GameObjects[3][0][i]; if (Obstacle.Destructed) { this.GameObjects[3][0].Remove(Obstacle); } else { Obstacle.Id = GlobalId.Create(503, obstacleIndex++); } } int obstacle2Index = 0; for (int i = 0; i < this.GameObjects[3][1].Count; i++) { Obstacle Obstacle = (Obstacle)this.GameObjects[3][1][i]; if (Obstacle.Destructed) { this.GameObjects[3][1].Remove(Obstacle); } else { Obstacle.Id = GlobalId.Create(503, obstacle2Index++); } } //Trap //Deco //Vobjs }
internal void AddGameObject(GameObject GameObject) { int GType = GameObject.Type; if (GType == 0) { Building Building = (Building)GameObject; BuildingData Data = Building.BuildingData; if (Data.IsTownHall) { this.TownHall = Building; } if (Data.IsTownHall2) { this.TownHall2 = Building; } if (Data.IsWorker) { this.Level.WorkerManager.WorkerCount++; } if (Data.IsWorker2) { this.Level.WorkerManagerV2.WorkerCount++; } if (Data.IsAllianceCastle) { this.Bunker = Building; } } else if (GType == 8) { VillageObject VillageObject = (VillageObject)GameObject; VillageObjectData Data = VillageObject.VillageObjectData; if (Data.GlobalId == 39000000) { this.Boat = VillageObject; } } GameObject.Id = GlobalId.Create(500 + GType, this.GameObjects[GType][GameObject.VillageType].Count); this.GameObjects[GType][GameObject.VillageType].Add(GameObject); }
internal override void Process() { bool Valid = true; bool AltMode = false; if (this.Parameters.Length >= 1) { int Id; if (int.TryParse(this.Parameters[0], out Id)) { if (this.Parameters.Length >= 2) { Valid = bool.TryParse(this.Parameters[1], out AltMode); } if (Valid) { this.Device.GameMode.Level.Player.ModSlot.AILevel = new Level(true); Level AI = this.Device.GameMode.Level.Player.ModSlot.AILevel; var data = CSV.Tables.Get(Gamefile.Buildings).GetDataWithInstanceID(Id); if (data is BuildingData) { BuildingData BuildingData = (BuildingData)data; if (BuildingData.IsWall) { var TownHallData = CSV.Tables.Get(Gamefile.Buildings).GetDataWithID(1000001) as BuildingData; Building TownHall = new Building(TownHallData, AI) { Position = { X = (24) << 9, Y = (24) << 9, }, Id = GlobalId.Create(500, this.Buildings.Count), }; TownHall.SetUpgradeLevel(TownHallData.MaxLevel); this.Buildings.Add(TownHall); this.TileMap.AddGameObject(TownHall); } if (this.Parameters.Length < 2 || !AltMode || BuildingData.AltAttackMode) { for (int X = 3; X <= 46;) { for (int Y = 3; Y <= 46;) { if (this.IsValidPlaceForBuilding(BuildingData, X, Y, BuildingData.Width, BuildingData.Height)) { Building Building = new Building(BuildingData, AI) { Position = { X = X << 9, Y = Y << 9 }, Id = GlobalId.Create(500, this.Buildings.Count) }; Building.SetUpgradeLevel(1); if (Building.CombatComponent != null) { if (AltMode) { if (BuildingData.AltAttackMode) { if (!string.IsNullOrEmpty(BuildingData.GearUpBuilding)) { Building.CombatComponent.GearUp = 1; } Building.CombatComponent.AttackMode = true; Building.CombatComponent.AttackModeDraft = true; } } } if (Building.HeroBaseComponent != null) { HeroData HeroData = Building.HeroBaseComponent.HeroData; AI.Player.HeroUpgrades.Set(HeroData.GlobalId, 0); } this.Buildings.Add(Building); this.TileMap.AddGameObject(Building, 0); //Logging.Info(this.GetType(), "X:" + X + " Y:" + Y); break; } if (Y + BuildingData.Width < 47) { Y += BuildingData.Width; } else { Y = 47; if (X + BuildingData.Height < 47) { X += BuildingData.Height; } else { X = 47; break; } } } } this.SendChatMessage("AI Base generated, Enjoy!"); this.Device.GameMode.Level.Player.ModSlot.AIAttack = true; AI.Home.LastSave = this.Save(); } else { this.SendChatMessage("Unable to generate AI Base. The building doesn't have alt mode!."); } } else { this.SendChatMessage("Unable to generate AI Base. You may have entered unknown id causing building data to be null."); this.SendChatMessage("If you have confirmed the id is valid and the issue persists, please contact our development team ASAP"); } } else { this.SendChatMessage("Unable to generate AI Base. You have entered unknown value after building id."); } } else { this.SendChatMessage("Unable to generate AI Base. You have entered invalid id!."); } } else { new AvatarStreamEntryMessage(this.Device) { StreamEntry = new AllianceMailAvatarStreamEntry(this.Device.GameMode.Level.Player) { LowId = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, SenderName = "[System] Command Manager", SenderLeague = 22, Message = Constants.AIBaseHelp.ToString() } }.Send(); this.SendChatMessage("Please check your MailBox!"); } }