private async void LoadEnemy(string enemyDataName) { var data = Autoload.Get <Data>(); if (!data.enemyData.ContainsKey(enemyDataName)) { GD.PushError($"Enemy data for {enemyDataName} not found"); return; } enemyName = enemyDataName; Stat = data.enemyData[enemyDataName]; moveSpeed = data.GetLerpedSpeedStat(Stat.MoveSpeed, MIN_SPEED, MAX_SPEED); battleTexture = new AtlasTexture { Atlas = GD.Load <Texture>(string.Format(BattleSpritePath, enemyDataName.ToLower())) }; if (sprite == null || stateMachine == null) { await ToSignal(this, "ready"); } sprite.Texture = GD.Load <Texture>(string.Format(OverworldSpritePath, enemyDataName.ToLower())); stateMachine.behaviour = GD.Load <AI_Behaviour>(string.Format(AIResourcePath, Stat.AiType.ToLower())); EmitSignal(nameof(StatsLoaded)); }
public SmartZombieModel(EnemyType type, IAiCommand command, EnemyRecord record) { EnemyType = type; Health = record.Health; Armor = record.Armor; Speed = record.Speed; Damage = record.Damage; Cooldown = record.Cooldown; Command = command; }
public void RecordEnemyHP(int id, int hp) { EnemyRecord enemyRecord = enemies.Find((EnemyRecord o) => o.id == id); if (enemyRecord == null) { enemyRecord = new EnemyRecord(); enemyRecord.id = id; enemies.Add(enemyRecord); } enemyRecord.hp = hp; }
public Formation(XmlNode node) : this() { ID = node.SelectSingleNode("@id").Value; XmlNode typeNode = node.SelectSingleNode("@type"); if (typeNode != null) { Type = (FormationType)Enum.Parse(typeof(FormationType), typeNode.Value); } else { Type = FormationType.Normal; } Dictionary<string, int> counts = new Dictionary<string, int>(); foreach (XmlNode enemyNode in node.SelectNodes("enemy")) { string id = enemyNode.SelectSingleNode("@name").Value; if (!counts.ContainsKey(id)) { counts.Add(id, 1); } else { counts[id] = counts[id] + 1; } } foreach (XmlNode enemyNode in node.SelectNodes("enemy")) { EnemyRecord record = new EnemyRecord(enemyNode); string designation = ""; if (counts[record.Name] > 1) { int index = Enemies.Where(e => e.Name == record.Name).Count(); designation = ((char)('A' + index)).ToString(); } record.Designation = designation; Enemies.Add(record); } }
public Formation(XmlNode node) : this() { ID = node.SelectSingleNode("@id").Value; XmlNode typeNode = node.SelectSingleNode("@type"); if (typeNode != null) { Type = (FormationType)Enum.Parse(typeof(FormationType), typeNode.Value); } else { Type = FormationType.Normal; } Dictionary <string, int> counts = new Dictionary <string, int>(); foreach (XmlNode enemyNode in node.SelectNodes("enemy")) { string id = enemyNode.SelectSingleNode("@name").Value; if (!counts.ContainsKey(id)) { counts.Add(id, 1); } else { counts[id] = counts[id] + 1; } } foreach (XmlNode enemyNode in node.SelectNodes("enemy")) { EnemyRecord record = new EnemyRecord(enemyNode); string designation = ""; if (counts[record.Name] > 1) { int index = Enemies.Where(e => e.Name == record.Name).Count(); designation = ((char)('A' + index)).ToString(); } record.Designation = designation; Enemies.Add(record); } }
public List <Enemy> GetEnemyList(BattleState battle) { int[] e = new int[Enemies.Count]; for (int i = 0; i < Enemies.Count; i++) { e[i] = RANDOM.Next(0, (int)TurnTimer.TURN_TIMER_MAX_VALUE / 2); } switch (Type) { case FormationType.PreEmptive: case FormationType.Side: for (int i = 0; i < Party.PARTY_SIZE; i++) { e[i] /= 8; } break; } List <Enemy> enemies = new List <Enemy>(); for (int i = 0; i < Enemies.Count; i++) { EnemyRecord record = Enemies[i]; XmlDocument gamedata = Resource.GetXmlFromResource("data.enemies.xml", battle.Seven.Data.Assembly); XmlNode node = gamedata.SelectSingleNode(String.Format("//enemy[name = '{0}']", record.Name)); if (node == null) { throw new GameDataException("Formation '{0}' references nonexistent enemy '{1}'", ID, record.Name); } Enemy enemy = new Enemy(battle, node, record.X, record.Y, record.Row, e[i], record.Designation); enemies.Add(enemy); } return(enemies); }
public void SetRecordsForExplore(List <ExplorePlayerStatus> playerStatuses, PartyModel.Party party, int bossHp, bool isInGame) { List <PlayerRecord> list = new List <PlayerRecord>(); using (List <ExplorePlayerStatus> .Enumerator enumerator = playerStatuses.GetEnumerator()) { ExplorePlayerStatus p; while (enumerator.MoveNext()) { p = enumerator.Current; if (p.isSelf) { PlayerRecord selfPlayerRecord = GetSelfPlayerRecord(); if (selfPlayerRecord != null) { PlayerRecord playerRecord = p.CreateInGameRecord(selfPlayerRecord.charaInfo); if (isInGame && MonoBehaviourSingleton <StageObjectManager> .I.self != null) { playerRecord.id = MonoBehaviourSingleton <StageObjectManager> .I.self.id; } list.Add(playerRecord); } } else { CharaInfo charaInfo = null; if (party != null) { PartyModel.SlotInfo slotInfo = party.slotInfos.Find((PartyModel.SlotInfo x) => x.userInfo != null && x.userInfo.userId == p.userId); if (slotInfo != null) { charaInfo = slotInfo.userInfo; } } PlayerRecord playerRecord2 = p.CreateInGameRecord(charaInfo); if (playerRecord2 != null && playerRecord2.charaInfo != null) { list.Add(playerRecord2); } PlayerRecord playerRecord3 = players.Find((PlayerRecord x) => x != null && x.charaInfo != null && x.charaInfo.userId == p.userId); if (playerRecord3 != null) { if (isInGame) { playerRecord2.id = playerRecord3.id; } } else { playerRecord2.isShowModel = false; } } } } players.Clear(); players.AddRange(list); players.Sort(delegate(PlayerRecord a, PlayerRecord b) { int num = b.givenTotalDamage - a.givenTotalDamage; if (num != 0) { return(num); } return(a.id - b.id); }); enemies.Clear(); EnemyRecord enemyRecord = new EnemyRecord(); if (bossHp <= 0) { enemyRecord.hp = 10000000; } else { enemyRecord.hp = bossHp; } enemies.Add(enemyRecord); if (!isVictory && MonoBehaviourSingleton <CoopManager> .IsValid() && !isInGame) { pickupPlayer = players.Find((PlayerRecord x) => x.isSelf); } }