Наследование: MonoBehaviour
 public static PlayerGameObject Factory(ServerGame game, RemotePlayer player)
 {
     PlayerGameObject obj = new PlayerGameObject(game.GameObjectCollection);
     game.GameObjectCollection.Add(obj);
     PlayerGameObject.ServerInitialize(obj, player.Id);
     return obj;
 }
 private void OnPlayerSitInCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     UserInfo userInfo = null;
     var c = (PlayerSitInCommand)command;
     if (p.Game.Params.Lobby.OptionType == LobbyTypeEnum.QuickMode)
         p.Player.MoneySafeAmnt = ((LobbyOptionsQuickMode) p.Game.Params.Lobby).StartingAmount;
     else
     {
         int money = c.MoneyAmount;
         userInfo = DataManager.Persistance.Get(p.Client.PlayerName);
         if (userInfo == null || userInfo.TotalMoney < money)
             p.Player.MoneySafeAmnt = -1;
         else
         {
             userInfo.TotalMoney -= money;
             p.Player.MoneySafeAmnt = money;
         }
     }
     var seat = p.Game.GameTable.SitIn(p.Player, c.NoSeat);
     if (seat == null)
     {
         client.SendCommand(c.ResponseFailure(BluffinMessageId.NoMoreSeats, "No seats available"));
         if (userInfo != null)
             userInfo.TotalMoney += p.Player.MoneySafeAmnt; 
     }
     else
     {
         var r = (seat.NoSeat != c.NoSeat) ? c.ResponseSuccess(BluffinMessageId.SeatChanged, "The asked seat wasn't available, the server gave you another one.") : c.ResponseSuccess();
         r.NoSeat = seat.NoSeat;
         client.SendCommand(r);
         p.Game.AfterPlayerSat(p.Player);
     }
 }
Пример #3
0
        public static void ExecuteCommand(RtsCommandMessage message, ServerGame game, RemotePlayer player)
        {
            int coID = message.ReadInt();

            Company obj = game.GameObjectCollection.Get<Company>(coID);
            if (player.Owns(obj))
            {
                obj.Destroy();
            }
        }
Пример #4
0
        public static void ExecuteCommand(RtsCommandMessage message, ServerGame game, RemotePlayer player)
        {
            int baseObjID = message.ReadInt();

            Base obj = game.GameObjectCollection.Get<Base>(baseObjID);
            if (player.Owns(obj))
            {
                obj.BuildTransportVehicle();
            }
        }
Пример #5
0
        public static void ExecuteCommand(RtsCommandMessage message, ServerGame game, RemotePlayer player)
        {
            int baseObjID = message.ReadInt();
            int coID = message.ReadInt();

            Base obj = game.GameObjectCollection.Get<Base>(baseObjID);
            Company co = game.GameObjectCollection.Get<Company>(coID);
            if (player.Owns(obj) && player.Owns(co))
            {
                co.ResupplyPoint = obj;
            }
        }
        public static void ExecuteCommand(RtsCommandMessage message, ServerGame game, RemotePlayer player)
        {
            int companyId = message.ReadInt();
            int vehicleId = message.ReadInt();

            Company co = game.GameObjectCollection.Get<Company>(companyId);
            CombatVehicle vic = game.GameObjectCollection.Get<CombatVehicle>(vehicleId);
            if (player.Owns(co) && player.Owns(co))
            {
                co.AddVehicle(vic);
            }
        }
Пример #7
0
        // Adds a client to the current clientlist. Returns true if the client is added, returns false if the clients are locked.
        private bool AddClient(RemotePlayer client)
        {
            bool added = false;
            clientsMutex.WaitOne();

            if (!clientsLocked)
            {
                clients.Add(client);
                added = true;
            }

            clientsMutex.ReleaseMutex();
            return added;
        }
Пример #8
0
        private void CreateStats(RemotePlayer remotePlayer, Canvas canvas)
        {
            GameObject originalBar = FindObjectOfType <uGUI_HealthBar>().gameObject;

            healthBar = CreateBar(originalBar, BarType.Health, canvas);

            originalBar = FindObjectOfType <uGUI_OxygenBar>().gameObject;
            oxygenBar   = CreateBar(originalBar, BarType.Oxygen, canvas);

            originalBar = FindObjectOfType <uGUI_FoodBar>().gameObject;
            foodBar     = CreateBar(originalBar, BarType.Food, canvas);

            originalBar = FindObjectOfType <uGUI_WaterBar>().gameObject;
            waterBar    = CreateBar(originalBar, BarType.Water, canvas);
        }
        void OnDisconnectCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
        {
            if (p.Game.Params.Lobby.OptionType == LobbyTypeEnum.RegisteredMode)
                DataManager.Persistance.Get(p.Client.PlayerName).TotalMoney += p.Player.MoneySafeAmnt;

            client.RemovePlayer(p);

            p.Player.State = PlayerStateEnum.Zombie;

            var t = p.Game.Table;
            LogManager.Log(LogLevel.Message, "BluffinGameWorker.OnDisconnectCommandReceived", "> Client '{0}' left table: {2}:{1}", p.Player.Name, t.Params.TableName, p.TableId);

            p.Game.LeaveGame(p.Player);
            
        }
Пример #10
0
        private void LogClientMessage(ChatMessage message)
        {
            Optional <RemotePlayer> remotePlayer = remotePlayerManager.Find(message.PlayerId);

            if (!remotePlayer.IsPresent())
            {
                string playerTableFormatted = string.Join("\n", remotePlayerManager.GetAll().Select(ply => $"Name: '{ply.PlayerName}', Id: {ply.PlayerId}"));
                throw new Exception($"Tried to add chat message for remote player that could not be found with id '${message.PlayerId}' and message: '{message.Text}'.\nAll remote players right now:\n{playerTableFormatted}");
            }

            RemotePlayer remotePlayerInstance = remotePlayer.Get();

            playerChat.AddMessage(remotePlayerInstance.PlayerName, message.Text, remotePlayerInstance.PlayerSettings.PlayerColor);
            playerChat.ShowLog();
        }
Пример #11
0
        private void OnVehiclePrefabLoaded(RemotePlayer player, GameObject prefab, string guid, Vector3 spawnPosition, Quaternion spawnRotation)
        {
            // Partially copied from SubConsoleCommand.OnSubPrefabLoaded
            GameObject gameObject = Utils.SpawnPrefabAt(prefab, null, spawnPosition);

            gameObject.transform.rotation = spawnRotation;
            gameObject.SetActive(true);
            gameObject.SendMessage("StartConstruction", SendMessageOptions.DontRequireReceiver);
            CrafterLogic.NotifyCraftEnd(gameObject, CraftData.GetTechType(gameObject));

            Rigidbody rigidBody = gameObject.GetComponent <Rigidbody>();

            rigidBody.isKinematic = false;

            GuidHelper.SetNewGuid(gameObject, guid);
        }
Пример #12
0
    // adds a remote player to establish a connection to, or accept a connection from
    public void AddRemotePlayer(RemotePlayer player)
    {
        if (!m_remotePlayers.ContainsKey(player.ID))
        {
            m_remotePlayers[player.ID]         = new RemotePlayerData();
            m_remotePlayers[player.ID].state   = PeerConnectionState.Unknown;
            m_remotePlayers [player.ID].player = player;

            // ID comparison is used to decide who Connects and who Accepts
            if (PlatformManager.MyID < player.ID)
            {
                Debug.Log("P2P Try Connect to: " + player.ID);
                Net.Connect(player.ID);
            }
        }
    }
Пример #13
0
        public void Build(RemotePlayer player)
        {
            GameObject signalBase = Object.Instantiate(Resources.Load("VFX/xSignal")) as GameObject;

            signalBase.name = "signal" + player.PlayerName;
            signalBase.transform.localScale     = new Vector3(.5f, .5f, .5f);
            signalBase.transform.localPosition += new Vector3(0, 0.8f, 0);
            signalBase.transform.SetParent(player.PlayerModel.transform, false);

            PingInstance ping = signalBase.GetComponent <PingInstance>();

            ping.SetLabel("Player " + player.PlayerName);
            ping.pingType = PingType.Signal;

            SetPingColor(player, ping);
        }
Пример #14
0
        /// <summary>
        /// Server - called when a client disconnects
        /// </summary>
        /// <param name="player"></param>
        public void OnClientDisconnected(RemotePlayer player)
        {
            Engine.ConsoleText(
                String.Format("{0} has disconnected", player.PlayerName),
                new Color4(1.0f, 1.0f, 0.0f, 0.0f));

            var entityToKill = Engine.Entities.FirstOrDefault(e => e.GetPlayerId() == player.ClientId);

            if (entityToKill == null)
            {
                return;
            }

            Engine.StopTrackingEntity(entityToKill);
            entityToKill.Destroy();
        }
Пример #15
0
        public PlayerBase CreateRemotePlayer(string remoteCharacterData)
        {
            //creates a remote player object
            //adds it to the lookup
            //creates its body
            //creates its group
            PlayerIDFlag ID           = PlayerIDFlag.Player01;                          //get remote ID
            RemotePlayer remotePlayer = gameObject.CreateChild(ID.ToString()).gameObject.AddComponent <RemotePlayer>();

            mPlayers.Add(ID, remotePlayer);
            remotePlayer.ID    = ID;
            remotePlayer.Group = WIGroups.GetOrAdd(ID.ToString(), WIGroups.Get.Player, remotePlayer);
            remotePlayer.Body  = Characters.Get.PlayerBody(remotePlayer);

            return(remotePlayer);
            //remote player will initialize itself after finding/creating all its parts
        }
Пример #16
0
    public void CreateRemotePlayer(BallColor color, PlayerID id)
    {
        RemotePlayer player = new RemotePlayer(color);

        if (id == PlayerID.Player1)
        {
            player.OnTurnFinished += GridManager.Instance.PlayerTurnEnded;
            players[0]             = player;
            UIManager.Instance.InitPlayer1(color);
        }
        else
        {
            player.OnTurnFinished += GridManager.Instance.PlayerTurnEnded;
            players[1]             = player;
            UIManager.Instance.InitPlayer2(color);
        }
    }
Пример #17
0
    void Awake()
    {
        name     = GameSetting.Instance.Bot.Name;
        _message = new MessageBroker();
        _route   = GameObject.Find("Position/Bot").transform;

        MessageBroker.Default.Receive <ResData>().Subscribe(x =>
        {
            if (GameConst.ResPlayerRemote == x.Type && x.Data != null)
            {
                var asset = x.Data.LoadAsset("RemoteBot");
                asset.SetParent(transform, false);
                _bot = asset.GetComponent <RemotePlayer>();
                _bot.Setup(_message, transform.position + Vector3.one * 0.0001f, transform.rotation);
            }
        }).AddTo(this);
    }
        public static void ExecuteCommand(RtsCommandMessage message, ServerGame game, RemotePlayer player)
        {
            int companyId = message.ReadInt();
            int positionCount = message.ReadInt();
            List<Vector2> positions = new List<Vector2>();

            for (int i = 0; i < positionCount; i++)
            {
                positions.Add(message.ReadVector2());
            }

            Company co = game.GameObjectCollection.Get<Company>(companyId);
            if (player.Owns(co))
            {
                co.SetPositions(game.GameObjectCollection, positions);
            }
        }
Пример #19
0
 public PlayerSnapshot(RemotePlayer player)
 {
     position               = player.transform.position;
     xMovement              = player.XMovement;
     zMovement              = player.ZMovement;
     rotation               = player.transform.rotation;
     mouseOrbitPosition     = player.MouseOrbit.transform.position;
     mouseOrbitrotation     = player.MouseOrbit.transform.rotation;
     mouseOrbitX            = player.MouseOrbit.x;
     mouseOrbitY            = player.MouseOrbit.y;
     equippedWeapon         = player.EquippedWeaponInfo.weaponName;
     isWeaponRaised         = player.IsWeaponRaised;
     isWeaponBlocking       = player.IsWeaponBlocking;
     lastAppliedCommandTime = player.lastAppliedCommandTime;
     hp             = player.hp;
     isDead         = player.isDead;
     hasSwingStruck = player.hasSwingStruck;
 }
Пример #20
0
 public PlayerSnapshot(RemotePlayer player)
 {
     position = player.transform.position;
     xMovement = player.XMovement;
     zMovement = player.ZMovement;
     rotation = player.transform.rotation;
     mouseOrbitPosition = player.MouseOrbit.transform.position;
     mouseOrbitrotation = player.MouseOrbit.transform.rotation;
     mouseOrbitX = player.MouseOrbit.x;
     mouseOrbitY = player.MouseOrbit.y;
     equippedWeapon = player.EquippedWeaponInfo.weaponName;
     isWeaponRaised = player.IsWeaponRaised;
     isWeaponBlocking = player.IsWeaponBlocking;
     lastAppliedCommandTime  = player.lastAppliedCommandTime;
     hp = player.hp;
     isDead = player.isDead;
     hasSwingStruck = player.hasSwingStruck;
 }
Пример #21
0
    void VoipStateChangedCallback(Message<NetworkingPeer> msg)
    {
        PlatformManager.LogOutput("Voip state to " + msg.Data.ID + " changed to  " + msg.Data.State):

        RemotePlayer remote = PlatformManager.GetRemoteUser(msg.Data.ID):
        if (remote != null)
        {
            remote.voipConnectionState = msg.Data.State:

            // ID comparison is used to decide who initiates and who gets the Callback
            if (msg.Data.State == PeerConnectionState.Timeout && PlatformManager.MyID < msg.Data.ID)
            {
                    // keep trying until hangup!
                    Voip.Start(msg.Data.ID):
                    PlatformManager.LogOutput("Voip re-connect to " + msg.Data.ID):
            }
        }
    }
Пример #22
0
        private void CreateRemotePlayers(List <InitialRemotePlayerData> remotePlayerData)
        {
            foreach (InitialRemotePlayerData playerData in remotePlayerData)
            {
                RemotePlayer player = remotePlayerManager.Create(playerData.PlayerContext);

                if (playerData.SubRootGuid.IsPresent())
                {
                    //TODO: require and run async after base pieces are loaded (similar to how items are added to inventories)
                    Optional <GameObject> sub = GuidHelper.GetObjectFrom(playerData.SubRootGuid.Get());

                    if (sub.IsPresent())
                    {
                        player.SetSubRoot(sub.Get().GetComponent <SubRoot>());
                    }
                }
            }
        }
Пример #23
0
    void ConnectionStateChangedCallback(Message<NetworkingPeer> msg)
    {
        PlatformManager.LogOutput("P2P state to " + msg.Data.ID + " changed to  " + msg.Data.State):

        RemotePlayer remote = PlatformManager.GetRemoteUser(msg.Data.ID):
        if (remote != null)
        {
            remote.p2pConnectionState = msg.Data.State:

            if (msg.Data.State == PeerConnectionState.Timeout &&
                // ID comparison is used to decide who calls Connect and who calls Accept
                PlatformManager.MyID < msg.Data.ID)
            {
                // keep trying until hangup!
                Net.Connect(msg.Data.ID):
                PlatformManager.LogOutput("P2P re-connect to " + msg.Data.ID):
            }
        }
    }
Пример #24
0
    //LocalPlayerPI player2;
    public NetworkGame()
    {
        BManager = GameObject.Find("PersistanceManager").GetComponent<BTManager>();

        player1 = new LocalPlayerPI ();
        player2 = new RemotePlayer ();
        //player2 = new LocalPlayerPI ();

        if(BTManager.isServer){
            player1.isAttackerPlayer = false;
            player2.isAttackerPlayer = true;
            currentPlayer = player2;
        }
        else{
            player1.isAttackerPlayer = true;
            player2.isAttackerPlayer = false;
            currentPlayer = player1;
        }
    }
Пример #25
0
    public static void AddRemoteUser(ulong userID)
    {
        RemotePlayer remoteUser = new RemotePlayer();

        remoteUser.RemoteAvatar = Instantiate(s_instance.remoteAvatarPrefab);
        remoteUser.RemoteAvatar.oculusUserID               = userID.ToString();
        remoteUser.RemoteAvatar.ShowThirdPerson            = true;
        remoteUser.RemoteAvatar.EnableMouthVertexAnimation = true;
        remoteUser.p2pConnectionState  = PeerConnectionState.Unknown;
        remoteUser.voipConnectionState = PeerConnectionState.Unknown;
        remoteUser.stillInRoom         = true;
        remoteUser.remoteUserID        = userID;

        s_instance.AddUser(userID, ref remoteUser);
        s_instance.p2pManager.ConnectTo(userID);
        s_instance.voipManager.ConnectTo(userID);

        s_instance.LogOutputLine("Adding User " + userID);
    }
Пример #26
0
        public void PlayerLevelUp(RemotePlayer remotePlayer, int newLevel)
        {
            var levelUpMessage = new ServerPlayerLevelUpMessage
            {
                RemotePlayer = remotePlayer,
                NewLevel     = newLevel
            };

            _gameServer.Engine.SendMessage(levelUpMessage);

            var entity = _gameServer.GetEntityForRemotePlayer(remotePlayer);

            var maxHealth        = entity.GetMaxHealth();
            var newMaxHealth     = GetNewMaxHealth(newLevel);
            var healthDifference = newMaxHealth - maxHealth;

            entity.SetMaxHealth(newMaxHealth);
            entity.SetHealth(entity.GetHealth() + healthDifference);
        }
Пример #27
0
        private void PlayerDisconnected(IMessage message)
        {
            string name = GetPlayerContext(message.Connection.Id)?.Name;

            if (name == null)
            {
                m_Logger.Log(LogLevel.Error, "No session found for " + message.Connection.Id);
            }

            RemotePlayer p = new RemotePlayer()
            {
                Name      = name,
                Id        = message.Connection.Id,
                Connected = false
            };

            Packet packet = new Packet(PacketType.RemotePlayer, p);

            m_Server.SendAll(packet.SerializePacket(), null, DeliveryMethod.ReliableOrdered, (int)MessageChannel.Chat);
        }
Пример #28
0
        private void CreateVehicleAt(RemotePlayer player, TechType techType, string guid, Vector3 position, Quaternion rotation)
        {
            if (techType == TechType.Cyclops)
            {
                LightmappedPrefabs.main.RequestScenePrefab("cyclops", (go) => OnVehiclePrefabLoaded(player, go, guid, position, rotation));
            }
            else
            {
                GameObject techPrefab = CraftData.GetPrefabForTechType(techType, false);

                if (techPrefab != null)
                {
                    OnVehiclePrefabLoaded(player, techPrefab, guid, position, rotation);
                }
                else
                {
                    Log.Error("No prefab for tech type: " + techType);
                }
            }
        }
Пример #29
0
        private void SendUpdate(ItemSpec spec, RemotePlayer target = null)
        {
            if (spec == null)
            {
                return;
            }

            var msg = new ServerItemSpecMessage {
                ItemSpec = spec
            };

            if (target == null)
            {
                _engine.SendMessage(msg);
            }
            else
            {
                _engine.SendMessageToClient(msg, target);
            }
        }
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            int remotePlayersSynced = 0;

            foreach (InitialRemotePlayerData playerData in packet.RemotePlayerData)
            {
                waitScreenItem.SetProgress(remotePlayersSynced, packet.RemotePlayerData.Count);

                List <TechType> equippedTechTypes = playerData.EquippedTechTypes.Select(techType => techType.ToUnity()).ToList();

                RemotePlayer player = remotePlayerManager.Create(playerData.PlayerContext, playerData.SubRootId, equippedTechTypes, new List <Pickupable>());

                if (!IsSwimming(playerData.Position.ToUnity(), playerData.SubRootId))
                {
                    player.UpdateAnimation(AnimChangeType.UNDERWATER, AnimChangeState.OFF);
                }
                remotePlayersSynced++;
                yield return(null);
            }
        }
Пример #31
0
        private void OnJoinTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c    = (JoinTableCommand)command;
            var game = (PokerGame)Lobby.GetGame(c.TableId);

            if (game == null || !game.IsRunning)
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.WrongTableState, "You can't join a game that isn't running !"));
                return;
            }
            var table = game.Table;

            if (table.Seats.Players().ContainsPlayerNamed(client.PlayerName))
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.NameAlreadyUsed, "Someone with your name is already in this game !"));
                return;
            }
            var rp = new RemotePlayer(game, new PlayerInfo(client.PlayerName, 0), client, c.TableId);

            if (!rp.JoinGame())
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            Logger.LogInformation("> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);


            var r = c.ResponseSuccess();

            r.GameHasStarted = rp.Game.IsPlaying;
            //r.BoardCards = rp.Game.Table.Cards.Select(x => x.ToString()).ToArray();
            r.Seats  = rp.AllSeats().ToList();
            r.Params = rp.Game.Table.Params;
            //r.TotalPotAmount = rp.Game.Table.Bank.MoneyAmount;
            //r.PotsAmount = rp.Game.Table.Bank.PotAmountsPadded(rp.Game.Table.Params.MaxPlayers).ToList();

            client.SendCommand(r);
        }
Пример #32
0
    private void MSG_players(JSONObject message)
    {
        JSONArray           players           = message ["players"].AsArray;
        List <RemotePlayer> remotePlayersCopy = new List <RemotePlayer> (remotePlayers);

        foreach (JSONObject player in players)
        {
            RemotePlayer playerInstance = remotePlayersCopy.Find(x => x.name == player ["name"].AsString);
            if (playerInstance == null)
            {
                playerInstance = ObjectPool.instance.GetInstance <RemotePlayer> ().GetComponent <RemotePlayer>();
                playerInstance.SetName(player ["name"].AsString);
                remotePlayers.Add(playerInstance);
            }
            remotePlayersCopy.Remove(playerInstance);
            playerInstance.SetPosition(new Vector3(player["x"].AsFloat, playerInstance.transform.position.y, player["y"].AsFloat));
            playerInstance.SetHealth(player ["health"].AsInt);
            playerInstance.SetRotation(player ["rotation"].AsFloat);
        }
        remotePlayersCopy.ForEach((x) => x.Kill());
    }
        public override void Process(InitialPlayerSync packet)
        {
            foreach (InitialRemotePlayerData playerData in packet.RemotePlayerData)
            {
                RemotePlayer player = remotePlayerManager.Create(playerData.PlayerContext, playerData.EquippedTechTypes);

                if (playerData.SubRootGuid.IsPresent())
                {
                    Optional <GameObject> sub = GuidHelper.GetObjectFrom(playerData.SubRootGuid.Get());

                    if (sub.IsPresent())
                    {
                        player.SetSubRoot(sub.Get().GetComponent <SubRoot>());
                    }
                    else
                    {
                        Log.Error("Could not spawn remote player into subroot with guid: " + playerData.SubRootGuid.Get());
                    }
                }
            }
        }
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            int remotePlayersSynced = 0;

            foreach (InitialRemotePlayerData playerData in packet.RemotePlayerData)
            {
                waitScreenItem.SetProgress(remotePlayersSynced, packet.RemotePlayerData.Count);

                List <TechType> equippedTechTypes = playerData.EquippedTechTypes.Select(techType => techType.ToUnity()).ToList();
                RemotePlayer    player            = remotePlayerManager.Create(playerData.PlayerContext, equippedTechTypes);

                if (playerData.SubRootId.HasValue)
                {
                    Optional <GameObject> sub = NitroxEntity.GetObjectFrom(playerData.SubRootId.Value);

                    if (sub.HasValue)
                    {
                        Log.Debug($"sub value set to {sub.Value}. Try to find subroot");
                        SubRoot subroot = null;
                        sub.Value.TryGetComponent <SubRoot>(out subroot);
                        if (subroot)
                        {
                            Log.Debug("Found subroot for player. Will add him and update animation.");
                            player.SetSubRoot(subroot);
                        }
                    }
                    else
                    {
                        Log.Error("Could not spawn remote player into subroot/escape pod with id: " + playerData.SubRootId.Value);
                    }
                }

                if (!IsSwimming(playerData.Position.ToUnity(), playerData.SubRootId))
                {
                    player.UpdateAnimation(AnimChangeType.UNDERWATER, AnimChangeState.OFF);
                }
                remotePlayersSynced++;
                yield return(null);
            }
        }
Пример #35
0
        public SkinEntry(LoadedSkin skin, PooledTexture2D texture2D, Action <SkinEntry> onDoubleClick)
        {
            Skin          = skin;
            OnDoubleClick = onDoubleClick;

            MinWidth  = 92;
            MaxWidth  = 92;
            MinHeight = 128;
            MaxHeight = 128;

            // AutoSizeMode = AutoSizeMode.GrowOnly;

            AddChild(
                new GuiTextElement()
            {
                Text = skin.Name, Margin = Thickness.Zero, Anchor = Alignment.TopCenter, Enabled = false
            });

            Margin = new Thickness(0, 8);
            Anchor = Alignment.FillY;
            // AutoSizeMode = AutoSizeMode.GrowAndShrink;
            // BackgroundOverlay = new GuiTexture2D(GuiTextures.OptionsBackground);

            var mob = new RemotePlayer(skin.Name, null, null, texture2D);

            mob.ModelRenderer = new EntityModelRenderer(skin.Model, texture2D);

            ModelView = new GuiEntityModelView(mob) /*"geometry.humanoid.customSlim"*/
            {
                BackgroundOverlay = new Color(Color.Black, 0.15f),
                Background        = null,
                //   Margin = new Thickness(15, 15, 5, 40),

                Width  = 92,
                Height = 128,
                Anchor = Alignment.Fill,
            };

            AddChild(ModelView);
        }
Пример #36
0
        private void readNewJuggernaut() //Reads in who should be the new juggernaut.
        {
            string tag = reader.ReadString();

            Global.msgNewJuggernaut(tag); //Fires off a message to the message displayer unit.
            NetworkGamer gamer = findGamerWithTag(tag);

            if (gamer.IsLocal)
            {
                LocalPlayer player = gamer.Tag as LocalPlayer;
                player.setAsJuggernaut();
                for (int i = 0; i < Global.localPlayers.Count; i++)
                {
                    if (Global.localPlayers[i] != player)
                    {
                        Global.localPlayers[i].setAsNotJuggernaut();
                    }
                }
                for (int i = 0; i < Global.remotePlayers.Count; i++)
                {
                    Global.remotePlayers[i].setAsNotJuggernaut();
                }
            }
            else
            {
                RemotePlayer rPlayer = gamer.Tag as RemotePlayer;
                rPlayer.setAsJuggernaut();
                for (int i = 0; i < Global.localPlayers.Count; i++)
                {
                    Global.localPlayers[i].setAsNotJuggernaut();
                }
                for (int i = 0; i < Global.remotePlayers.Count; i++) //Loop for all remotes except the juggernaut
                {
                    if (Global.remotePlayers[i] != rPlayer)
                    {
                        Global.remotePlayers[i].setAsNotJuggernaut();
                    }
                }
            }
        }
Пример #37
0
 void GameStartedEventHandler(object sender, GameStartedEventArgs e)
 {
     if (hostSessionType == HostSessionType.Host)
     {
         int          firstJugIndex = Global.rand.Next(0, Global.networkManager.networkSession.AllGamers.Count);
         NetworkGamer firstJug      = networkSession.AllGamers[firstJugIndex];
         newJuggernaut(firstJug);
         if (firstJug.IsLocal)
         {
             LocalPlayer player = firstJug.Tag as LocalPlayer;
             player.setAsJuggernaut();
         }
         else
         {
             RemotePlayer player = firstJug.Tag as RemotePlayer;
             player.setAsJuggernaut();
         }
     }
     Global.gameState = Global.GameState.Playing;
     Global.menusong.Stop();
     Global.actionsong.Play();
 }
Пример #38
0
        public override void Process(InitialPlayerSync packet)
        {
            foreach (InitialRemotePlayerData playerData in packet.RemotePlayerData)
            {
                List <TechType> equippedTechTypes = playerData.EquippedTechTypes.Select(techType => techType.Enum()).ToList();
                RemotePlayer    player            = remotePlayerManager.Create(playerData.PlayerContext, equippedTechTypes);

                if (playerData.SubRootId.IsPresent())
                {
                    Optional <GameObject> sub = NitroxIdentifier.GetObjectFrom(playerData.SubRootId.Get());

                    if (sub.IsPresent())
                    {
                        player.SetSubRoot(sub.Get().GetComponent <SubRoot>());
                    }
                    else
                    {
                        Log.Error("Could not spawn remote player into subroot with id: " + playerData.SubRootId.Get());
                    }
                }
            }
        }
Пример #39
0
        private void StartVehicleUndocking(VehicleUndocking packet, GameObject vehicleGo, Vehicle vehicle, VehicleDockingBay vehicleDockingBay)
        {
            Optional <RemotePlayer> player = remotePlayerManager.Find(packet.PlayerId);

            vehicleDockingBay.subRoot.BroadcastMessage("OnLaunchBayOpening", SendMessageOptions.DontRequireReceiver);
            SkyEnvironmentChanged.Broadcast(vehicleGo, (GameObject)null);

            if (player.HasValue)
            {
                RemotePlayer playerInstance = player.Value;
                vehicle.mainAnimator.SetBool("player_in", true);
                playerInstance.Attach(vehicle.playerPosition.transform);
                // It can happen that the player turns in circles around himself in the vehicle. This stops it.
                playerInstance.RigidBody.angularVelocity = Vector3.zero;
                playerInstance.ArmsController.SetWorldIKTarget(vehicle.leftHandPlug, vehicle.rightHandPlug);
                playerInstance.AnimationController["in_seamoth"] = vehicle is SeaMoth;
                playerInstance.AnimationController["in_exosuit"] = playerInstance.AnimationController["using_mechsuit"] = vehicle is Exosuit;
                vehicles.SetOnPilotMode(packet.VehicleId, packet.PlayerId, true);
                playerInstance.AnimationController.UpdatePlayerAnimations = false;
            }
            vehicleDockingBay.StartCoroutine(StartUndockingAnimation(vehicleDockingBay));
        }
Пример #40
0
    public static void AddRemoteUser(ulong userID)
    {
        RemotePlayer remoteUser = new RemotePlayer();

        remoteUser.RemoteAvatar = Instantiate(s_instance.remoteAvatarPrefab);
        remoteUser.RemoteAvatar.oculusUserID    = userID.ToString();
        remoteUser.RemoteAvatar.ShowThirdPerson = true;
        remoteUser.p2pConnectionState           = PeerConnectionState.Unknown;
        remoteUser.voipConnectionState          = PeerConnectionState.Unknown;
        remoteUser.stillInRoom  = true;
        remoteUser.remoteUserID = userID;

        s_instance.AddUser(userID, ref remoteUser);
        s_instance.p2pManager.ConnectTo(userID);
        s_instance.voipManager.ConnectTo(userID);

        var audioSource = remoteUser.RemoteAvatar.gameObject.AddComponent <VoipAudioSourceHiLevel>();

        audioSource.senderID = userID;

        s_instance.LogOutputLine("Adding User " + userID);
    }
            public void CreateRemotePlayers(object sender, EventArgs eventArgs)
            {
                ThrottledBuilder.main.QueueDrained -= CreateRemotePlayers;

                foreach (InitialRemotePlayerData playerData in remotePlayerData)
                {
                    RemotePlayer player = remotePlayerManager.Create(playerData.PlayerContext);

                    if (playerData.SubRootGuid.IsPresent())
                    {
                        Optional <GameObject> sub = GuidHelper.GetObjectFrom(playerData.SubRootGuid.Get());

                        if (sub.IsPresent())
                        {
                            player.SetSubRoot(sub.Get().GetComponent <SubRoot>());
                        }
                        else
                        {
                            Log.Error("Could not spawn remote player into subroot with guid: " + playerData.SubRootGuid.Get());
                        }
                    }
                }
            }
Пример #42
0
    public void AddPlayer(RemotePlayer player, bool occupyEmptySlot)
    {
        uniqueIDtoPlayer.Add(player.UniqueID, player);

        OnPlayerAdded(player);

        if (occupyEmptySlot)
        {
            for (int i = 0; i < slots.Count; ++i)
            {
                if (slots[i] == null)
                {
                    MovePlayerToSlot(player, i);
                    break;
                }
            }
        }
    }
Пример #43
0
 public void RemovePlayer(RemotePlayer p)
 {
     throw new NotImplementedException();
 }
Пример #44
0
 private void OnPlayerStatusChanged(RemotePlayer player)
 {
     NetOutgoingMessage msg = CreateMessage(eServerToClientMessage.PlayerSetStatus);
     msg.Write(player.UniqueID);
     msg.Write((byte)player.Status);
     server.SendToAll(msg, null, NetDeliveryMethod.ReliableOrdered, 0);
 }
Пример #45
0
    private void HandlePlayerJoined(NetIncomingMessage msg)
    {
        long id = msg.ReadInt64();
        string name = msg.ReadString();
        RemotePlayerStatus status = (RemotePlayerStatus)msg.ReadByte();

        RemotePlayer player = new RemotePlayer(id, name);
        Players.AddPlayer(new RemotePlayer(id, name), false);
        Players.SetStatus(player, status);

        chatHandler(string.Format("{0} joined...", name));
    }
Пример #46
0
    public void SetStatus(RemotePlayer player, RemotePlayerStatus status)
    {
        player.Status = status;

        OnPlayerStatusChanged(player);
    }
Пример #47
0
    private void OnPlayerAdded(RemotePlayer player)
    {
        // Nofity everyone the player was added
        NetOutgoingMessage msg = CreateMessage(eServerToClientMessage.PlayerJoined);
        msg.Write(player.UniqueID);
        msg.Write(player.PlayerName);
        msg.Write((byte)player.Status);
        server.SendToAll(msg, null, NetDeliveryMethod.ReliableOrdered, 0);

        LobbySettingsChanged();
    }
Пример #48
0
    private void OnPlayerSetSlot(RemotePlayer player)
    {
        // Notify all players on slot assignement change
        NetOutgoingMessage msg = CreateMessage(eServerToClientMessage.PlayerSetSlot);
        msg.Write(player.UniqueID);
        msg.Write(player.PlayerSlot);
        server.SendToAll(msg, null, NetDeliveryMethod.ReliableOrdered, 0);

        LobbySettingsChanged();
    }
Пример #49
0
    private void SendChatMessageToAll(RemotePlayer sender, string message)
    {
        if (string.IsNullOrEmpty(message))
            return;

        if (server.ConnectionsCount == 0)
            return;

        NetOutgoingMessage msg = CreateMessage(eServerToClientMessage.Chat);
        if (sender == null)
            msg.Write((long)0);
        else
            msg.Write(sender.UniqueID);

        msg.Write(message);
        server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableOrdered, 0);
    }
Пример #50
0
    public void MovePlayerToSlot(RemotePlayer player, int targetSlot)
    {
        // Target slot is already occupied
        if (targetSlot >= 0 && slots[targetSlot] != null)
        {
            return;
        }

        // Already in a slot
        if (player.PlayerSlot >= 0)
        {
            slots[player.PlayerSlot] = null;
        }

        player.PlayerSlot = targetSlot;

        // Occupy new slot
        if (player.PlayerSlot >= 0)
        {
            slots[player.PlayerSlot] = player;
        }

        OnPlayerSetSlot(player);
    }
Пример #51
0
    public void RemovePlayer(RemotePlayer player)
    {
        MovePlayerToSlot(player, -1);

        uniqueIDtoPlayer.Remove(player.UniqueID);

        OnPlayerRemoved(player);
    }
 private void OnPlayerSitOutCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     var c = (PlayerSitOutCommand)command;
     client.SendCommand(c.ResponseSuccess());
     p.Game.SitOut(p.Player);
 }
Пример #53
0
 public static void ExecuteCommand(RtsCommandMessage message, ServerGame game, RemotePlayer player)
 {
     player.GameObject.AddCompany(game);
 }
 private void OnPlayerPlayMoneyCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     var c = (PlayerPlayMoneyCommand)command;
     p.Game.PlayMoney(p.Player, c.Played);
 }
Пример #55
0
    private void HandleSessionInit(NetIncomingMessage msg)
    {
        int slots = msg.ReadInt32();
        Players.SetNumSlots(slots);

        int numconnected = msg.ReadInt32();
        for (int i = 0; i < numconnected; ++i)
        {
            long uniqueID = msg.ReadInt64();
            string name = msg.ReadString();
            int slot = msg.ReadInt32();
            RemotePlayerStatus status = (RemotePlayerStatus)msg.ReadByte();

            RemotePlayer player = new RemotePlayer(uniqueID, name);

            Players.AddPlayer(player, false);
            Players.MovePlayerToSlot(player, slot);
            Players.SetStatus(player, status);
        }
    }
Пример #56
0
 public void SetPlayerInControll(RemotePlayer player)
 {
     if (player == null)
     {
         controllingPlayer.Value = null;
     }
     else
     {
         controllingPlayer.Value = player.GameObject;
     }
 }
Пример #57
0
 public void SetRemotePlayerData(RemotePlayer data1, RemotePlayerDetail data2)
 {
     if (data1 == null || data2 == null)
     {
         Debug.LogError(new object[]
         {
             "data1 == null || data2 == null"
         });
         return;
     }
     this.ClearRemotePlayerData();
     this.remoteID = data1.GUID;
     this.remoteName = data1.Name;
     this.remoteLevel = data1.Level;
     this.remoteFurther = data1.FurtherLevel;
     this.remoteAwake = data1.AwakeLevel;
     this.remoteAwakeItemFlag = data1.AwakeItemFlag;
     this.remoteVipLevel = data1.VipLevel;
     this.remoteGender = data1.Gender;
     this.remoteConstellationLevel = data1.ConstellationLevel;
     this.remoteFashionLevel = data2.FashionLevel;
     if (data2.Lopet != null && data2.Lopet.InfoID != 0)
     {
         LopetInfo info = Globals.Instance.AttDB.LopetDict.GetInfo(data2.Lopet.InfoID);
         if (info == null)
         {
             Debug.LogErrorFormat("LopetDict.GetInfo error, id = {0}", new object[]
             {
                 data2.Lopet.InfoID
             });
             return;
         }
         this.remoteLopet = new LopetDataEx(data2.Lopet, info);
     }
     PlayerPetInfo.Info2.Name = this.remoteName;
     PlayerPetInfo.Info2.Quality = this.GetRemoteQuality();
     PlayerPetInfo.Info2.Type = this.remoteGender;
     PetData petData = new PetData();
     if (petData == null)
     {
         Debug.LogError(new object[]
         {
             "new PetData error"
         });
         return;
     }
     petData.ID = 0uL;
     petData.InfoID = 90001;
     petData.Level = (uint)this.remoteLevel;
     petData.Further = (uint)this.remoteFurther;
     petData.Awake = (uint)this.remoteAwake;
     petData.ItemFlag = (uint)this.remoteAwakeItemFlag;
     data2.Pets.Add(petData);
     for (int i = 0; i < data2.Pets.Count; i++)
     {
         int num = (int)data2.Pets[i].ID;
         if (num >= 4)
         {
             num -= 4;
             if (num >= 6)
             {
                 Debug.LogErrorFormat("remote assist pet slot error, slot = {0}", new object[]
                 {
                     num
                 });
             }
             else
             {
                 PetInfo info2 = Globals.Instance.AttDB.PetDict.GetInfo(data2.Pets[i].InfoID);
                 if (info2 == null)
                 {
                     Debug.LogErrorFormat("PetDict.GetInfo error, id = {0}", new object[]
                     {
                         data2.Pets[i].InfoID
                     });
                 }
                 else
                 {
                     this.remoteAssistPets[num] = new PetDataEx(data2.Pets[i], info2);
                 }
             }
         }
     }
     int fashionID = data1.FashionID;
     for (int j = 0; j < 4; j++)
     {
         this.remoteSockets[j] = new SocketDataEx();
         if (this.remoteSockets[j] == null)
         {
             Debug.LogError(new object[]
             {
                 "allocate SocketDataEx error!"
             });
         }
         else
         {
             this.remoteSockets[j].Init(j, (j != 0) ? 0 : fashionID, data2);
         }
     }
     this.UpdateRemoteCombatValue();
 }
Пример #58
0
 public void SetPillageTargetID(ulong id)
 {
     this.targetData = null;
     if (this.PillageTargets == null)
     {
         return;
     }
     for (int i = 0; i < this.PillageTargets.Count; i++)
     {
         if (this.PillageTargets[i].Data.GUID == id)
         {
             this.targetData = this.PillageTargets[i].Data;
             return;
         }
     }
 }
Пример #59
0
    private void HandlePlayerConnected(NetConnection connection)
    {
        string name = connection.RemoteHailMessage.ReadString();

        if (Players.ConnectedCount >= MaxNumConnectedClients)
        {
            connection.Disconnect("Server is full");
            Log(string.Format("player connection attempt by {0}{1} rejected, server full", name, NetUtility.ToHexString(connection.RemoteUniqueIdentifier)));
            return;
        }

        if(currentGameMode != null && currentGameMode.AllowJoinInProgress == false)
        {
            connection.Disconnect("Cannot connect to game already in progress");
            Log(string.Format("player connection attempt by {0}{1} rejected, gamemode in progress", name, NetUtility.ToHexString(connection.RemoteUniqueIdentifier)));
            return;
        }

        RemotePlayer player = new RemotePlayer(connection.RemoteUniqueIdentifier, name);

        NetOutgoingMessage msg = CreateMessage(eServerToClientMessage.SessionInit);
        msg.Write(Players.SlotsCount);
        msg.Write(Players.ConnectedCount);
        foreach (RemotePlayer connectedPlayer in Players.ConnectedPlayers)
        {
            msg.Write(connectedPlayer.UniqueID);
            msg.Write(connectedPlayer.PlayerName);
            msg.Write(connectedPlayer.PlayerSlot);
            msg.Write((byte)connectedPlayer.Status);
        }
        server.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered, 0);

        // Add player and try to default assign a slot
        Players.AddPlayer(player, true);

        Log(string.Format("player ({0} {1}) joined, slot {2}", name, NetUtility.ToHexString(connection.RemoteUniqueIdentifier), player.PlayerSlot));
    }
 private void OnCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     LogManager.Log(LogLevel.MessageVeryLow, "BluffinGameWorker.OnCommandReceived", "GameWorker RECV from {0} [{1}]", client.PlayerName, command.Encode());
     LogManager.Log(LogLevel.MessageVeryLow, "BluffinGameWorker.OnCommandReceived", "-------------------------------------------");
 }