public void LoadTileList(string tilelist) { Texture2D tempTex = null; int tempColl = -1; string ReadLine; using (StreamReader sr = new StreamReader(BASEFILEPATH + tilelist)) { while ((ReadLine = sr.ReadLine()) != null) { try { tempColl = int.Parse(ReadLine); } catch (FormatException) { if (ReadLine != "") { tempTex = RAM.LoadContent(ReadLine); } } if (tempColl != -1 && tempTex != null) { TileList.Add(new TileInfo(tempTex, tempColl)); tempColl = -1; tempTex = null; } } } }
public void Draw(SpriteBatch spriteBatch) { Texture2D bb = RAM.LoadContent(@"Pixel"); if (Targeted == false) { spriteBatch.Draw(this.GetSprite(), this.GetPosition() + this.GetOffset(), Color.White); } else { spriteBatch.Draw(this.GetSprite(), this.GetPosition() + this.GetOffset(), Color.Red); } int dsd = cir.GetRadius(); for (int x = 0; x <= 300; x++) { int a = (int)Math.Round((GetPosition().X) + cir.GetRadius() * Math.Cos(x)); int b = (int)Math.Round((GetPosition().Y) - cir.GetRadius() * Math.Sin(x)); spriteBatch.Draw(bb, new Vector2((float)a, (float)b), Color.Red); } for (int x = 0; x <= 350 * 3; x++) { int a = (int)Math.Round((GetPosition().X) + MoveCircle.GetRadius() * Math.Cos(x)); int b = (int)Math.Round((GetPosition().Y) - MoveCircle.GetRadius() * Math.Sin(x)); spriteBatch.Draw(bb, new Vector2((float)a, (float)b), Color.Red); } }
public void Draw(SpriteBatch spriteBatch) { Texture2D aa = RAM.LoadContent(@"Pixel"); if (rec != null) { for (int x = rec.GetInteractiveRectangle().Left; x <= rec.GetInteractiveRectangle().Right; x++) { for (int y = rec.GetInteractiveRectangle().Top; y <= rec.GetInteractiveRectangle().Bottom; y++) { if (x <= rec.GetInteractiveRectangle().Left || rec.GetInteractiveRectangle().Right <= x || y <= rec.GetInteractiveRectangle().Top || rec.GetInteractiveRectangle().Bottom <= y) { spriteBatch.Draw(aa, new Vector2(x, y), Color.Red); } } } /* for (int x = rec.GetCollisionRectangle().Left; x <= rec.GetCollisionRectangle().Right; x++) * { * for (int y = rec.GetCollisionRectangle().Top; y <= rec.GetCollisionRectangle().Bottom; y++) * { * if (x <= rec.GetCollisionRectangle().Left || rec.GetCollisionRectangle().Right <= x || y <= rec.GetCollisionRectangle().Top || rec.GetCollisionRectangle().Bottom <= y) || { || spriteBatch.Draw(bb, new Vector2(x, y), Color.White); || } || } || }*/ } if (cir != null) { for (int x = 0; x <= 200; x++) { int a = (int)Math.Round((GetPosition().X) + (cir.GetRadius() * Math.Cos(x))); int b = (int)Math.Round((GetPosition().Y) - (cir.GetRadius() * Math.Sin(x))); spriteBatch.Draw(aa, new Vector2((float)a, (float)b), Color.Green); } if (this is AvatarSprite) { for (int x = 0; x <= 200; x++) { int a = (int)Math.Round((GetPosition().X) + (cir.GetRadius() + cir.GetInteractionArea()) * Math.Cos(x)); int b = (int)Math.Round((GetPosition().Y) - (cir.GetRadius() + cir.GetInteractionArea()) * Math.Sin(x)); spriteBatch.Draw(aa, new Vector2((float)a, (float)b), Color.Red); } } } spriteBatch.Draw(aa, GetPosition(), Color.Aqua); spriteBatch.Draw(this.GetSprite(), this.GetPosition() + this.GetOffset(), Color.White); }
public BasicSpriteInfo(Vector2 offset, Texture2D sprite) { Position = new Vector2(0, 0); Offset = offset; if (sprite == null) { Sprite = RAM.LoadContent(@"DefultSprite"); } else { Sprite = sprite; } }
public void Draw(SpriteBatch spriteBatch) { if (RAM.TalkFlag == true) { spriteBatch.Draw(RAM.LoadContent(@"TextBox"), new Vector2(RAM.camera.GetTextBoxPosition().X - XFORMATING, RAM.camera.GetTextBoxPosition().Y + YFORMATING), Color.White); try { for (int x = 0; x <= Letter; x++) { if (x <= StringList[LineCounter].Length - 1) { spriteBatch.DrawString(RAM.GetFont(0), StringList[LineCounter][x].ToString(), new Vector2((RAM.camera.GetTextBoxPosition().X - 590) + (x * KERN), (RAM.camera.GetTextBoxPosition().Y + 215) + (LineCounter * LINESPACE)), Color.White); } if (LineCounter + 1 <= StringList.Count - 1) { if (x <= StringList[LineCounter + 1].Length - 1) { spriteBatch.DrawString(RAM.GetFont(0), StringList[(LineCounter + 1)][x].ToString(), new Vector2((RAM.camera.GetTextBoxPosition().X - 590) + (x * KERN), (RAM.camera.GetTextBoxPosition().Y + 215) + ((LineCounter + 1) * LINESPACE)), Color.White); } } if (LineCounter + 2 <= StringList.Count - 1) { if (x <= StringList[LineCounter + 2].Length - 1) { spriteBatch.DrawString(RAM.GetFont(0), StringList[(LineCounter + 2)][x].ToString(), new Vector2((RAM.camera.GetTextBoxPosition().X - 590) + (x * KERN), (RAM.camera.GetTextBoxPosition().Y + 215) + ((LineCounter + 2) * LINESPACE)), Color.White); } } if (LineCounter + 3 <= StringList.Count - 1) { if (x <= StringList[LineCounter + 3].Length - 1) { spriteBatch.DrawString(RAM.GetFont(0), StringList[(LineCounter + 3)][x].ToString(), new Vector2((RAM.camera.GetTextBoxPosition().X - 590) + (x * KERN), (RAM.camera.GetTextBoxPosition().Y + 215) + ((LineCounter + 3) * LINESPACE)), Color.White); } } } } catch (ArgumentOutOfRangeException) { } } }
public void Update(GameTime gameTime) { ((Player)ObjectList[0][0]).ControlledPlayer = true; foreach (BaseEnitiy obj in ObjectList[0]) { if (obj is Player) { if (((Player)obj).ControlledPlayer == true) { ControlledPlayer = (Player)obj; } } obj.SetSprite(RAM.LoadContent(obj.CurrentAnimation.GetSpriteName(obj.CurrentAnimation.GetFrame()))); } KeyboardState keyboardState = Keyboard.GetState(); if (Menuflag == true) { pointer.Update(gameTime); if (keyboardState.IsKeyDown(Keys.Enter)) { if (pointer.GetChoice() == 0)//Move { Menuflag = false; } else if (pointer.GetChoice() == 1)//Attack { ((BattleChar)ObjectList[0][5]).Targeted = true; } else if (pointer.GetChoice() == 2)//Magic { } else if (pointer.GetChoice() == 3)//Skill { } else if (pointer.GetChoice() == 4)//Defend { } else if (pointer.GetChoice() == 5)//Run { RAM.BattleFlag = false; } } } else { // base.Update(); MoveTime.Update(gameTime); foreach (BaseEnitiy obj in ObjectList[0]) { if (obj is Player) { ((Player)obj).Update(gameTime); } if (obj != ControlledPlayer) { if (obj.GetCir().Intersects(ControlledPlayer.GetPosition(), obj.GetPosition()) == false) { if (keyboardState.IsKeyDown(Keys.Up) && keyboardState.IsKeyDown(Keys.Left)) { ControlledPlayer.SetPosition(new Vector2(ControlledPlayer.GetPosition().X + (RAM.TILESIZE / 8), ControlledPlayer.GetPosition().Y + (RAM.TILESIZE / 8))); } else if (keyboardState.IsKeyDown(Keys.Up) && keyboardState.IsKeyDown(Keys.Right)) { ControlledPlayer.SetPosition(new Vector2(ControlledPlayer.GetPosition().X - (RAM.TILESIZE / 8), ControlledPlayer.GetPosition().Y + (RAM.TILESIZE / 8))); } else if (keyboardState.IsKeyDown(Keys.Down) && keyboardState.IsKeyDown(Keys.Left)) { ControlledPlayer.SetPosition(new Vector2(ControlledPlayer.GetPosition().X + (RAM.TILESIZE / 8), ControlledPlayer.GetPosition().Y - (RAM.TILESIZE / 8))); } else if (keyboardState.IsKeyDown(Keys.Down) && keyboardState.IsKeyDown(Keys.Right)) { ControlledPlayer.SetPosition(new Vector2(ControlledPlayer.GetPosition().X - (RAM.TILESIZE / 8), ControlledPlayer.GetPosition().Y - (RAM.TILESIZE / 8))); } else if (keyboardState.IsKeyDown(Keys.Up)) { ControlledPlayer.SetPositionY(ControlledPlayer.GetPosition().Y + RAM.TILESIZE / 8); } else if (keyboardState.IsKeyDown(Keys.Down)) { ControlledPlayer.SetPositionY(ControlledPlayer.GetPosition().Y - RAM.TILESIZE / 8); } else if (keyboardState.IsKeyDown(Keys.Left)) { ControlledPlayer.SetPositionX(ControlledPlayer.GetPosition().X + RAM.TILESIZE / 8); } else if (keyboardState.IsKeyDown(Keys.Right)) { ControlledPlayer.SetPositionX(ControlledPlayer.GetPosition().X - RAM.TILESIZE / 8); } } } } } /* * KeyboardState keyboardState = Keyboard.GetState(); * float time = (float)gameTime.ElapsedGameTime.TotalMilliseconds; * BattleChar Chased = null; * base.Update(); * * //TempList = ObjectList; * for (int x = 0; x <= PlayerList.Count - 1; ) * { * PlayerList.Remove(PlayerList[x]); * } * for (int x = 0; x <= EnemyList.Count - 1; ) * { * EnemyList.Remove(EnemyList[x]); * } * foreach (BattleChar obj in ObjectList) * { * obj.MoveFlag = true; * if (obj is Player) * { * if(((Player)obj).ControlledPlayer == true) * { * ControlledPlayer = ((Player)obj); * } * PlayerList.Add(((Player)obj)); * ((Player)obj).Update(gameTime); * } * if (obj is Enemy) * { * EnemyList.Add(((Enemy)obj)); * ((Enemy)obj).Update(gameTime); * } * CircleCollision(time); * } * LeftX = lowest; * lowest = 0; * int test = 0; * ///////////////////////////////////////////////////////////////////////////////////// * ///////////////////////////////////////////////////////////////////////////////////// * * foreach (Enemy enemy in EnemyList) * { * if (enemy.MoveFlag == true) * { * int LowestHP = PlayerList[0].HP; * foreach (Player player in PlayerList) * { * * if (LowestHP <= player.HP) * { * Chased = player; * } * } * * Chase(gameTime, enemy, Chased); * } * } * //////////////////////////////////////////////////////////////////////////////////////////////////////// * foreach (Player player in PlayerList) * { * float MoveSpeed = player.MoveSpeed; * if (player.MoveFlag == true) * { * if (player is TestPlayer) * { * * if (keyboardState.IsKeyDown(Keys.Right)) * { * float dsd = player.GetPosition().X; * float dse = player.GetPosition().Y; * int sdf = 34; * } * if (keyboardState.IsKeyDown(Keys.Up) * && keyboardState.IsKeyDown(Keys.Left)) * { * * player.SetPosition(new Vector2(player.GetPosition().X - MoveSpeed, player.GetPosition().Y - MoveSpeed)); * camera.SetPosition(new Vector2(camera.GetPosition().X + MoveSpeed, camera.GetPosition().Y + MoveSpeed)); * StatsPos.X -= MoveSpeed; * StatsPos.Y -= MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Up) * && keyboardState.IsKeyDown(Keys.Right)) * { * player.SetPosition(new Vector2(player.GetPosition().X + MoveSpeed, player.GetPosition().Y - MoveSpeed)); * camera.SetPosition(new Vector2(camera.GetPosition().X - MoveSpeed, camera.GetPosition().Y + MoveSpeed)); * StatsPos.X += MoveSpeed; * StatsPos.Y -= MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Down) * && keyboardState.IsKeyDown(Keys.Left)) * { * player.SetPosition(new Vector2(player.GetPosition().X - MoveSpeed, player.GetPosition().Y + MoveSpeed)); * camera.SetPosition(new Vector2(camera.GetPosition().X + MoveSpeed, camera.GetPosition().Y - MoveSpeed)); * StatsPos.X -= MoveSpeed; * StatsPos.Y += MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Down) * && keyboardState.IsKeyDown(Keys.Right)) * { * player.SetPosition(new Vector2(player.GetPosition().X + MoveSpeed, player.GetPosition().Y + MoveSpeed)); * camera.SetPosition(new Vector2(camera.GetPosition().X - MoveSpeed, camera.GetPosition().Y - MoveSpeed)); * StatsPos.X += MoveSpeed; * StatsPos.Y += MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Up)) * { * player.SetPositionY(player.GetPosition().Y - MoveSpeed); * camera.SetPosition(new Vector2(camera.GetPosition().X, camera.GetPosition().Y + MoveSpeed)); * StatsPos.Y -= MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Down)) * { * player.SetPositionY( player.GetPosition().Y + MoveSpeed); * camera.SetPosition(new Vector2(camera.GetPosition().X, camera.GetPosition().Y - MoveSpeed)); * StatsPos.Y += MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Left)) * { * player.SetPositionX(player.GetPositionX() - MoveSpeed); * camera.SetPosition(new Vector2(camera.GetPosition().X + MoveSpeed, camera.GetPosition().Y)); * StatsPos.X -= MoveSpeed; * } * else if (keyboardState.IsKeyDown(Keys.Right)) * { * float dsd = player.GetPosition().X; * float dse = player.GetPosition().Y; * float erew = MoveSpeed; * player.SetPositionX(player.GetPositionX() + MoveSpeed); * camera.SetPosition(new Vector2(camera.GetPosition().X - MoveSpeed, camera.GetPosition().Y)); * StatsPos.X += MoveSpeed; * float dsdg = player.GetPosition().X; * int ds = 34; * } * } * else * { * Chased = EnemyList[0]; * Chase(gameTime, player,Chased); * } * } * } * foreach (BattleChar obj in ObjectList) * { * if (obj.HP < 0) * { * ObjectList.Remove(obj); * break; * } * }*/ foreach (BattleChar obj in ObjectList[0]) { obj.SetSprite(RAM.LoadContent(obj.CurrentAnimation.GetSpriteName(obj.CurrentAnimation.GetFrame()))); } }
public void Update(GameTime gameTime) { KeyboardState keyboardState = Keyboard.GetState(); RAM.VRAM.Update(); for (int x = 0; x <= RAM.VRAM.LayerCount; x++) { try { foreach (BaseEnitiy obj in RAM.VRAM.ObjectList[x]) { if (obj is AvatarSprite) { MainChar = (AvatarSprite)obj; ((AvatarSprite)obj).Update(gameTime); } else if (obj is NPC) { ((NPC)obj).Update(gameTime); } else if (obj is Chest) { ((Chest)obj).Update(gameTime); } else if (obj is Door) { ((Door)obj).Update(gameTime); } else if (obj is LayerChange) { ((LayerChange)obj).Update(gameTime); } else if (obj is Encounter_Area) { ((Encounter_Area)obj).Update(gameTime); } else if (obj is Boat) { ((Boat)obj).Update(gameTime); } obj.SetSprite(RAM.LoadContent(obj.CurrentAnimation.GetSpriteName(obj.CurrentAnimation.GetFrame()))); } } catch (InvalidOperationException) { Update(gameTime); } } if (RAM.TalkFlag == true) { // RAM.Storytext.Update(gameTime); } if (TalkFlag == false) { foreach (BaseEnitiy obj in RAM.VRAM.ObjectList[RAM.VRAM.LayerLevel]) { if (obj != MainChar) { if (obj.GetCollision() == true) { if (obj.GetRec().GetCollisionRectangle().Intersects(MainChar.GetRec().GetCollisionRectangle())) { if (keyboardState.IsKeyDown(Keys.Up) && keyboardState.IsKeyDown(Keys.Left)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X + (RAM.TILESIZE / 8), MainChar.GetPosition().Y + (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X + (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y + (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Up) && keyboardState.IsKeyDown(Keys.Right)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X - (RAM.TILESIZE / 8), MainChar.GetPosition().Y + (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X - (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y + (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Down) && keyboardState.IsKeyDown(Keys.Left)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X + (RAM.TILESIZE / 8), MainChar.GetPosition().Y - (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X + (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y - (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Down) && keyboardState.IsKeyDown(Keys.Right)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X - (RAM.TILESIZE / 8), MainChar.GetPosition().Y - (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X - (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y - (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Up)) { MainChar.SetPositionY(MainChar.GetPosition().Y + RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X, RAM.camera.GetTextBoxPosition().Y + (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Down)) { MainChar.SetPositionY(MainChar.GetPosition().Y - RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X, RAM.camera.GetTextBoxPosition().Y - (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Left)) { MainChar.SetPositionX(MainChar.GetPosition().X + RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.GetTextBoxPosition().X + (RAM.TILESIZE / 8), RAM.camera.TextBoxPos.Y); } else if (keyboardState.IsKeyDown(Keys.Right)) { MainChar.SetPositionX(MainChar.GetPosition().X - RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.GetTextBoxPosition().X - (RAM.TILESIZE / 8), RAM.camera.TextBoxPos.Y); } } if (obj.GetCir().Intersects(MainChar.GetPosition(), obj.GetPosition()) == false) { if (keyboardState.IsKeyDown(Keys.Up) && keyboardState.IsKeyDown(Keys.Left)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X + (RAM.TILESIZE / 8), MainChar.GetPosition().Y + (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X + (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y + (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Up) && keyboardState.IsKeyDown(Keys.Right)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X - (RAM.TILESIZE / 8), MainChar.GetPosition().Y + (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X - (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y + (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Down) && keyboardState.IsKeyDown(Keys.Left)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X + (RAM.TILESIZE / 8), MainChar.GetPosition().Y - (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X + (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y - (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Down) && keyboardState.IsKeyDown(Keys.Right)) { MainChar.SetPosition(new Vector2(MainChar.GetPosition().X - (RAM.TILESIZE / 8), MainChar.GetPosition().Y - (RAM.TILESIZE / 8))); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X - (RAM.TILESIZE / 8), RAM.camera.GetTextBoxPosition().Y - (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Up)) { MainChar.SetPositionY(MainChar.GetPosition().Y + RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X, RAM.camera.GetTextBoxPosition().Y + (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Down)) { MainChar.SetPositionY(MainChar.GetPosition().Y - RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.TextBoxPos.X, RAM.camera.GetTextBoxPosition().Y - (RAM.TILESIZE / 8)); } else if (keyboardState.IsKeyDown(Keys.Left)) { MainChar.SetPositionX(MainChar.GetPosition().X + RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.GetTextBoxPosition().X + (RAM.TILESIZE / 8), RAM.camera.TextBoxPos.Y); } else if (keyboardState.IsKeyDown(Keys.Right)) { MainChar.SetPositionX(MainChar.GetPosition().X - RAM.TILESIZE / 8); RAM.camera.TextBoxPos = new Vector2(RAM.camera.GetTextBoxPosition().X - (RAM.TILESIZE / 8), RAM.camera.TextBoxPos.Y); } } } } } } }