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); } } }
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; } }
void UnSwoop() { if (State == IcydactylStates.Swooping) State = IcydactylStates.Rising; }
public override void Update(GameTime gameTime) { float timeDelta = (float)gameTime.ElapsedGameTime.TotalSeconds; Vector2 center = DrawBox.Center.ToVector2(); // Bounce off ground if (center.Y > World.GroundLevel - HEIGHT_OFF_GROUND_GIVE_UP_OFFSET) UnSwoop(); // Rise if ((State == IcydactylStates.Rising || State == IcydactylStates.Carrying) && center.Y > CRUISING_ALTITUDE) Velocity.Y = -100; // Cruise if ((State == IcydactylStates.Rising || State == IcydactylStates.Carrying) && center.Y <= CRUISING_ALTITUDE) { if (State == IcydactylStates.Carrying) Game1.EventMan.Notify(Events.PlayerReleasedByIcydactyl, null); State = IcydactylStates.Flying; } if (State == IcydactylStates.Flying) Velocity.Y = 0; // Change Direction, If player is largely out of bounds, fly into bounds direction if (State == IcydactylStates.Flying) { if (center.X <= LeftMoveBounds) Velocity.X = Math.Abs(Velocity.X); if (center.X >= RightMoveBounds) Velocity.X = -Math.Abs(Velocity.X); } if (State == IcydactylStates.Swooping) { float angle = (float)Math.Atan2(SwoopTarget.Y - DrawBox.Center.Y, SwoopTarget.X - DrawBox.Center.X); Velocity.X = (float)Math.Cos(angle) * SPEED * 2; Velocity.Y = (float)Math.Sin(angle) * SPEED * 2; } UpdateMovement(gameTime); }