Exemplo n.º 1
0
        public TBAGW.EnemyAIInfo ToEnemy(TBAGW.MapZone mz, List <BasicTile> playerZone)
        {
            TBAGW.EnemyAIInfo temp = mz.zoneEncounterInfo.enemies.Find(e => e.enemyName.Equals(name, StringComparison.OrdinalIgnoreCase) ||
                                                                       name.Equals(e.enemyCharBase.CharacterName, StringComparison.OrdinalIgnoreCase) ||
                                                                       name.Equals(e.enemyCharBase.displayName, StringComparison.OrdinalIgnoreCase));

            if (temp == null)
            {
                return(null);
            }

            bool      bGenerateLocation = true;
            Vector2   pos  = new Vector2(location.x * 64, location.y * 64);
            BasicTile tile = new BasicTile();

            if (mz.Contains(pos))
            {
                tile = GameProcessor.loadedMap.possibleTilesGameZoneForEnemyINITIALIZATION(mz.zoneTiles).Except(playerZone).ToList().Find(t => t.positionGrid == new Vector2(location.x, location.y));
                if (tile != default(TBAGW.BasicTile))
                {
                    Console.WriteLine("From LuaScriptBattle, script enemy has correct spawn location!");
                    bGenerateLocation = false;

                    //int randomNum = GamePlayUtility.Randomize(0, temp.Count);
                    //var randomTile = temp[randomNum];
                }
            }

            if (bGenerateLocation)
            {
                Console.WriteLine("From LuaScriptBattle, script enemy has incorrect spawn location!");
                var tiles = GameProcessor.loadedMap.possibleTilesGameZoneForEnemyINITIALIZATION(mz.zoneTiles).Except(playerZone).ToList();
                if (tiles.Count < PlayerSaveData.heroParty.Count)
                {
                    return(null);
                }
                int randomNum = GamePlayUtility.Randomize(0, tiles.Count);
                tile = tiles[randomNum];
            }

            CombatProcessor.encounterEnemies.Add(temp.enemyCharBase);
            CombatProcessor.encounterEnemies.Last().spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);

            CombatProcessor.encounterEnemies.Last().position      = CombatProcessor.encounterEnemies.Last().spriteGameSize.Location.ToVector2();
            CombatProcessor.encounterEnemies.Last().rotationIndex = rot % 4;
            CombatProcessor.encounterEnemies.Last().UpdatePosition();

            //temp.enemyCharBase.spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);
            //item.spriteGameSize.Width = 64;
            //item.spriteGameSize.Height = 64;
            //temp.enemyCharBase.spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);
            //temp.enemyCharBase.rotationIndex = rot % 4;
            //temp.enemyCharBase.position = temp.enemyCharBase.spriteGameSize.Location.ToVector2();
            //GameProcessor.encounterEnemies = enemies;
            //CombatProcessor.encounterEnemies.Add(temp.enemyCharBase);
            //CombatProcessor.encounterEnemies.Last().spriteGameSize = new Rectangle(((Rectangle)tile.mapPosition).X, ((Rectangle)tile.mapPosition).Y, ((Rectangle)tile.mapPosition).Width, ((Rectangle)tile.mapPosition).Height);
            return(null);
        }
 public void ReloadDefaultAIAbility(GameContentDataBase gcdb, EnemyAIInfo AII)
 {
     defaultAbilityID = AII.defaultAIAbilityID;
     try
     {
         AIDefaultAttack = gcdb.gameAbilities.Find(abi => abi.abilityIdentifier == defaultAbilityID).Clone();
     }
     catch (Exception)
     {
         Console.WriteLine("Error generating default ability info for" + AII.ToString());
         AIDefaultAttack = new BasicAbility();
     }
 }
 public void AddEnemy(EnemyAIInfo eai)
 {
     enemyInfoIDs.Add(eai.infoID);
     enemies.Add(eai);
     enemySpawnChance.Add(30);
 }