Exemple #1
0
        public override bool Update(float elapsedTime, ArrayList collisionList)
        {
            float decision = ai.Next(0, 1000);

            if (decision > 925 + interest)
            {
                Wander();
            }
            else if (Position != goal)
            {
                Vector2 dir    = ((goal - Position) / (goal - Position).Length());
                float   dist   = Math.Min(maxSpeed, (goal - Position).Length() * speed);
                Vector2 travel = dir * dist;
                int     choose = GetAnimationDirection(dir);
                AnimationPlay.PlayAnimation(Animations[choose]);
                if (dist > elapsedTime)
                {
                    if (checkMove(collisionList, Position + travel * elapsedTime))
                    {
                        Position += (travel * elapsedTime);
                    }
                }
                else
                {
                    if (checkMove(collisionList, goal))
                    {
                        Position = goal;
                    }
                }
            }

            if (ai.Next(0, 10) > 5)
            {
                interest--;
            }

            return(base.Update(elapsedTime, collisionList));
        }
Exemple #2
0
        public override bool Update(float elapsedTime, ArrayList collisionList)
        {
            if (input.IsKeyPressed(Keys.Z))
            {
                isWolf = !isWolf;
            }
            if (input.IsKeyPressed(Keys.X))
            {
                SpawnMine();
            }

            Vector2 movement = input.CheckLStick(0);

            if (input.IsKeyDown(Keys.Up))
            {
                movement.X -= speed * elapsedTime;
                movement.Y -= speed * elapsedTime;
            }
            if (input.IsKeyDown(Keys.Down))
            {
                movement.X += speed * elapsedTime;
                movement.Y += speed * elapsedTime;
            }
            if (input.IsKeyDown(Keys.Left))
            {
                movement.X -= speed * elapsedTime;
                movement.Y += speed * elapsedTime;
            }
            if (input.IsKeyDown(Keys.Right))
            {
                movement.X += speed * elapsedTime;
                movement.Y -= speed * elapsedTime;
            }

            int choose = direction;

            if (isWolf)
            {
                choose += 8;
            }

            AnimationPlay.PlayAnimation(Animations[choose]);

            AnimationPlay.Paused = true;

            if (movement != Vector2.Zero)
            {
                AnimationPlay.Paused = false;
                direction            = GetAnimationDirection(movement);
                if (checkMove(collisionList, Position + movement))
                {
                    Position += movement;
                    movement.Normalize();
                }
                Error.Trace(Position.ToString());
            }

            //HACK

            /*
             *      if (parent.m_ParentApp.Inputs.IsKeyPressed(Keys.H))
             *      {
             *              List<Animation> animList = new List<Animation>();
             *              for (int j = 0; j < 8; j++)
             *              {
             *                      Animation anim = new Animation(parent.textureList[18], 1, true, new Vector2(35, 35), j);
             *                      animList.Add(anim);
             *              }
             *              Vector2 tempVec = new Vector2(Position.X,Position.Y);
             *              Sheep tempSheep = new Sheep(tempVec, animList, parent.textureList[18]);
             *              //((ArrayList)parent.AllObjects[(int)Level.RenderLevel.RL_OBJECTS]).Add(tempSheep);
             *              parent.Spawn(Level.RenderLevel.RL_OBJECTS, tempSheep);
             *              Clutter tempShadow = new Clutter(tempSheep.Position, parent.textureList[21]);
             *              tempShadow.AddShadow(ref tempSheep, parent.textureList[21]);
             *              //((ArrayList)parent.AllObjects[(int)Level.RenderLevel.RL_SHADOWS]).Add(tempShadow);
             *              parent.Spawn(Level.RenderLevel.RL_SHADOWS, tempShadow);
             *              tempSheep.parent = parent;
             *              tempShadow.parent = parent;
             *              //tempSheep.AddShadow(textureList[21]);
             *
             *      }
             */
            //return base.Update(elapsedTime, collisionList);
            return(true);
        }
Exemple #3
0
 public Explosion(Vector2 Location, List <Animation> animationList, Texture2D tex)
     : base(Location, animationList, tex)
 {
     AnimationPlay.PlayAnimation(Animations[0]);
 }