public void RotateAim(Aim aim, Player.Side side) { float rightThumbstickY = currentGamePadState.ThumbSticks.Right.Y; float rightThumbstickX = currentGamePadState.ThumbSticks.Right.X; if ((rightThumbstickX != 0 || rightThumbstickY != 0)) { float thumbstickAngle = 0; float thumbstickAngleAngleInDegrees = 0; thumbstickAngle = (float)Math.Atan2(rightThumbstickY, rightThumbstickX); thumbstickAngleAngleInDegrees = (float)aim.RadianToDegree(thumbstickAngle); if (side == Player.Side.Left) { if (thumbstickAngleAngleInDegrees >= 0) { thumbstickAngleAngleInDegrees = 90 - (thumbstickAngleAngleInDegrees - 90); } else { thumbstickAngleAngleInDegrees = -90 + ((thumbstickAngleAngleInDegrees + 90) * -1); } } aim.Rotate(thumbstickAngleAngleInDegrees); } aim.angle = aim.DegreeToRadian(aim.angleInDegrees); }
public Happy(Animation animation, Animation deadAnimation, Aim aim, Texture2D measureBar, string id, int maxHp, int maxSp, float spRegen, float move, float maximumFallingSpeed, Vector2 distanceToHand, Side side, Inputs inputs) : base(animation, deadAnimation, aim, measureBar, id, maxHp, maxSp, spRegen, move, maximumFallingSpeed, distanceToHand, side, inputs) { happyActions = HappyActions.None; }
public void SetDefaultAim(Aim aim) { float leftThumbstickY = currentGamePadState.ThumbSticks.Left.Y; float leftThumbstickX = currentGamePadState.ThumbSticks.Left.X; if ((leftThumbstickX != 0 || leftThumbstickY != 0)) { float thumbstickAngle = 0; float thumbstickAngleAngleInDegrees = 0; thumbstickAngle = (float)Math.Atan2(leftThumbstickY, leftThumbstickX); thumbstickAngleAngleInDegrees = (float)aim.RadianToDegree(thumbstickAngle); if (thumbstickAngleAngleInDegrees > 22.5 && thumbstickAngleAngleInDegrees <= 67.5) { aim.angleInDegrees = 45; } else if (thumbstickAngleAngleInDegrees > 67.5 && thumbstickAngleAngleInDegrees <= 112.5) { aim.angleInDegrees = 90; } else if (thumbstickAngleAngleInDegrees > 112.5 && thumbstickAngleAngleInDegrees <= 157.5) { aim.angleInDegrees = 45; } else if ((thumbstickAngleAngleInDegrees > 157.5 && thumbstickAngleAngleInDegrees <= 180) || (thumbstickAngleAngleInDegrees >= -180 && thumbstickAngleAngleInDegrees <= -157.5)) { aim.angleInDegrees = 0; } else if (thumbstickAngleAngleInDegrees > -157.5 && thumbstickAngleAngleInDegrees <= -112.5) { aim.angleInDegrees = -45; } else if (thumbstickAngleAngleInDegrees > -112.5 && thumbstickAngleAngleInDegrees <= -67.5) { aim.angleInDegrees = -90; } else if (thumbstickAngleAngleInDegrees > -67.5 && thumbstickAngleAngleInDegrees <= -22.5) { aim.angleInDegrees = -45; } else if ((thumbstickAngleAngleInDegrees > -22.5 && thumbstickAngleAngleInDegrees <= 0) || (thumbstickAngleAngleInDegrees >= 0 && thumbstickAngleAngleInDegrees <= 22.5)) { aim.angleInDegrees = 0; } } else { aim.angleInDegrees = 0; } }
public void RotateAim(Aim aim, Player.Side side) { if (currentKeyboardState.IsKeyDown(upKey)) { aim.Rotate((int)1); } else if (currentKeyboardState.IsKeyDown(downKey)) { aim.Rotate((int)-1); } aim.angle = aim.DegreeToRadian(aim.angleInDegrees); }
public Goat(Animation animation, Animation deadAnimation, Aim aim, Texture2D measureBar, string id, int maxHp, int maxSp, float spRegen, float move, float maximumFallingSpeed, Vector2 distanceToHand, Side side, Inputs inputs, Texture2D disconnectionTexture, Love love, RoutesConfiguration routesConfiguration) : base(animation, deadAnimation, aim, measureBar, id, maxHp, maxSp, spRegen, move, maximumFallingSpeed, distanceToHand, side, inputs) { this.disconnectionTexture = disconnectionTexture; this.love = love; this.routesConfiguration = routesConfiguration; disconnections = new List <Projectile>(); goatActions = GoatActions.None; disconnectionManaCost = 25; configuringRoutes = false; }
public Dove(Animation animation, Animation deadAnimation, Aim aim, Texture2D measureBar, string id, int maxHp, int maxSp, float spRegen, float move, float maximumFallingSpeed, Vector2 distanceToHand, Side side, Inputs inputs, Animation sandwich, Texture2D pooTexture, int maxNumberOfPoos, Animation stinkAnimation, Projectile fork) : base(animation, deadAnimation, aim, measureBar, id, maxHp, maxSp, spRegen, move, maximumFallingSpeed, distanceToHand, side, inputs) { doveActions = DoveActions.None; this.sandwich = sandwich; poos = new List <Poo>(); this.fork = fork; ResetFork(); this.pooTexture = pooTexture; maxSkillValue = maxNumberOfPoos; this.stinkAnimation = stinkAnimation; }
public void RotateAim(Aim aim, Player.Side side) { if (currentMouseState.Position != previousMouseState.Position) { if (currentMouseState.Position.Y < aim.mouseAimArea.Y - (aim.mouseAimArea.Height / 2)) { aim.Rotate((int)1); } else if (currentMouseState.Position.Y > aim.mouseAimArea.Y - (aim.mouseAimArea.Height / 2)) { aim.Rotate((int)-1); } } aim.angle = aim.DegreeToRadian(aim.angleInDegrees); }
public Dwarf(Animation animation, Animation deadAnimation, Aim aim, Texture2D measureBar, string id, int maxHp, int maxSp, float spRegen, float move, float maximumFallingSpeed, Vector2 distanceToHand, Side side, Inputs inputs, FireSpitting fireSpitting, Texture2D spinningBoozeTexture) : base(animation, deadAnimation, aim, measureBar, id, maxHp, maxSp, spRegen, move, maximumFallingSpeed, distanceToHand, side, inputs) { dwarfActions = DwarfActions.None; maxSkillValue = fireSpitting.maximumAmount; alcoholOnMouth = false; drinking = false; this.fireSpitting = fireSpitting; this.spinningBoozeTexture = spinningBoozeTexture; smokingSpRegen = 25f; spRegenered = 0; boozes = new List <Projectile>(); }
public Skinny(Animation animation, Animation deadAnimation, Aim aim, Texture2D measureBar, string id, int maxHp, int maxSp, float spRegen, float move, float maximumFallingSpeed, Vector2 distanceToHand, Side side, Inputs inputs, Animation spaceshipAnimation, Texture2D spaceshipShootTexture, Texture2D crazyRayTexture, Teleport teleport, float spaceshipManaDecrement) : base(animation, deadAnimation, aim, measureBar, id, maxHp, maxSp, spRegen, move, maximumFallingSpeed, distanceToHand, side, inputs) { skinnyActions = SkinnyActions.None; this.spaceshipAnimation = spaceshipAnimation; this.spaceshipShootTexture = spaceshipShootTexture; this.crazyRayTexture = crazyRayTexture; this.teleport = teleport; this.spaceshipManaDecrement = spaceshipManaDecrement; spaceshipShoots = new List <SpaceshipShoot>(); crazyRays = new List <Projectile>(); }
public void SetDefaultAim(Aim aim) { if (currentKeyboardState.IsKeyDown(Keys.I) && currentKeyboardState.IsKeyDown(Keys.L)) { aim.angleInDegrees = 45; } else if (currentKeyboardState.IsKeyDown(Keys.K) && currentKeyboardState.IsKeyDown(Keys.L)) { aim.angleInDegrees = -45; } if (currentKeyboardState.IsKeyDown(Keys.I) && currentKeyboardState.IsKeyDown(Keys.J)) { aim.angleInDegrees = 45; } else if (currentKeyboardState.IsKeyDown(Keys.K) && currentKeyboardState.IsKeyDown(Keys.J)) { aim.angleInDegrees = -45; } else if (currentKeyboardState.IsKeyDown(Keys.L)) { aim.angleInDegrees = 0; } else if (currentKeyboardState.IsKeyDown(Keys.I)) { aim.angleInDegrees = 90; } else if (currentKeyboardState.IsKeyDown(Keys.J)) { aim.angleInDegrees = 0; } else if (currentKeyboardState.IsKeyDown(Keys.K)) { aim.angleInDegrees = -90; } else { aim.angleInDegrees = 0; } }
public void SetDefaultAim(Aim aim) { if (currentKeyboardState.IsKeyDown(upKey) && currentKeyboardState.IsKeyDown(rightKey)) { aim.angleInDegrees = 45; } else if (currentKeyboardState.IsKeyDown(downKey) && currentKeyboardState.IsKeyDown(rightKey)) { aim.angleInDegrees = -45; } if (currentKeyboardState.IsKeyDown(upKey) && currentKeyboardState.IsKeyDown(leftKey)) { aim.angleInDegrees = 45; } else if (currentKeyboardState.IsKeyDown(downKey) && currentKeyboardState.IsKeyDown(leftKey)) { aim.angleInDegrees = -45; } else if (currentKeyboardState.IsKeyDown(rightKey)) { aim.angleInDegrees = 0; } else if (currentKeyboardState.IsKeyDown(upKey)) { aim.angleInDegrees = 90; } else if (currentKeyboardState.IsKeyDown(leftKey)) { aim.angleInDegrees = 0; } else if (currentKeyboardState.IsKeyDown(downKey)) { aim.angleInDegrees = -90; } else { aim.angleInDegrees = 0; } }
public Player LoadPlayer(ContentManager content, int width, int height, int deadWidth, int deadHeight) { if (side == Player.Side.Left) { position.X -= width; } Player player; Animation playerAnimation = new Animation(); Texture2D playerTexture = content.Load <Texture2D>("Graphics\\" + characterName.ToLower()); // Frame dimensions: 39x - 45y playerAnimation.Initialize(playerTexture, position, width, height, 0, 0, 100, Color.White, 1f, true); Animation deadAnimation = new Animation(); Texture2D deadTexture = content.Load <Texture2D>("Graphics\\" + characterName.ToLower() + "_flying"); deadAnimation.Initialize(deadTexture, position, deadWidth, deadHeight, 0, 3, 100, Color.White, 1f, false); Texture2D measureBar = content.Load <Texture2D>("Graphics\\measure_bar"); Texture2D aimTexture = content.Load <Texture2D>("Graphics\\aim"); Aim aim = new Aim(aimTexture, 30, 9, 50); Texture2D appearanceSmokeTexture = content.Load <Texture2D>("Graphics\\appearance_smoking"); switch (characterName.ToLower()) { case "dwarf": Animation boozeAnimation = new Animation(); Texture2D boozeTexture = content.Load <Texture2D>("Graphics\\booze"); boozeAnimation.Initialize(boozeTexture, position, 9, 9, 0, 4, 100, Color.White, 1f, true); Animation lighterAnimation = new Animation(); Texture2D lighterTexture = content.Load <Texture2D>("Graphics\\lighter"); lighterAnimation.Initialize(lighterTexture, position, 4, 7, 0, 4, 100, Color.White, 1f, true); Animation fireSpitAnimation = new Animation(); Texture2D fireSpitTexture = content.Load <Texture2D>("Graphics\\lighter_on_fire"); fireSpitAnimation.Initialize(fireSpitTexture, position, 46, 32, 0, 4, 100, Color.White, 1f, true); FireSpitting fireSpitting = new FireSpitting(boozeAnimation, lighterAnimation, fireSpitAnimation, 2f, 100, 2f); Texture2D boozeSpinTexture = content.Load <Texture2D>("Graphics\\spinning_booze"); //SpinningBooze boozeSpinning = new SpinningBooze(boozeSpinAnimation, 0.3f, 25, 5); player = new Dwarf(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0, 4, 5, new Vector2(6, 33), side, input, fireSpitting, boozeSpinTexture); break; case "dove": Animation sandwichAnimation = new Animation(); Texture2D sandwichTexture = content.Load <Texture2D>("Graphics\\sandwich"); sandwichAnimation.Initialize(sandwichTexture, position, 9, 9, 0, 5, 400, Color.White, 1f, true); Animation stinkAnimation = new Animation(); Texture2D stinkTexture = content.Load <Texture2D>("Graphics\\stink"); stinkAnimation.Initialize(stinkTexture, position, 45, 45, 0, 6, 100, Color.White, 1f, true); Texture2D pooTexture = content.Load <Texture2D>("Graphics\\poo"); Texture2D forkTexture = content.Load <Texture2D>("Graphics\\fork"); Animation forkAnimation = new Animation(); forkAnimation.Initialize(forkTexture, new Vector2(0, 0), 18, 18, 0, 7, 50, Color.White, 1f, true); Projectile fork = new Projectile(forkAnimation, 0, 30, 10); player = new Dove(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.5f, 5, 5, new Vector2(3, 39), side, input, sandwichAnimation, pooTexture, 4, stinkAnimation, fork); break; case "skinny": Animation spaceshipAnimation = new Animation(); Texture2D spaceshipTexture = content.Load <Texture2D>("Graphics\\spaceship"); spaceshipAnimation.Initialize(spaceshipTexture, position, 57, 30, 0, 4, 50, Color.White, 1f, true); Texture2D spaceshoot = content.Load <Texture2D>("Graphics\\spaceshoot"); Texture2D crazyRay = content.Load <Texture2D>("Graphics\\crazy_ray"); Animation disappearanceAnimation = new Animation(); Texture2D disappearanceTexture = content.Load <Texture2D>("Graphics\\skinny_teleport"); disappearanceAnimation.Initialize(disappearanceTexture, position, width, height, 0, 6, 50, Color.White, 1f, true); Animation appearanceSmokeAnimation = new Animation(); appearanceSmokeAnimation.Initialize(appearanceSmokeTexture, position, 57, 57, 0, 8, 40, Color.White, 1f, true); Teleport tp = new Teleport(disappearanceAnimation, appearanceSmokeAnimation, 100f); player = new Skinny(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.2f, 5, 5, new Vector2(6, 30), side, input, spaceshipAnimation, spaceshoot, crazyRay, tp, 0.7f); break; case "goat": Animation disillusionRaysAnimation = new Animation(); Texture2D disillusionRaysTexture = content.Load <Texture2D>("Graphics\\appearance_ray"); disillusionRaysAnimation.Initialize(disillusionRaysTexture, position, 33, 48, 0, 3, 50, Color.White, 1f, true); Texture2D heart = content.Load <Texture2D>("Graphics\\heart"); Texture2D disconnected = content.Load <Texture2D>("Graphics\\disconnected"); Love luv = new Love(heart, disillusionRaysAnimation); RoutesConfiguration routesConfig = new RoutesConfiguration(appearanceSmokeTexture); player = new Goat(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.15f, 5, 5, new Vector2(6, 30), side, input, disconnected, luv, routesConfig); break; default: player = null; break; } return(player); }
public Player(Animation animation, Animation deadAnimation, Aim aim, Texture2D measureBar, string id, int maxHp, int maxSp, float spRegen, float move, float maximumFallingSpeed, Vector2 distanceToHand, Side side, Inputs inputs) { playerAnimation = animation; defaultAnimation = animation; this.deadAnimation = deadAnimation; changeAnimation = false; this.side = side; startingSide = side; this.aim = aim; aiming = false; this.distanceToHand = distanceToHand; this.inputs = inputs; //playerName = font; this.id = id; // Set the starting position of the player around the middle of the screen and to the back //this.position = position; //positionX = (int)position.X; //positionY = (int)position.Y; inicialPosition = playerAnimation.position; // Set the player to be active //active = true; playerIsDead = false; stopUpdating = false; deadPlayerOnGround = false; // Set the player movemente speed movement = move; initialMovement = movement; this.maxHp = maxHp; this.maxSp = maxSp; this.hp = maxSp; this.sp = maxSp; this.spRegen = spRegen; defaultSpRegen = spRegen; //spRegen = 0.5f; skillValue = 0; onGround = null; this.maximumFallingSpeed = maximumFallingSpeed; force = 0; jumpForce = 8f; gravity = 0.3f; AdjustCollisionRectangles(); this.measureBar = measureBar; measureBarSourceRectangle = new Rectangle(0, 0, (measureBar.Width / 2), measureBar.Height); measure_spRectangle = new Rectangle((int)positionX, (int)positionY - measureBar.Height - 3, width, measureBar.Height); spRectangle = new Rectangle((int)positionX, (int)positionY - measureBar.Height - 3, (int)GetValueFromPercentage(width, GetPercentage(maxSp, sp)), measureBar.Height); measure_hpRectangle = new Rectangle((int)positionX, spRectangle.Y - measureBar.Height, width, measureBar.Height); hpRectangle = new Rectangle((int)positionX, spRectangle.Y - measureBar.Height, (int)GetValueFromPercentage(width, GetPercentage(maxHp, hp)), measureBar.Height); measure_skillRectangle = new Rectangle((int)positionX, hpRectangle.Y - measureBar.Height - 3, width, measureBar.Height); skillRectangle = new Rectangle((int)positionX, hpRectangle.Y - measureBar.Height, (int)GetValueFromPercentage(width, GetPercentage(maxSkillValue, skillValue)), measureBar.Height); hp_spSourceRectangle = new Rectangle(measureBar.Width / 2, 0, (measureBar.Width / 2), measureBar.Height); skillMeasureBarVisible = false; action = PlayerAction.Idle; }