using UnityEngine; using System.Collections; using System.Collections.Generic; public class CraftAI : AI { public bool followTarget; protected float lastCheckOccupyTime; protected float checkOccupyInterval = 3f; protected Craft owner { get{ return _owner as Craft; } } protected virtual bool CheckOccupy() { if(GameTime.time - lastCheckOccupyTime > checkOccupyInterval) { lastCheckOccupyTime = GameTime.time; return true; } return false; } public void AttempGetItem(MapItem mapItem) { if(!CanSendMessage()) { return; } if(!owner.IsHero()) return; if(mapItem is FlagItem) DealFlag(mapItem as FlagItem); else battleController.GetMessageManager().GetItem(player, owner.id, mapItem.id); } private void DealFlag(FlagItem flagItem) { if (flagItem.linkedCraftId >= 0) return; if(flagItem.team == owner.team) { if(flagItem.IsInBase()) { FlagItem oppFlagItem = battleController.GetMap().GetFlag(TeamUtil.GetOpponentTeam(flagItem.team)); if(oppFlagItem.linkedCraftId == owner.id) battleController.GetMessageManager().CaptureFlag(player, owner); } else { battleController.GetMessageManager().ReturnFlag(player, owner, flagItem); } } else battleController.GetMessageManager().GetFlag(player, owner, flagItem); } protected void FindMaxThreatTarget() { if(map.HasFlag()) { FlagItem myFlag = map.GetFlag(owner.team); if(myFlag.linkedCraftId != -1) { owner.target = map.GetBattleObject(myFlag.linkedCraftId); return; } } else if(map.id == MapData.MapID.Challenge) { List list = battleController.GetMap().GetCrystalBaseList(); for(int i=0; i