public static Booth Create(Player Player, UInt16 X, UInt16 Y) { Player.Booth = null; GameMap Map = Player.Map; Int32 UniqId = -1; foreach (Object Object in Map.Entities.Values) { NPC Npc = (Object as NPC); if (Npc == null) { continue; } if ((Npc.X + 3 == X) && (Npc.Y == Y)) { UniqId = 610000 + Npc.UniqId; } } if (UniqId == -1) { return(null); } Booth Booth = new Booth(UniqId, Player, X, Y); Map.AddEntity(Booth); World.BroadcastMapMsg(Map.Id, new MsgNpcInfo(Booth, true)); Player.Booth = Booth; return(Booth); }
#pragma warning disable CS0162 // Unreachable code detected public async Task <bool> EstablishGame(bool connectOnline) { return(await Task.Run(new Func <bool>(() => { if (connectOnline) { //Connect to matchmaker if (!NetworkManager.Connect(new Network.Client.ClientInfo(new Network.Client.LobbyInfo(targetPlayers, new Network.Client.LobbyAspect[0]), DatabaseManager.Username))) { graphicsUI.MessageManager.AddMessage("Failed to connect to the " + NetworkManager.CurrentConnectionType.ToString().ToLower() + " matchmaking server."); return false; } else { return true; } } else { //Start local game gameMap = new GameMap(new Random(), graphicsDevice, this); gameMap.AddEntity(PlayerStandards.PlayerTypes[(int)PlayerStandards.PlayerType.Knight].DeployPlayer(Content, graphicsDevice, gameMap, new GameTime())); StartGame(); return true; } }))); }
public DamageableEntity(float initialHealth, int initialLives, Polygon collisionPolygon, GameMap gameMap) { clientCollider = new ClientCollider(collisionPolygon, HandleCollision); gameMap.AddEntity(clientCollider); currentLives = initialLives; currentHealth = initialHealth; this.initialHealth = initialHealth; }
public void SpawnDeathParticles(GameMap gameMap) { RigidBody.VelocityRestriction[] velocityRestrictions = RigidBody.AllRestrictions; for (int i = 0; i < playerTexturePack.DeathParticles.Length; i++) { gameMap.AddEntity(new SpriteParticle(gameMap, gameMap.gameSession.LatestGameTime, new RectangleF(playerPolygon.CenterPoint.X - (drawScale.X * PLAYER_SIZE_PORTION / 2), playerPolygon.CenterPoint.Y - (drawScale.Y * PLAYER_SIZE_PORTION / 2), drawScale.X * PLAYER_SIZE_PORTION, drawScale.Y * PLAYER_SIZE_PORTION), new Vector2(MAX_RANDOM_VELOCITY - (2 * MAX_RANDOM_VELOCITY * (float)gameMap.gameSession.LocalRandom.NextDouble()), MAX_RANDOM_VELOCITY - (2 * MAX_RANDOM_VELOCITY * (float)gameMap.gameSession.LocalRandom.NextDouble())), playerTexturePack.DeathParticles[i], enableRotation: true, allowedCollisionsOverride: velocityRestrictions)); } }
#pragma warning restore CS0162 // Unreachable code detected public async void LoadMap(Random random) { await Task.Run(() => { //Load map gameMap = new Map.GameMap(random, graphicsDevice, this); //TEMP (ADD PLAYER SELECTION) gameMap.AddEntity(PlayerStandards.PlayerTypes[(int)PlayerStandards.PlayerType.Knight].DeployPlayer(Content, graphicsDevice, gameMap, LatestGameTime)); //Send ready message NetworkManager.SendMessage(new ClientReadyMessage()); }); }
public void SpawnDamageNotifier(float damage, GameMap gameMap) { string additive = ""; Color drawColor = Color.LightGreen; if (damage < 0) { drawColor = Color.Red; } else { additive += "+"; } gameMap.AddEntity(new TextParticle(additive + damage.ToString(), gameMap, gameMap.gameSession.LatestGameTime, playerPolygon.BoundaryRectangle, new Vector2(MAX_RANDOM_VELOCITY - (2 * MAX_RANDOM_VELOCITY * (float)gameMap.gameSession.LocalRandom.NextDouble()), MAX_RANDOM_VELOCITY - (2 * MAX_RANDOM_VELOCITY * (float)gameMap.gameSession.LocalRandom.NextDouble())), drawColor)); }
public IActionResult[] Drop(Item item) { Remove(item); item.transform.parent = null; item.Entity.Position = Entity.Position; map.AddEntity(item.Entity); item.gameObject.SetActive(true); return(new IActionResult[] { new DropItemActionResult() { Item = item, Message = string.Format("You dropped the {0}", item.Entity.DisplayName) } }); }
public void SpawnBlood(GameMap gameMap) { gameMap.AddEntity(new SpriteParticle(gameMap, gameMap.gameSession.LatestGameTime, playerPolygon.BoundaryRectangle, new Vector2(MAX_RANDOM_VELOCITY - (2 * MAX_RANDOM_VELOCITY * (float)gameMap.gameSession.LocalRandom.NextDouble()), MAX_RANDOM_VELOCITY - (2 * MAX_RANDOM_VELOCITY * (float)gameMap.gameSession.LocalRandom.NextDouble())), playerTexturePack.BloodSheets[gameMap.gameSession.LocalRandom.Next(0, playerTexturePack.BloodSheets.Length)], endAfterLoop: true, ignoreCollisions: true)); }