Ejemplo n.º 1
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (player.Hitbox.Intersects(Hitbox))
       {
     Game1.EventMan.Notify(Events.PlayerHitByPlant, this);
       }
 }
Ejemplo n.º 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;
              }
        }
Ejemplo n.º 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();
            }
              }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
     }
       }
 }
Ejemplo n.º 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;
     }
       }
 }
Ejemplo n.º 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;
     }
       }
 }
Ejemplo n.º 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);
     }
       }
 }
Ejemplo n.º 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;
              }
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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;
            }
              }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
              }
        }
Ejemplo n.º 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;
              }
        }
Ejemplo n.º 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;
              }
        }
Ejemplo n.º 16
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     // Do nothing
 }
Ejemplo n.º 17
0
 public virtual void CheckRange(Player player, GameTime gameTime)
 {
 }
Ejemplo n.º 18
0
 public virtual void CollisionCheck(Player player, GameTime gameTime)
 {
     // Nothing by default
 }
Ejemplo n.º 19
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
     if (DistanceXCenter(player) < ATTACK_DISTANCE)
     ShootLightning();
 }
Ejemplo n.º 20
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     foreach (var item in Icicles)
     item.CollisionCheck(player, gameTime);
 }
Ejemplo n.º 21
0
 public override void CheckRange(Player player, GameTime gameTime)
 {
 }
Ejemplo n.º 22
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (player.Hitbox.Intersects(Hitbox))
     {
       Destroy = true;
       Game1.EventMan.Notify(Events.PlayerHitWithIcicle, this);
     }
 }
Ejemplo n.º 23
0
 void AttachToPlayer(Player player)
 {
     Position = player.DrawBox.Center.ToVector2();
       Position.X -= DrawBox.Width / 2;
 }
Ejemplo n.º 24
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (!Destroy)
     {
       if (player.Hitbox.Intersects(Hitbox))
       {
     Game1.EventMan.Notify(Events.PlayerHitByFlamingBoulder, this);
     DeregisterEvents();
       }
     }
 }
Ejemplo n.º 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;
              }
        }
Ejemplo n.º 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;
       }
 }
Ejemplo n.º 27
0
            public override void CollisionCheck(Player player, GameTime gameTime)
            {
                if (player.Hitbox.Intersects(Hitbox))
                {
                  Game1.EventMan.Notify(Events.PlayerSpottedByScanner, null);

                  DeregisterEvents();
                }
            }
Ejemplo n.º 28
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (Scanner != null)
     Scanner.CollisionCheck(player, gameTime);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
       }
 }