コード例 #1
0
ファイル: NPC.cs プロジェクト: vladimir-aubrecht/WiccanRede
        /// <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);
        }
コード例 #2
0
        public GeneralNPC(CharacterNPC character, Vector3 position, IWalkable terrain, IControlable entity)
        {
            this.character  = character;
            this.terrain    = terrain;
            this.entity     = entity;
            this.position3D = position;
            this.position2D = terrain.Get2DMapPosition(this.position3D);
            this.taskStack  = new Stack <NpcTask>();
            this.taskMove   = new Traveling(new Astar());
            this.fightMove  = new Traveling(new Astar());

            //init start status
            this.currentStatus             = new Status();
            this.currentStatus.hp          = character.hp;
            this.currentStatus.mana        = character.mana;
            this.currentStatus.energy      = 100;
            this.currentStatus.position    = this.position2D;
            this.currentStatus.enemySeen   = 0;
            this.currentStatus.alive       = true;
            this.currentStatus.nearEnemies = new List <IActing>();

            this.targetCell = this.position2D;
            aiMap           = Map.GetInstance();
            this.npcMap     = aiMap.getRelatedMap(this.position2D, this.visualRange);
        }