public void Advance(Position position__1, SpriteEffects flip) { if (flip == SpriteEffects.FlipHorizontally) { this.flip = SpriteEffects.None; } else { this.flip = SpriteEffects.FlipHorizontally; } if (position__1.X + SPRITE_SIZE_X - 30 <= Position.X) { //flip = SpriteEffects.None; spriteState.Add(Enumeration.State.advance, Enumeration.PriorityState.Normal); } else if (position__1.X - SPRITE_SIZE_X + 30 >= Position.X) { spriteState.Add(Enumeration.State.advance, Enumeration.PriorityState.Normal); } else { //flip = SpriteEffects.FlipHorizontally; Strike(); //spriteState.Add(Enumeration.State.ready, Enumeration.PriorityState.Normal); return; } sprite.PlayAnimation(spriteSequence, spriteState.Value()); }
public bool CheckOnRow(Position p) { if (p.Y == Y) { return true; } return false; }
public bool CheckCollision(Position p) { if (p.Y == Y) { if (p.X + 10 > X & p.X - 10 < X) { return true; } } return false; }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position, SpriteEffects spriteEffect) { _position = new Position(new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), new Vector2(Player.SPRITE_SIZE_X, Player.SPRITE_SIZE_Y)); _position.X = position.X + Player.PLAYER_L_PENETRATION; _position.Y = position.Y + Player.PLAYER_STAND_FLOOR_PEN; Velocity = Vector2.Zero; Energy = 0; flip = spriteEffect; spriteState.Clear(); Show(); }
public void UpdateFrameTile(float elapsed, ref Position position, ref SpriteEffects spriteEffects__1, ref TileState tileState) { float TimePerFrame = 0; TimePerFrame = frameRate + sequence.frames[m_frameIndex].delay; //0.1 //TimePerFrame = 0.9f + sequence.frames[frameIndex].delay; //0.1 TotalElapsed += elapsed; if (TotalElapsed > TimePerFrame) { //Play Sound sequence.frames[m_frameIndex].PlaySound(); m_frameIndex = Math.Min(m_frameIndex + 1, Frames.Count - 1); TotalElapsed -= TimePerFrame; if (sequence.frames[m_frameIndex].type != Enumeration.TypeFrame.SPRITE) { //COMMAND string[] aCommand = sequence.frames[m_frameIndex].name.Split('|'); string[] aParameter = sequence.frames[m_frameIndex].parameter.Split('|'); for (int x = 0; x <= aCommand.Length - 1; x++) { if (aCommand[x] == Enumeration.TypeCommand.ABOUTFACE.ToString()) { if (spriteEffects__1 == SpriteEffects.FlipHorizontally) { spriteEffects__1 = SpriteEffects.None; } else { spriteEffects__1 = SpriteEffects.FlipHorizontally; } } else if (aCommand[x] == Enumeration.TypeCommand.GOTOFRAME.ToString()) { string par = aParameter[x]; int result = sequence.frames.FindIndex((Frame f) => f.name == par); m_frameIndex = result; } else if (aCommand[x] == Enumeration.TypeCommand.GOTOSEQUENCE.ToString()) { string par = aParameter[x]; Sequence result = lsequence.Find((Sequence s) => s.name == par); sequence = result; m_frameIndex = 0; tileState.Add(StateTileElement.Parse(par)); } else if (aCommand[x] == Enumeration.TypeCommand.IFGOTOSEQUENCE.ToString()) { string par = string.Empty; if (tileState.Value().IfTrue == true) { par = aParameter[0]; } else { par = aParameter[1]; } Sequence result = lsequence.Find((Sequence s) => s.name == par); sequence = result; m_frameIndex = 0; tileState.Add(StateTileElement.Parse(par)); } } } int flip = 0; if (spriteEffects__1 == SpriteEffects.FlipHorizontally) { flip = 1; } else { flip = -1; } position.Value = new Vector2(position.X + (sequence.frames[m_frameIndex].xOffSet * flip), position.Y + sequence.frames[m_frameIndex].yOffSet); } else if (firstTime == true) { int flip = 0; if (spriteEffects__1 == SpriteEffects.FlipHorizontally) { flip = 1; } else { flip = -1; } position.Value = new Vector2(position.X + (sequence.frames[m_frameIndex].xOffSet * flip), position.Y + sequence.frames[m_frameIndex].yOffSet); firstTime = false; //Play Sound sequence.frames[m_frameIndex].PlaySound(); } }
public void UpdateFrame(float elapsed, ref Position position, ref SpriteEffects spriteEffects__1, ref PlayerState playerState) { //Resetting Name float TimePerFrame = 0; playerState.Value().Name = string.Empty; //playerState.Value().Name = sequence.frames[frameIndex].name; //System.Console.WriteLine(playerState.Value().Name.ToUpper()); TimePerFrame = frameRate + sequence.frames[m_frameIndex].delay; //0.1 //TimePerFrame = 0.9f + sequence.frames[frameIndex].delay; //0.1 //TimePerFrame = 1.2f + sequence.frames[frameIndex].delay; //0.1 TotalElapsed += elapsed; if (TotalElapsed > TimePerFrame) { //Play Sound sequence.frames[m_frameIndex].PlaySound(); m_frameIndex = Math.Min(m_frameIndex + 1, Frames.Count - 1); TotalElapsed -= TimePerFrame; //Taking name of the frame usefull for hit combat.. playerState.Value().Name = sequence.frames[m_frameIndex].name; if (sequence.frames[m_frameIndex].type != Enumeration.TypeFrame.SPRITE) { //COMMAND string[] aCommand = sequence.frames[m_frameIndex].name.Split('|'); string[] aParameter = sequence.frames[m_frameIndex].parameter.Split('|'); for (int x = 0; x <= aCommand.Length - 1; x++) { if (aCommand[x] == Enumeration.TypeCommand.ABOUTFACE.ToString()) { if (spriteEffects__1 == SpriteEffects.FlipHorizontally) { spriteEffects__1 = SpriteEffects.None; } else { spriteEffects__1 = SpriteEffects.FlipHorizontally; } } else if (aCommand[x] == Enumeration.TypeCommand.GOTOFRAME.ToString()) { string par = aParameter[x]; int result = sequence.frames.FindIndex((Frame f) => f.name == par); m_frameIndex = result; } else if (aCommand[x] == Enumeration.TypeCommand.GOTOSEQUENCE.ToString()) { string[] par = aParameter[x].Split(':'); Sequence result = lsequence.Find((Sequence s) => s.name == par[0]); sequence = result; m_frameIndex = 0; if (par.Length > 1) { Vector2 v = new Vector2(float.Parse(par[1].Split(',')[0]), float.Parse(par[1].Split(',')[1])); playerState.Add(StatePlayerElement.Parse(par[0]), Enumeration.PriorityState.Normal, v); } else { playerState.Add(StatePlayerElement.Parse(par[0])); } } else if (aCommand[x] == Enumeration.TypeCommand.IFGOTOSEQUENCE.ToString()) { string par = string.Empty; if (playerState.Value().IfTrue == true) { par = aParameter[0]; } else { par = aParameter[1]; } Sequence result = lsequence.Find((Sequence s) => s.name == par); sequence = result; m_frameIndex = 0; playerState.Add(StatePlayerElement.Parse(par)); } else if (aCommand[x] == Enumeration.TypeCommand.DELETE.ToString()) { playerState.Add(Enumeration.State.delete, Enumeration.PriorityState.Force); } } } int flip = 0; if (spriteEffects__1 == SpriteEffects.FlipHorizontally) { //& TotalElapsed > TimePerFrame) skip first frame =!==!=?!?bug flip = 1; } else { flip = -1; } position.Value = new Vector2(position.X + (sequence.frames[m_frameIndex].xOffSet * flip), position.Y + sequence.frames[m_frameIndex].yOffSet); } else if (firstTime == true) { //Play Sound sequence.frames[m_frameIndex].PlaySound(); int flip = 0; if (spriteEffects__1 == SpriteEffects.FlipHorizontally) { flip = 1; } else { flip = -1; } position.Value = new Vector2(position.X + (sequence.frames[m_frameIndex].xOffSet * flip), position.Y + sequence.frames[m_frameIndex].yOffSet); firstTime = false; } }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position, SpriteEffects spriteEffect) { _position = new Position(new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), new Vector2(Player.SPRITE_SIZE_X, Player.SPRITE_SIZE_Y)); _position.X = position.X; _position.Y = position.Y; Velocity = Vector2.Zero; Energy = PrinceOfPersiaGame.CONFIG_KID_START_ENERGY; flip = spriteEffect; spriteState.Clear(); Stand(); }
public float CheckOnRowDistance(Position p) { if (p.Y == Y) { float distance = Math.Abs(p.X - X); int ret = Convert.ToInt32(Math.Truncate(distance)) / Tile.WIDTH; return ret; } return -1; }
public float CheckOnRowDistancePixel(Position p) { if (p.Y == Y) { float distance = Math.Abs(p.X - X); //int ret = ((int)distance) / Tile.WIDTH; return distance; } return -1; }
public bool CheckOnRow(Position position__1) { if (position__1.Y == Position.Y) { return true; } return false; }
public bool CheckCollision(Position position__1) { if (object.ReferenceEquals(position__1, Position)) { return true; } return false; }
public void SubsTile(Vector2 coordinate, Enumeration.TileType tileType) { int x = Convert.ToInt32(Math.Truncate(coordinate.X)); // (int)Math.Floor((float)position.X / Tile.WIDTH); int y = Convert.ToInt32(Math.Truncate(coordinate.Y)); //(int)Math.Ceiling(((float)(position.Y - RoomNew.BOTTOM_BORDER) / Tile.HEIGHT)); Tile t = new Tile(this, content, tileType, Enumeration.StateTile.normal, Enumeration.Items.nothing, Enumeration.TileType.space); Position p = new Position(tiles[x, y].Position._screenRealSize, tiles[x, y].Position._spriteRealSize); p.X = tiles[x, y].Position.X; p.Y = tiles[x, y].Position.Y; t.Position = p; tiles[x, y] = t; tiles[x, y].tileAnimation.PlayAnimation(t.TileSequence, t.tileState.Value()); }