Example #1
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (player.Hitbox.Intersects(Hitbox))
       {
     Game1.EventMan.Notify(Events.PlayerHitByPlant, this);
       }
 }
Example #2
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (Target == null)
            Target = player;

              if (Game1.CurrentTime - LastCharge < ChargeCooldown)
            return;

              float distance = player.DrawBox.Center.Distance(DrawBox.Center);

              switch (State)
              {
            case StoneRobotState.Stone:
              break;

            case StoneRobotState.Normal:
              if (distance < ATTACK_RANGE)
            State = StoneRobotState.Chasing;
              break;

            case StoneRobotState.Chasing:
              if (distance < CHARGE_RANGE)
              {
            State = StoneRobotState.Charging;
            LastCharge = Game1.CurrentTime;
              }
              break;

            case StoneRobotState.Charging:
              break;
              }
        }
Example #3
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (TargetPerson == null)
            TargetPerson = player;

              float distance = GetDistance(player);

              if (BehaviourState == BehaviourStates.Aggressive)
              {
            if (distance < RANGE_CHARGE)
            {
              if (ActionState != ActionStates.Charging
            && ActionState != ActionStates.PreCharge)
              {
            StartPreCharge();
              }
            }
            else if (distance < RANGE_FOLLOW)
            {
              if (ActionState != ActionStates.Charging)
            ChasePlayer();
            }
            else if (distance >= RANGE_FOLLOW && !CurrentlyBeingShot)
            {
            GoNeutral();
            }
              }
        }
Example #4
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (State == IcydactylStates.Swooping
            || State == IcydactylStates.Rising
            || State == IcydactylStates.Carrying)
            return;

              if (DistanceXCenter(player) < SWOOP_RANGE)
            Swoop(player);
        }
Example #5
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     if (Game1.CurrentTime - LastShower > ShowerCooldown)
       {
     if (DistanceXCenter(player) < ATTACK_DISTANCE)
     {
       LastShower = Game1.CurrentTime;
       IciclesToAdd = MAX_ICICLES;
     }
       }
 }
Example #6
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     if (State == SnappingPlantState.Normal)
       {
     if (Math.Abs(player.DrawBox.Center.X - DrawBox.Center.X) < SNAPPING_RANGE)
     {
       State = SnappingPlantState.Attacking;
       LastSnap = Game1.CurrentTime;
     }
       }
 }
Example #7
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     if (Game1.CurrentTime - LastHug > CoolDownRate
     && State == YetiStates.Standing)
       {
     if (DistanceXCenter(player) < AGGRO_RANGE)
     {
       State = YetiStates.Chasing;
       Destination = player.Position;
       Player = player;
     }
       }
 }
Example #8
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if ((player.State == Player.PlayerStates.Standing
     || player.State == Player.PlayerStates.Walking
     || player.State == Player.PlayerStates.Shooting)
     && (State == IcydactylStates.Swooping || State == IcydactylStates.Rising))
       {
     if (Hitbox.Intersects(player.Hitbox))
     {
       State = IcydactylStates.Carrying;
       Game1.EventMan.Notify(Events.PlayerPickedUpByIcydactyl, this);
     }
       }
 }
Example #9
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (Target == null)
            Target = player;

              float distance = player.DrawBox.Center.Distance(DrawBox.Center);

              switch (State)
              {
            case RobotSentinelStates.Attacking:
              if (distance > GIVE_UP_ATTACK_RANGE)
            RestoreState();
              break;
              }
        }
Example #10
0
        public override void CollisionCheck(Player player, GameTime gameTime)
        {
            if (Hitbox.Intersects(player.Hitbox))
              {
            // Resolve Collision
            Rectangle overlap = Rectangle.Intersect(Hitbox, player.Hitbox);

            if (Hitbox.Center.X > player.Hitbox.Center.X)
              player.Position.X -= overlap.Width;
            else
              player.Position.X += overlap.Width;
              }

              // Check if player hits shield
              // If they do, knock back with particle explosion, deal damage
        }
Example #11
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (Game1.CurrentTime - LastSwarm > SwarmCooldown)
              {
            float distToPlayer = player.DrawBox.Center.Distance(DrawBox.Center);
            if (distToPlayer < ATTACK_RANGE)
            {
              AttachToPlayer(player);

              if (State == LeechStates.Normal)
            Game1.EventMan.Notify(Events.PlayerSwarmedByLeeches, this);

              State = LeechStates.Attack;
            }
              }
        }
Example #12
0
        public override void CollisionCheck(Player player, GameTime gameTime)
        {
            bool playerHitWithLightning = false;
              Lightning lightningBolt = null;

              foreach (var lightning in LightningObjects)
              {
            if (lightning.Hitbox.Intersects(player.Hitbox))
            {
              // Lightning Hit player
              lightning.Destroy = true;
              playerHitWithLightning = true;
              lightningBolt = lightning;
            }
              }

              if (playerHitWithLightning)
            Game1.EventMan.Notify(Events.PlayerHitWithLightning, lightningBolt);
        }
Example #13
0
        public override void CollisionCheck(Player Player, GameTime gameTime)
        {
            // If hugged recently, return.
              if (Game1.CurrentTime - LastHug < CoolDownRate)
            return;

              // Collision Check
              if (State != YetiStates.Hugging)
              {
            if (Hitbox.Intersects(Player.Hitbox) &&
              (Player.State == Planet4.Player.PlayerStates.Standing
              || Player.State == Planet4.Player.PlayerStates.Walking
              || Player.State == Planet4.Player.PlayerStates.Shooting))
            {
              State = YetiStates.Hugging;
              LastHug = Game1.CurrentTime;
              Velocity = Vector2.Zero;
              Game1.EventMan.Notify(Events.PlayerHugged, this);
            }
              }
        }
Example #14
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            float distanceToPlayer = DistanceXCenter(player);
              Player = player;

              // Normal : Aggro Range : Chase
              // Chase : Punch Range : Chase
              // Chase : Giveup Range : Chase

              bool inAggroRange = distanceToPlayer < AGGRO_RANGE;
              bool inPunchRange = distanceToPlayer < PUNCH_RANGE;
              bool outsideGiveupRange = distanceToPlayer > GIVEUP_RANGE;

              bool canPunch = Game1.CurrentTime - LastPunchHit > PunchCooldown;

              switch (State)
              {
            case RockGuyStates.Normal:
              if (canPunch && inAggroRange)
            State = RockGuyStates.Chasing;

              break;
            case RockGuyStates.Chasing:
              if (canPunch && inPunchRange)
              {
            State = RockGuyStates.Punching;
            LastPunchHit = Game1.CurrentTime;
              }

              if (outsideGiveupRange)
            State = RockGuyStates.Normal;

              break;
            case RockGuyStates.Punching:
              break;
              }
        }
Example #15
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (State == SwarmState.MovingToDestination)
            return;

              // Get aggro
              if (!IsAggro && gameTime.TotalGameTime - LastAttack > AttackCooldown)
              {
            float distSqr = Vector2.DistanceSquared(player.Position, Position);

            if (distSqr < AggroRange * AggroRange)
            {
              IsAggro = true;
              Player = player;
            }
              }

              // If center point is over player
              if (player.Hitbox.Over(Position))
              {
            Game1.EventMan.Notify(Events.PlayerSwarmedBySwarm, this);
            State = SwarmState.Attacking;
              }
        }
Example #16
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     // Do nothing
 }
Example #17
0
 public virtual void CheckRange(Player player, GameTime gameTime)
 {
 }
Example #18
0
 public virtual void CollisionCheck(Player player, GameTime gameTime)
 {
     // Nothing by default
 }
Example #19
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     if (DistanceXCenter(player) < ATTACK_DISTANCE)
     ShootLightning();
 }
Example #20
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     foreach (var item in Icicles)
     item.CollisionCheck(player, gameTime);
 }
Example #21
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
 }
Example #22
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (player.Hitbox.Intersects(Hitbox))
     {
       Destroy = true;
       Game1.EventMan.Notify(Events.PlayerHitWithIcicle, this);
     }
 }
Example #23
0
 void AttachToPlayer(Player player)
 {
     Position = player.DrawBox.Center.ToVector2();
       Position.X -= DrawBox.Width / 2;
 }
Example #24
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (!Destroy)
     {
       if (player.Hitbox.Intersects(Hitbox))
       {
     Game1.EventMan.Notify(Events.PlayerHitByFlamingBoulder, this);
     DeregisterEvents();
       }
     }
 }
Example #25
0
        public Controller()
            : base()
        {
            int currentPlanet = DB.CurrentPlanet;

              Player = new Player(new Vector2(World.WORLD_WIDTH / 2, 100));
              Type = (PlanetTypes)DB.Planets[currentPlanet].PlanetType;
              Camera = new Camera();

              WhaleButton = new UI.Button(Player.Position.X, 100, "Planet/WhaleButton", Events.GoToSystemView);

              if (currentPlanet != 7)
              {
            Generators.Add(new Generator(new Vector2(0, 250)));
            Generators.Add(new Generator(new Vector2(World.WORLD_WIDTH - Generator.WIDTH, 250)));
              }
              else
              {
            AncientMachines.Add(new AncientMachine(new Vector2(0, 250)));
            AncientMachines.Add(new AncientMachine(new Vector2(
              World.WORLD_WIDTH - Generator.WIDTH, 250)));
              }

              if (Generators.Count > 0)
              {
            ActiveObjects.Add(Generators[0]);
            ActiveObjects.Add(Generators[1]);
              }

              foreach (var item in DB.Planets[currentPlanet].Hostiles)
              {
            switch ((HostilesTypes)item.Type)
            {
              case HostilesTypes.Boomba: ActiveObjects.Add(new Boomba(item.Position)); break;
              case HostilesTypes.Buffalo: ActiveObjects.Add(new Buffalo(item.Position)); break;
              case HostilesTypes.Bullfrog: ActiveObjects.Add(new Bullfrog(item.Position)); break;
              case HostilesTypes.CrushingMachine: ActiveObjects.Add(new CrushingMachine(item.Position)); break;
              case HostilesTypes.FireColumn: ActiveObjects.Add(new FireColumn(item.Position)); break;
              case HostilesTypes.FlamingBoulderSpawner: ActiveObjects.Add(new FlamingBoulder(item.Position)); break;
              case HostilesTypes.IceCloud: ActiveObjects.Add(new IceCloud(item.Position)); break;
              case HostilesTypes.IceColumn: ActiveObjects.Add(new IceColumn(item.Position)); break;
              case HostilesTypes.Icydactyl: ActiveObjects.Add(new Icydactyl(item.Position)); break;
              case HostilesTypes.Leech: ActiveObjects.Add(new Leech(item.Position)); break;
              case HostilesTypes.RobotSender: ActiveObjects.Add(new RobotSender(item.Position)); break;
              case HostilesTypes.RobotSentinel: ActiveObjects.Add(new RobotSentinel(item.Position)); break;
              case HostilesTypes.Rockguy: ActiveObjects.Add(new Rockguy(item.Position)); break;
              case HostilesTypes.SnappingPlant: ActiveObjects.Add(new SnappingPlant(item.Position)); break;
              case HostilesTypes.SpikeWall: ActiveObjects.Add(new SpikeWall(item.Position)); break;
              case HostilesTypes.StoneRobot: ActiveObjects.Add(new StoneRobot(item.Position)); break;
              case HostilesTypes.StormCloud: ActiveObjects.Add(new StormCloud(item.Position)); break;
              case HostilesTypes.Swarm: ActiveObjects.Add(new Swarm(item.Position)); break;
              case HostilesTypes.Yeti: ActiveObjects.Add(new Yeti(item.Position)); break;
            }
              }

              foreach (var item in DB.Planets[currentPlanet].Foods)
            Foods.Add(new Food(item.Position));

              foreach (var item in DB.Planets[currentPlanet].Cubes)
            Cubes.Add(new Cube(item.Position));

              foreach (var item in DB.Planets[currentPlanet].Critters)
            Critters.Add(new Critter(item.Position, item.Type));

              foreach (var item in DB.Planets[currentPlanet].Peoples)
            Persons.Add(new Person((CharacterTypes)item.Type, item.Position));

              Game1.EventMan.Register(Events.MouseMove, MouseMove);
              Game1.EventMan.Register(Events.MouseClick, MouseClick);
              Game1.EventMan.Register(Events.GoToSystemView, GoToSystemView);
              Game1.EventMan.Register(Events.PlayerHitByFeedback, PlayerHitByFeedback);
              Game1.EventMan.Register(Events.TeleportedFood, TeleportedFood);
              Game1.EventMan.Register(Events.PersonTeleported, PersonTeleported);

              WhaleButton.DeregisterEvents();

              switch (Type)
              {
            case PlanetTypes.Green:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Jungle:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Ice:
              Audio.Play(Music.Ice);
              break;
            case PlanetTypes.Desert:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Volcano:
              Audio.Play(Music.Volcano);
              break;
            case PlanetTypes.Machine:
              Audio.Play(Music.Machine);
              break;
              }
        }
Example #26
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (State == StoneRobotState.Charging && player.Hitbox.Intersects(Hitbox))
       {
     Game1.EventMan.Notify(Events.KnockedBack, new ActiveObject[]{ this, player });
     State = StoneRobotState.Normal;
     Velocity.X = 0;
       }
 }
Example #27
0
            public override void CollisionCheck(Player player, GameTime gameTime)
            {
                if (player.Hitbox.Intersects(Hitbox))
                {
                  Game1.EventMan.Notify(Events.PlayerSpottedByScanner, null);

                  DeregisterEvents();
                }
            }
Example #28
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (Scanner != null)
     Scanner.CollisionCheck(player, gameTime);
 }
Example #29
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (State == FireColumnState.Raised)
     if (player.Hitbox.Intersects(Hitbox))
       Game1.EventMan.Notify(Events.PlayerHitFireColumn, this);
 }
Example #30
0
 void Swoop(Player player)
 {
     if (player.State == Player.PlayerStates.Standing
     || player.State == Player.PlayerStates.Walking
     || player.State == Player.PlayerStates.Shooting)
       {
     SwoopTarget = player.DrawBox.Center.ToVector2();
     State = IcydactylStates.Swooping;
       }
 }