Example #1
0
        public Enemy(Vector2 position)
            : base(position)
        {
            IsAlive = true;
            followBear = null;
            Scale = 1;
            mScale = new Vector2(Scale, Scale);
            CurrentState = State.Aimless;

            mFollowPlayerAI = new FollowPlayerAI(this, followBear);
            mAfraidAI = new AfraidAI(this);
            mPlantingAI = new PlantingAI(this);
            mEvilAI = new EvilAI(this);

            SeedPouch pouch = new SeedPouch(1);
            mGetSeedAI = new GetSeedAI(this, pouch);
            mPlantSeedAI = new PlantSeedAI(this, pouch);
            bCurrGetSeed = true;

            mCommands = new List<AIComponent>();
            mNumCommands = 0;
            mNextCommandIndex = 0;
            mCurrCommand = null;

            AddCommand(mGetSeedAI);
            AddCommand(mPlantSeedAI);

            Pouch = new SeedPouch(2);
            bListening = false;
        }
Example #2
0
        private void doCommands(GameTime gameTime)
        {
            if (mNumCommands <= 0)
            {
                changeState(State.Aimless);
                return;
            }

            if (mCurrCommand == null || mCurrCommand.CurrentState == AIComponent.State.Done)
            {
                if (mNextCommandIndex >= mNumCommands)
                {
                    mNextCommandIndex = 0;
                }
                mCurrCommand = mCommands[mNextCommandIndex];
                mNextCommandIndex++;
            }

            mCurrCommand.DoAI(gameTime);

            if (mCurrCommand.CurrentState == AIComponent.State.Problem)
            {
                changeState(State.Aimless);
            }

            checkStuck(gameTime);
            dealWithCollisions();
        }
Example #3
0
 public void ClearCommands()
 {
     mCommands.Clear();
     mNumCommands = 0;
     mNextCommandIndex = 0;
     mCurrCommand = null;
 }
Example #4
0
 //public void AddCommand(String command)
 public void AddCommand(AIComponent command)
 {
     if (bListening)
     {
         mCommands.Add(command);
         mNumCommands++;
     }
 }