diff --git a/Shared/LinesOfSight.cs b/Shared/LinesOfSight.cs index 3589b53..9832444 100644 --- a/Shared/LinesOfSight.cs +++ b/Shared/LinesOfSight.cs @@ -29,12 +29,12 @@ namespace SemiColinGames { float fov = FMath.DegToRad(120); float fovStep = fov / (numEdgeVertices - 1); - Vector2 ray = new Vector2(visionRange * player.GetFacing, 0); + Vector2 ray = new Vector2(visionRange * player.Facing, 0); if (player.GetPose == Player.Pose.Stretching) { - ray = ray.Rotate(player.GetFacing * FMath.DegToRad(-30)); + ray = ray.Rotate(player.Facing * FMath.DegToRad(-30)); } if (player.GetPose == Player.Pose.Crouching) { - ray = ray.Rotate(player.GetFacing * FMath.DegToRad(30)); + ray = ray.Rotate(player.Facing * FMath.DegToRad(30)); } coneVertices[0] = new VertexPositionColor(new Vector3(player.EyePosition, 0), color); diff --git a/Shared/Player.cs b/Shared/Player.cs index 5636a79..1f2fc6b 100644 --- a/Shared/Player.cs +++ b/Shared/Player.cs @@ -5,12 +5,6 @@ using System.Collections.Generic; namespace SemiColinGames { class Player { - // The player's Facing corresponds to the x-direction that they're looking. - enum Facing { - Left = -1, - Right = 1 - }; - public enum Pose { Walking, Standing, Crouching, Stretching, SwordSwing, Jumping }; private const int moveSpeed = 180; @@ -35,7 +29,6 @@ namespace SemiColinGames { private Vector2 eyeOffsetWalking = new Vector2(15, -7); private int jumps = 0; - private Facing facing = Facing.Right; private Pose pose = Pose.Jumping; private double swordSwingTime = 0; private int swordSwingNum = 0; @@ -46,10 +39,7 @@ namespace SemiColinGames { this.texture = texture; } - // TODO: just make Facing an int. - public int GetFacing { - get { return (int) facing; } - } + public int Facing { get; private set; } = 1; public Pose GetPose { get { return pose; } @@ -139,9 +129,9 @@ namespace SemiColinGames { } if (movement.X > 0) { - facing = Facing.Right; + Facing = 1; } else if (movement.X < 0) { - facing = Facing.Left; + Facing = -1; } if (swordSwingTime > 0) { pose = Pose.SwordSwing; @@ -163,7 +153,7 @@ namespace SemiColinGames { bool walking = pose == Pose.Walking || pose == Pose.Jumping; Vector2 eyeOffset = walking ? eyeOffsetWalking : eyeOffsetStanding; return Vector2.Add( - Position.ToVector2(), new Vector2(eyeOffset.X * (int) facing, eyeOffset.Y)); + Position.ToVector2(), new Vector2(eyeOffset.X * Facing, eyeOffset.Y)); } } @@ -220,7 +210,7 @@ namespace SemiColinGames { int index = SpriteIndex(pose); Rectangle textureSource = new Rectangle(index * spriteWidth, 0, spriteWidth, spriteHeight); Vector2 spriteCenter = new Vector2(spriteWidth / 2, spriteHeight / 2 + spriteCenterYOffset); - SpriteEffects effect = facing == Facing.Right ? + SpriteEffects effect = Facing == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; spriteBatch.Draw(texture, position.ToVector2(), textureSource, Color.White, 0f, spriteCenter, Vector2.One, effect, 0f);