/// <summary> /// ctor, initialize ai structures /// </summary> /// <param name="character">character of npc</param> /// <param name="position">position on which npc stands</param> /// <param name="terrain">terrain, where npc moves</param> /// <param name="entity">pointer on graphical representation of npc, used for changing position, making effects, ...</param> public NPC(CharacterNPC character, Vector3 position, IWalkable terrain, IControlable entity) { this.position3D = position; System.Drawing.Point xy = terrain.Get2DMapPosition(position); this.x = xy.X; this.y = xy.Y; this.character = character; this.visualRange = this.character.visualRange; this.currentStatus = new Status(); this.currentStatus.hp = character.hp; this.currentStatus.mana = character.mana; this.currentStatus.energy = 100; this.currentStatus.position = this.GetPosition2D(); this.currentStatus.enemySeen = 0; this.currentStatus.alive = true; this.currentStatus.nearEnemies = new List <IActing>(); this.entity = entity; this.terrain = terrain; this.taskStack = new Stack <NpcTask>(); this.taskMove = new Traveling(new Astar()); this.fightMove = new Traveling(new Astar()); this.targetCell = new System.Drawing.Point(x, y); this.aiMap = Map.GetInstance(); pathFinding = new Astar(); this.entity.ChangePosition(position); }
public Traveling(Astar a) { pathFinding = a; path = new List <Point>(); isOnWay = false; progress = 0; }
public void Dispose() { this.targetedEnemy = null; this.taskStack = null; this.pathFinding = null; }