private static bool IsInPortal(PlayerLocation playerLocation) { return (playerLocation.X >= 253 && playerLocation.X <= 259 && playerLocation.Y >= 77 && playerLocation.Y <= 83 && playerLocation.Z >= 276 && playerLocation.Z <= 279); }
public override void SpawnLevel(Level toLevel, PlayerLocation spawnPoint, bool useLoadingScreen = false, Func <Level> levelFunc = null, Action postSpawnAction = null) { CooldownTick = 20; //lock(DynamicInvSync) // DynInventory = null; for (int i = 0; i < Inventory.Slots.Count; ++i) { if (Inventory.Slots[i] == null || Inventory.Slots[i].Id != 0) { Inventory.Slots[i] = new ItemAir(); } } if (Inventory.Helmet.Id != 0) { Inventory.Helmet = new ItemAir(); } if (Inventory.Chest.Id != 0) { Inventory.Chest = new ItemAir(); } if (Inventory.Leggings.Id != 0) { Inventory.Leggings = new ItemAir(); } if (Inventory.Boots.Id != 0) { Inventory.Boots = new ItemAir(); } AllowFly = false; IsSpectator = false; base.SpawnLevel(toLevel, spawnPoint, useLoadingScreen, levelFunc, null); }
public ProjectileHitEventArgs(long entityID, Level level, PlayerLocation knownPosition, Player shooter) { EntityID = entityID; Shooter = shooter; KnownPosition = knownPosition; Level = level; }
private bool PlayerMoveEvent(PlayerLocation from, PlayerLocation to, bool teleport = false) { PlayerMoveEvent playerMoveEvent = new PlayerMoveEvent(this, from, to, teleport); EventDispatcher.DispatchEvent(playerMoveEvent); return(!playerMoveEvent.IsCancelled); }
private bool isPlayerEliminated(SPlayer sp, PlayerLocation startLocation, Tile t) { if (t == null || startLocation.Coordinate != t.Coordinate) { return(false); } int positionAfterPath = t.GetPathConnection(startLocation.PositionOnTile); Vector2Int newCoord = startLocation.Coordinate + DirectionUtils.DirectionToVector(DirectionUtils.IntToDirection(positionAfterPath)); int newPos = DirectionUtils.AdjacentPosition(positionAfterPath); PlayerLocation pl = new PlayerLocation(newCoord, newPos); if (!isPositionInBoard(newCoord) || GetPlayersAtLocation(pl, sp).Count > 0) { return(true); } if (m_placedTiles.ContainsKey(newCoord)) { return(isPlayerEliminated(sp, pl, m_placedTiles [newCoord])); } return(false); }
public static Player LoadPlayerLocation() { string path = Application.persistentDataPath + "/player.save"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); PlayerLocation data = formatter.Deserialize(stream) as PlayerLocation; stream.Close(); Player thePlayer = new Player { LocationID = data.LocationID, Password = data.Password, Username = data.Username }; return(thePlayer); } else { Debug.LogError("Cannot save file"); return(null); } }
public PlayerCountHologram(string name, Level level, PlayerLocation playerLocation, string gameName) : base(name, level, playerLocation) { _gameName = gameName; KnownPosition = (PlayerLocation)KnownPosition.Clone(); KnownPosition.Y += 2.8f; }
private static bool IsInInvisRegion(PlayerLocation playerLocation) { return (playerLocation.X >= 252 && playerLocation.X <= 261 && playerLocation.Y >= 77 && playerLocation.Y <= 83 && playerLocation.Z >= 252 && playerLocation.Z <= 258); }
void Ready(LobbyMessageInfo info) { LobbyPlayer player = GetLobbyPlayer(info); LogManager.General.Log(string.Format("Player '{0}' is now ready after logging in, connecting him to town", player.name)); // Return player to his location in the game world LocationsDB.GetLocation(player.accountId, (data) => { // If that's the first time logging in, set the location to the default map if (data == null) { data = new PlayerLocation(MapManager.startingMap, ServerType.World); } // This will connect the player to a new or existing server // using the location data we just received. player.location = data; }); // Add player to chat channels LobbyServer.globalChannel.AddPlayer(player); LobbyServer.announceChannel.AddPlayer(player); // Login message SendSystemMessage(player, loginMessage); }
public PlayerMob(string name, Level level) : base(63, level) { Uuid = new UUID(Guid.NewGuid().ToByteArray()); Width = 0.6; Length = 0.6; Height = 1.80; IsSpawned = false; NameTag = name; Skin = new Skin { Slim = false, SkinData = Encoding.Default.GetBytes(new string('Z', 8192)) }; ItemInHand = new ItemAir(); HideNameTag = false; IsAlwaysShowName = true; IsInWater = true; NoAi = true; HealthManager.IsOnFire = false; Velocity = Vector3.Zero; PositionOffset = new PlayerLocation(0, 1.62f, 0); }
private void UpdateTarget() { var target = Entity.KnownPosition; if (!InterpolatedMovement) { Entity.RenderLocation = target; return; } var distance = Microsoft.Xna.Framework.Vector3.DistanceSquared( Entity.RenderLocation.ToVector3() * new Vector3(1f, 0f, 1f), target.ToVector3() * new Vector3(1f, 0f, 1f)); if (distance >= 16f) { Entity.RenderLocation = target; _frameAccumulator = TargetTime; } else { _frameAccumulator = 0; _from = (PlayerLocation)Entity.RenderLocation.Clone(); _target = (PlayerLocation)target.Clone(); } }
public HubLevel(SkyCoreAPI plugin, string gameId, string levelPath, GameLevelInfo gameLevelInfo, bool modifiable = false) : base(plugin, "hub", gameId, levelPath, gameLevelInfo, modifiable) { AddPendingTask(() => { PlayerLocation portalInfoLocation = new PlayerLocation(256.5, 79.5, 276.5); const string hologramContent = " §d§lSkytonia§r §f§lNetwork§r" + "\n" + " §7Enter the portal and§r" + "\n" + "§7enjoy your adventure!§r" + "\n" + " §ewww.skytonia.com§r"; new Hologram(hologramContent, this, portalInfoLocation).SpawnEntity(); RunnableTask.RunTaskLater(() => { try { PlayerNPC.SpawnAllHubNPCs(this); //SpawnHubMaps(); } catch (Exception e) { BugSnagUtil.ReportBug(e, this); } }, 250); }); }
// Constructor public LobbyPlayer(Account nAccount) { account = nAccount; peer = AccountManager.Master.GetLoggedInPeer(account); statusObservers = new HashSet <LobbyPlayer>(); statusObservers.Add(this); stats = null; ffaStats = null; custom = null; friends = null; _location = null; _followers = null; _party = new LobbyParty(); _gameInstance = null; artifactsEditingFlag = false; channels = new List <LobbyChatChannel>(); chatMember = new ChatMember(account.id.value); accountsWhereInfoIsRequired = new HashSet <string>(); LobbyPlayer.list.Add(this); LobbyPlayer.accountIdToLobbyPlayer[account.id.value] = this; LobbyPlayer.peerToLobbyPlayer[peer] = this; }
public override void SetLocation(PlayerLocation location) { Location = location; // Location.Yaw = Location.HeadYaw = MathUtils.RadianToDegree(rotation.Y); // Location.Pitch = MathUtils.RadianToDegree(rotation.Z); }
// Constructor - Assume that Boss and Player are at Starting Positions. public BlackBoard() { // Transforms BossTransform = null; PlyrTransform = null; // Health PlyrHP = 1.0f; BossHP = 1.0f; //Current Active Specialist ActSpec = ActionSpecialists.AttackSpec; PasSpec = PassiveSpecialists.DistanceSpec; //Boss Variables BossBhvr = BossBehavior.Agressive; // Distance Variables CurBossLoc = BossLocation.RightSide; PlyrLoc = PlayerLocation.LeftFromBoss; DestBossLoc = BossLocation.RightSide; PlyrDist = PlayerDistance.Far; isMovingToOtherSide = false; isAtSafeDistance = false; isPlyrLinedUp = false; // Projectile Variables AreBulletsNear = false; NumberBulletsNear = 0; }
protected Entity(Level level) { Level = level; KnownPosition = new PlayerLocation(); EntityId = EntityManager.EntityIdUndefined; }
public bool IsInWater(PlayerLocation playerPosition) { if (playerPosition.Y < 0 || playerPosition.Y > 255) { return(false); } float y = playerPosition.Y + 1.62f; BlockCoordinates waterPos = new BlockCoordinates { X = (int)Math.Floor(playerPosition.X), Y = (int)Math.Floor(y), Z = (int)Math.Floor(playerPosition.Z) }; var block = Entity.Level.GetBlock(waterPos); if (block == null || (block.Id != 8 && block.Id != 9)) { return(false); } return(y < Math.Floor(y) + 1 - ((1f / 9f) - 0.1111111)); }
public GameLevelInfo(string gameType, string levelName, int worldTime, PlayerLocation lobbyLocation) { GameType = gameType; LevelName = levelName; WorldTime = worldTime; LobbyLocation = lobbyLocation; }
public Hologram(string name, Level level, PlayerLocation playerLocation) : base(name, level) { NameTag = name; Scale = 0f; KnownPosition = playerLocation; }
private static bool IsInPortal(PlayerLocation playerLocation) { return (playerLocation.X >= 253 && playerLocation.X <= 257 && playerLocation.Y >= 15 && playerLocation.Y <= 20 && playerLocation.Z >= 263 && playerLocation.Z <= 264); }
public void SetBlock(Block block, bool broadcast = true, bool applyPhysics = true) { PlayerLocation spawn = SpawnPoint; ChunkColumn chunk = _worldProvider.GenerateChunkColumn(new ChunkCoordinates(block.Coordinates.X >> 4, block.Coordinates.Z >> 4)); chunk.SetBlock(block.Coordinates.X & 0x0f, block.Coordinates.Y & 0x7f, block.Coordinates.Z & 0x0f, block.Id); chunk.SetMetadata(block.Coordinates.X & 0x0f, block.Coordinates.Y & 0x7f, block.Coordinates.Z & 0x0f, block.Metadata); if (applyPhysics) { ApplyPhysics(block.Coordinates.X, block.Coordinates.Y, block.Coordinates.Z); } if (!broadcast) { return; } Block sendBlock = new Block(block.Id) { Coordinates = block.Coordinates, Metadata = (byte)(0xb << 4 | (block.Metadata & 0xf)) }; var message = McpeUpdateBlock.CreateObject(); message.blocks = new BlockRecords { sendBlock }; RelayBroadcast(message); }
public void MoveTo(PlayerLocation location, bool updateLook = true) { var distance = Microsoft.Xna.Framework.Vector3.Distance( Entity.KnownPosition.ToVector3() * new Vector3(1f, 0f, 1f), location.ToVector3() * new Vector3(1f, 0f, 1f)); //var difference = Entity.KnownPosition.ToVector3() - location.ToVector3(); //Move(difference); Entity.KnownPosition = location; //Entity.KnownPosition.X = location.X; //Entity.KnownPosition.Y = location.Y; //Entity.KnownPosition.Z = location.Z; //Entity.KnownPosition.OnGround = location.OnGround; if (updateLook) { //Entity.KnownPosition.Yaw = location.Yaw; //Entity.KnownPosition.HeadYaw = location.HeadYaw; //Entity.KnownPosition.Pitch = location.Pitch; } UpdateTarget(); Entity.DistanceMoved += MathF.Abs(distance); }
public void SetPlayerPosition(PlayerPosition playerPosition) { var newPosition = new PlayerLocation { Location = GetPlayerLocation(playerPosition), Timestamp = Timestamp.ToUtcMilliseconds(DateTime.UtcNow) }; if (_previousPosition != null && _previousPosition.Location == newPosition.Location) { return; } else { _playerPositions.Add(new PlayerLocation { Location = GetPlayerLocation(playerPosition), Timestamp = Timestamp.ToUtcMilliseconds(DateTime.UtcNow) }); _previousPosition = newPosition; } if (!seen.Contains(playerPosition.Zone) && !_knownPositions.Exists(m => m.Zone == playerPosition.Zone)) { Logger.Warn($"Unknown zone detected: {playerPosition.Zone:X}"); seen.Add(playerPosition.Zone); } }
public static List <Entity> SpawnLobbyNPC(GameLevel level, string gameName, PlayerLocation spawnLocation) { //Ensure this NPC can be seen PlayerNPC npc = new PlayerNPC("", level, spawnLocation, GameUtil.ShowGameList, gameName) { Scale = 1.5, KnownPosition = spawnLocation }; PlayerLocation changeGameLocation = (PlayerLocation)spawnLocation.Clone(); changeGameLocation.Y += 3.1f; Hologram changeGameHologram = new Hologram("§d§lChange Game", level, changeGameLocation); PlayerLocation clickHereLocation = (PlayerLocation)spawnLocation.Clone(); clickHereLocation.Y += 2.8f; Hologram clickHereHologram = new Hologram("§e(Click Here)", level, clickHereLocation); SkyCoreAPI.Instance.AddPendingTask(() => { npc.SpawnEntity(); changeGameHologram.SpawnEntity(); clickHereHologram.SpawnEntity(); }); return(new List <Entity> { npc, changeGameHologram, clickHereHologram }); }
public void Initialize() { IsWorldTimeStarted = true; _worldProvider.Initialize(); SpawnPoint = new PlayerLocation(_worldProvider.GetSpawnPoint()); CurrentWorldTime = _worldProvider.GetTime(); if (_worldProvider.IsCaching) { Stopwatch chunkLoading = new Stopwatch(); chunkLoading.Start(); // Pre-cache chunks for spawn coordinates int i = 0; foreach (var chunk in GenerateChunks(new ChunkCoordinates(SpawnPoint), new Dictionary <Tuple <int, int>, McpeBatch>())) { i++; } Log.InfoFormat("World pre-cache {0} chunks completed in {1}ms", i, chunkLoading.ElapsedMilliseconds); } StartTimeInTicks = DateTime.UtcNow.Ticks; _levelTicker = new Timer(WorldTick, null, 0, _worldTickTime); // MC worlds tick-time }
public PlayerNPC(string name, Level level, PlayerLocation playerLocation, onInteract action = null, string gameName = "") : base(name, level) { NameTag = name; KnownPosition = playerLocation; string npcSkinLocation; if (string.IsNullOrEmpty(gameName) || !File.Exists((npcSkinLocation = $@"C:\Users\Administrator\Desktop\npc-skins\{gameName}-npc.png"))) { Skin = new Skin { SkinData = Skin.GetTextureFromFile("Skin.png") }; } else { Skin = new Skin { SkinData = Skin.GetTextureFromFile(npcSkinLocation) }; } Scale = 1.8D; //Ensure this NPC is visible Width = 0.43; Height = 3.0D; _action = action; }
public override void SetLocation(PlayerLocation location) { // _rotation.Y = MathUtils.RadianToDegree(rotation.Y); // _rotation.Z = MathUtils.RadianToDegree(rotation.Z); // _rotation.X = MathUtils.RadianToDegree(rotation.X); _location = location; }
public override void OnTick() { base.OnTick(); if (Velocity.Length() > 0) { PlayerLocation oldPosition = (PlayerLocation)KnownPosition.Clone(); bool onGroundBefore = IsOnGround(KnownPosition); KnownPosition.X += (float)Velocity.X; KnownPosition.Y += (float)Velocity.Y; KnownPosition.Z += (float)Velocity.Z; bool onGround = IsOnGround(KnownPosition); if (!onGroundBefore && onGround) { KnownPosition.Y = (float)Math.Floor(oldPosition.Y); Velocity = Vector3.Zero; } else { Velocity *= (float)(1.0f - Drag); if (!onGround) { Velocity -= new Vector3(0, (float)Gravity, 0); } } LastUpdatedTime = DateTime.UtcNow; } else if (Velocity != Vector3.Zero) { Velocity = Vector3.Zero; LastUpdatedTime = DateTime.UtcNow; } }
private void GenerateParticles(Random random, Level level, PlayerLocation point, float yoffset, Vector3 multiplier, double d) { float vx = (float)random.NextDouble(); vx *= random.Next(2) == 0 ? 1 : -1; vx *= (float)multiplier.X; float vy = (float)random.NextDouble(); //vy *= random.Next(2) == 0 ? 1 : -1; vy *= (float)multiplier.Y; float vz = (float)random.NextDouble(); vz *= random.Next(2) == 0 ? 1 : -1; vz *= (float)multiplier.Z; McpeLevelEvent mobParticles = McpeLevelEvent.CreateObject(); mobParticles.eventId = (short)(0x4000 | GetParticle(random.Next(0, m < 1 ? 2 : 5))); mobParticles.x = point.X + vx; mobParticles.y = (point.Y - 2) + yoffset + vy; mobParticles.z = point.Z + vz; level.RelayBroadcast(mobParticles); }
public void Test1(Player player) { List <Pig> pigs = new List <Pig>(); for (int i = 0; i < 10; i++) { Pig pig = new Pig(player.Level); pig.KnownPosition = (PlayerLocation)player.KnownPosition.Clone(); pig.SpawnEntity(); pigs.Add(pig); } player.SendMessage("Spawned pigs"); Thread.Sleep(4000); PlayerLocation loc = (PlayerLocation)player.KnownPosition.Clone(); loc.Y = loc.Y + 10; loc.X = loc.X + 10; loc.Z = loc.Z + 10; player.SendMessage("Moved pigs"); Thread.Sleep(4000); foreach (var pig in pigs) { pig.KnownPosition = (PlayerLocation)loc.Clone(); pig.LastUpdatedTime = DateTime.UtcNow; } player.SendMessage("Moved ALL pigs"); }
public static PlayerLocation LookAt(Vector3 sourceLocation, Vector3 targetLocation) { var dx = targetLocation.X - sourceLocation.X; var dz = targetLocation.Z - sourceLocation.Z; var pos = new PlayerLocation(sourceLocation.X, sourceLocation.Y, sourceLocation.Z); if (dx > 0 || dz > 0) { double tanOutput = 90 - RadianToDegree(Math.Atan(dx / (dz))); double thetaOffset = 270d; if (dz < 0) { thetaOffset = 90; } var yaw = thetaOffset + tanOutput; double bDiff = Math.Sqrt((dx * dx) + (dz * dz)); var dy = (sourceLocation.Y) - (targetLocation.Y); double pitch = RadianToDegree(Math.Atan(dy / (bDiff))); pos.Yaw = (float)yaw; pos.HeadYaw = (float)yaw; pos.Pitch = (float)pitch; } return(pos); }
/// <inheritdoc /> public void SetLocation(CharacterKey key, int channelId, int mapId) { var location = new PlayerLocation(channelId, mapId); if (this.locations.ContainsKey(key)) { this.locations[key] = location; } else { this.locations.Add(key, location); } }
}; //used to get html friendly names to use in id fields, format: { (key) location, (value) { location name, first action, second action } #endregion Fields #region Constructors public ActionSpaceViewModel(string userName, Game game, PlayerLocation location) { Game = game; IsActivePlayer = FormHelper.IsActivePlayer(userName, game); IsValidSpace = ValidateSpace(game, location); Location = location; State = (GameActionState)Enum.Parse(typeof(GameActionState), location.ToString()); LocationName = HtmlNames[location][0]; FirstActionName = HtmlNames[location][1]; SecondActionName = HtmlNames[location][2]; Color = game.Players.First(p => p.UserName == userName).Color; SetGalleristColorClass(game, location); SetPushAndPullByLocation(location); }
private float GetDistanceFromMeTo(PlayerLocation target) { float lat1 = (float)Locator.Instance.GetLocation().latitude; float lat2 = (float)target.Latitude; float lon1 = (float)Locator.Instance.GetLocation().longitude; float lon2 = (float)target.Longitude; int R = 6371; // Radius of the earth in km float dLat = Mathf.Deg2Rad * (lat2-lat1); // deg2rad below float dLon = Mathf.Deg2Rad * (lon2-lon1); float a = Mathf.Sin(dLat/2) * Mathf.Sin(dLat/2) + Mathf.Cos(Mathf.Deg2Rad *(lat1)) * Mathf.Cos(Mathf.Deg2Rad * (lat2)) * Mathf.Sin(dLon/2) * Mathf.Sin(dLon/2) ; float c = 2 * Mathf.Atan2(Mathf.Sqrt(a), Mathf.Sqrt(1-a)); float d = R * c; // Distance in km return d; }
void ReadPlayerData() { float BossPosX = BossTransform.position.x; float PlyrPosX = PlyrTransform.position.x; float DistToPlayer = Mathf.Abs(BossPosX - PlyrPosX); // Calculate relative distance of Player from Boss. if (DistToPlayer <= TooNearDistance) { PlyrDist = PlayerDistance.TooNear; isBossAtSafeDist = false; } else if (DistToPlayer <= NearDistance) { PlyrDist = PlayerDistance.Near; if (ReadBlackBoard.BossBhvr == BossBehavior.Agressive) isBossAtSafeDist = true; else if (ReadBlackBoard.BossBhvr == BossBehavior.Defensive) isBossAtSafeDist = false; } else if (DistToPlayer > NearDistance + 0.5) { PlyrDist = PlayerDistance.Far; if (ReadBlackBoard.BossBhvr == BossBehavior.Agressive) isBossAtSafeDist = false; else if (ReadBlackBoard.BossBhvr == BossBehavior.Defensive) isBossAtSafeDist = true; } // Calculate which side from the boss the player is. if (BossPosX > PlyrPosX) PlyrLoc = PlayerLocation.LeftFromBoss; else PlyrLoc = PlayerLocation.RightFromBoss; // Checks if player is lined up with boss. if (Physics.Raycast(BossTransform.position, BossTransform.forward, out TargetInfo)) { if (TargetInfo.transform.tag == "Player") isPlyrLinedUp = true; else isPlyrLinedUp = false; } }
private void SetPushAndPullByLocation(PlayerLocation location) { Push = ""; Pull = ""; if (location == PlayerLocation.ArtistColony || location == PlayerLocation.MediaCenter) { Push = "col-xs-push-6"; Pull = "col-xs-pull-6"; } }
private void SetGalleristColorClass(Game game, PlayerLocation location) { var playerAtLocation = game.Players.FirstOrDefault(p => p.GalleristLocation == location); if (playerAtLocation != null) { GalleristColorClass = playerAtLocation.Color.ToString() + "-gallerist"; } else { GalleristColorClass = ""; } }
private bool ValidateSpace(Game game, PlayerLocation location) { var state = (GameActionState)Enum.Parse(typeof(GameActionState), location.ToString()); var action = new GameAction { State = state, Location = game.CurrentTurn.CurrentAction.Location }; var invoker = new ActionContextInvoker(game); return invoker.IsValidTransition(action); }