Esempio n. 1
0
        public HumanAI(NonPlayableCharacterAbstract npc)
            : base(npc)
        {
            GoalManager_.addGoal(new GoalPatrol(this));
            //GoalManager_.addGoal(new GoalIdle(this));
            GoalManager_.addGoal(new GoalInvestigate(this));
            GoalManager_.addGoal(new GoalKill(this));
            GoalManager_.setTeamGoal(new GoalTeamwork(this));

            PlanManager_.addAction(new ActionTypeTakeCover(npc));
            PlanManager_.addAction(new ActionTypeInvestigate(npc));
            PlanManager_.addAction(new ActionTypeGoto(npc));
            PlanManager_.addAction(new ActionTypePatrol(npc));
            PlanManager_.addAction(new ActionTypeAttackRanged(npc));
            PlanManager_.addAction(new ActionTypeAttackRangedCover(npc));
            PlanManager_.addAction(new ActionTypeFlee(npc));
            PlanManager_.addAction(new ActionTypePickupAmmo(npc));

            PlanManager_.addAction(new TeamActionTypeSuppress(npc));

            sensors_.Add(new SensorEars(this));
            sensors_.Add(new SensorSeeCharacter(this, FIELD_OF_VIEW));
            sensors_.Add(new SensorCover(this));
            sensors_.Add(new SensorAmmo(this, FIELD_OF_VIEW));
        }
 /// <summary>
 /// Consume a resource so that it can never again be reserved.
 /// </summary>
 /// <param name="resource">The resource in question.</param>
 /// <param name="owner">Current owner of the resource reservation.</param>
 internal static void consumeResource(Object resource, NonPlayableCharacterAbstract owner)
 {
     if (reservations_.ContainsKey(resource))
     {
         if (reservations_[resource] == owner)
         {
             reservations_[resource] = null;
         }
         else
         {
             throw new InvalidOperationException("This NPC does not own this resource");
         }
     }
 }
Esempio n. 3
0
        public DummyAI(NonPlayableCharacterAbstract npc)
            : base(npc)
        {
            GoalManager_.addGoal(new GoalPatrol(this));
            GoalManager_.addGoal(new GoalInvestigate(this));
            GoalManager_.addGoal(new GoalKill(this));

            PlanManager_.addAction(new ActionTypeInvestigate(npc));
            PlanManager_.addAction(new ActionTypeGoto(npc));
            PlanManager_.addAction(new ActionTypePatrol(npc));
            PlanManager_.addAction(new ActionTypeFlee(npc));
            PlanManager_.addAction(new ActionTypeAggressiveFire(npc));

            sensors_.Add(new SensorEars(this));
            sensors_.Add(new SensorSeeCharacter(this, FIELD_OF_VIEW));
        }
Esempio n. 4
0
        public BossAI(NonPlayableCharacterAbstract npc)
            : base(npc)
        {
            GoalManager_.addGoal(new GoalIdle(this));
            GoalManager_.addGoal(new GoalInvestigate(this));
            GoalManager_.addGoal(new GoalKill(this));
            GoalManager_.addGoal(new GoalKeepDistance(this));

            PlanManager_.addAction(new ActionTypeGoto(npc));
            PlanManager_.addAction(new ActionTypeInvestigate(npc));
            PlanManager_.addAction(new ActionTypeAggressiveFire(npc));
            PlanManager_.addAction(new ActionTypeFlee(npc));

            sensors_.Add(new SensorSeeCharacter(this, FIELD_OF_VIEW));

            systems_.Add(new BossSystemMissiles(this));
        }
Esempio n. 5
0
        public AI(NonPlayableCharacterAbstract npc)
        {
            Character_ = npc;
            ReservationTable.register(npc);

            Memory_ = new Memory();

            GoalManager_ = new GoalManager(this);
            CurrentGoal_ = null;
            PlanManager_ = new PlanManager(this);

            systems_.Add(new SystemTargetSelection(this));
            systems_.Add(new SystemCoverSelection(this));
            systems_.Add(new SystemMemoryCleanup(this));

            CommunicationSystem_ = new SystemCommunication(this, 100);
        }
        /// <summary>
        /// Destroy a resource reservation so another can reserve it.
        /// </summary>
        /// <param name="resource">The resource in question.</param>
        /// <param name="owner">Current owner of the resource.</param>
        internal static void freeResource(Object resource, NonPlayableCharacterAbstract owner)
        {
            if (reservations_.ContainsKey(resource))
            {
                if (owner == null)
                {
                    throw new InvalidOperationException("Consumed resources cannot be freed.");
                }

                if (reservations_[resource] == owner)
                {
                    reservations_.Remove(resource);
                }
                else
                {
                    throw new InvalidOperationException("This NPC does not own this resource");
                }
            }
        }
Esempio n. 7
0
 internal ActionTypeTakeCover(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
        /// <summary>
        /// Attempt to reserve a resource.
        /// </summary>
        /// <param name="resource">The resource in question.</param>
        /// <param name="reserver">Entity attempting to reserve the resource.</param>
        /// <returns>True if the resource was successfully reserved, false otherwise.</returns>
        internal static bool reserveResource(Object resource, NonPlayableCharacterAbstract reserver)
        {
            if (isFree(resource))
            {
                reservations_.Add(resource, reserver);

                BeliefType type = BeliefType.Error;
                if (resource is CoverObject)
                {
                    type = BeliefType.AvailableCover;
                }
                else if (resource is AmmoBox)
                {
                    type = BeliefType.AmmoLoc;
                }

                if (type == BeliefType.Error)
                {
                    throw new NotImplementedException("Reservations for this object type not yet implemented");
                }

                // notify other agents in the world that this resource is taken
                for (int i = 0; i < notifyList_.Count; i++)
                {
                    if (notifyList_[i] != reserver)
                    {
                        notifyList_[i].AI_.Memory_.removeBelief(type, resource);
                    }
                }
                return true;
            }
            return false;
        }
Esempio n. 9
0
 internal TeamActionTypeFlush(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Esempio n. 10
0
        /// <summary>
        /// Used to determine whether a resource is reserved by a particular entity.
        /// </summary>
        /// <param name="resource">The resource in question.</param>
        /// <param name="owner">Possible owner of the reservation.</param>
        /// <returns>Whether 'owner' has a reservation for this resource.</returns>
        internal static bool isReservedBy(Object resource, NonPlayableCharacterAbstract owner)
        {
            if (owner == null)
            {
                // The idea behind this exception is that if it did not exist, characters
                // attempting to check a resource for reservation could glean information that it
                // had in fact been consumed, and remove it from their list of beliefs.

                // On second thought, they'll never try and use it anyway so that wouldn't
                // really help all that much.

                // throw new AccessViolationException("ReservationTable should not be used to determine if a resource has been consumed.");
            }
            return (reservations_.ContainsKey(resource) && reservations_[resource] == owner);
        }
Esempio n. 11
0
 internal static void register(NonPlayableCharacterAbstract npc)
 {
     notifyList_.Add(npc);
 }
Esempio n. 12
0
 public ActionGoto(NonPlayableCharacterAbstract character, TileIndex target)
     : base(character)
 {
     target_ = target;
 }
 internal TeamActionSuppress(NonPlayableCharacterAbstract character, Object handle)
     : base(character)
 {
     handle_ = handle;
 }
 internal ActionAggressiveFire(NonPlayableCharacterAbstract character, Object handle)
     : base(character)
 {
     handle_ = handle;
 }
 internal ActionAttackRanged(NonPlayableCharacterAbstract character, Object handle)
     : base(character)
 {
     handle_ = handle;
 }
Esempio n. 16
0
 internal ActionTypeInvestigate(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Esempio n. 17
0
 internal ActionTypePickupAmmo(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Esempio n. 18
0
 internal ActionTypeFlee(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Esempio n. 19
0
 internal ActionPickupAmmo(NonPlayableCharacterAbstract character, ref TileIndex ammoLocation, Object tempHandle)
     : base(character)
 {
     ammoLocation_ = ammoLocation;
     tempHandle_ = tempHandle;
 }
Esempio n. 20
0
 internal Action(NonPlayableCharacterAbstract character)
 {
     character_ = character;
 }
 internal ActionTypeAggressiveFire(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Esempio n. 22
0
 internal ActionTakeCover(NonPlayableCharacterAbstract character, ref TileIndex coverLocation)
     : base(character)
 {
     coverLocation_ = coverLocation;
 }
 internal ActionTypeThrowGrenade(NonPlayableCharacterAbstract character)
     : base(character)
 {
     throw new NotImplementedException();
 }
 internal TeamActionTypeSuppress(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
 internal ActionTypeAttackRanged(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Esempio n. 26
0
 public ActionTypeGoto(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }