/// <summary> /// A player character. It can be either Sigma or Delta. /// </summary> /// <param name="id">0 = Sigma, 1 = Delta</param> /// <param name="loc">The location on the screen that the player should be created at.</param> /// <param name="wep">The currently equipped weapon the player should have.</param> public Player(byte id, Point loc, Weapon wep) { Id = id; switch (Id) { case 0: // If Sigma Animations = SigmaAnimations; Console.WriteLine("Sigma Registered"); break; case 1: // If Delta Animations = DeltaAnimations; Console.WriteLine("Delta Registered"); break; } CurrentAnimation = Animations[(int) Animation.Old_Off]; Loc = new Point(loc.X, loc.Y); Weapon = wep; Weapon.Owner = this; }
/// <summary> /// Move this player in the specified direction. /// </summary> /// <param name="dir">The direction to move in.</param> public void Move(Main.Direction dir) { switch (dir) { case Main.Direction.Left: // Set direction to left. Dir = dir; if (IsGrounded) // Move left. Loc.X -= (GroundSpeed); else // Move left. Loc.X -= (AirSpeed); // Play walking animation. CurrentAnimation = Animations[(int) Animation.Old_Walk]; // Play walking animation. Weapon.CurrentAnimation = Weapon.Animations[(int) Weapon.Type]; break; case Main.Direction.Right: // set direction to right Dir = dir; if (IsGrounded) // Move right. Loc.X += (GroundSpeed); else // Move right. Loc.X += (AirSpeed); // Play walking animation. CurrentAnimation = Animations[(int) Animation.Old_Walk]; // Play walking animation. Weapon.CurrentAnimation = Weapon.Animations[(int) Weapon.Type]; break; // We can't move a player up or down so we just ignore these. case Main.Direction.Up: break; case Main.Direction.Down: break; default: throw new ArgumentOutOfRangeException(nameof(dir), dir, "An invalid direction was given to a player."); } }