Ejemplo 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));
        }
Ejemplo n.º 2
0
 /// <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");
         }
     }
 }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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);
        }
Ejemplo n.º 6
0
        /// <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");
                }
            }
        }
Ejemplo n.º 7
0
 internal ActionTypeTakeCover(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 8
0
        /// <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;
        }
Ejemplo n.º 9
0
 internal TeamActionTypeFlush(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo 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);
        }
Ejemplo n.º 11
0
 internal static void register(NonPlayableCharacterAbstract npc)
 {
     notifyList_.Add(npc);
 }
Ejemplo n.º 12
0
 public ActionGoto(NonPlayableCharacterAbstract character, TileIndex target)
     : base(character)
 {
     target_ = target;
 }
Ejemplo n.º 13
0
 internal TeamActionSuppress(NonPlayableCharacterAbstract character, Object handle)
     : base(character)
 {
     handle_ = handle;
 }
Ejemplo n.º 14
0
 internal ActionAggressiveFire(NonPlayableCharacterAbstract character, Object handle)
     : base(character)
 {
     handle_ = handle;
 }
Ejemplo n.º 15
0
 internal ActionAttackRanged(NonPlayableCharacterAbstract character, Object handle)
     : base(character)
 {
     handle_ = handle;
 }
Ejemplo n.º 16
0
 internal ActionTypeInvestigate(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 17
0
 internal ActionTypePickupAmmo(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 18
0
 internal ActionTypeFlee(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 19
0
 internal ActionPickupAmmo(NonPlayableCharacterAbstract character, ref TileIndex ammoLocation, Object tempHandle)
     : base(character)
 {
     ammoLocation_ = ammoLocation;
     tempHandle_ = tempHandle;
 }
Ejemplo n.º 20
0
 internal Action(NonPlayableCharacterAbstract character)
 {
     character_ = character;
 }
Ejemplo n.º 21
0
 internal ActionTypeAggressiveFire(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 22
0
 internal ActionTakeCover(NonPlayableCharacterAbstract character, ref TileIndex coverLocation)
     : base(character)
 {
     coverLocation_ = coverLocation;
 }
Ejemplo n.º 23
0
 internal ActionTypeThrowGrenade(NonPlayableCharacterAbstract character)
     : base(character)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 24
0
 internal TeamActionTypeSuppress(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 25
0
 internal ActionTypeAttackRanged(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }
Ejemplo n.º 26
0
 public ActionTypeGoto(NonPlayableCharacterAbstract character)
     : base(character)
 {
 }