Example #1
0
 public void InitOtherPlayer(float x, float y, string dir)
 {
     OtherPlayers    = Instantiate <OtherPlayers>(OtherPlayersPrefab, new Vector3(x, y, 0), transform.rotation);
     OtherPlayers.gm = gameObject.GetComponent <GameManager>();
     OtherPlayers.Direction(dir);
     // players.Add(curPlayer);
 }
Example #2
0
 private void Victory(Player player)
 {
     if (gameOver)
     {
         return;
     }
     player.Gain(pot);
     GameControler.DisplayDealWon(player.Name, pot);
     if (OtherPlayers.All(p => p.Money <= 0 || p.PlayerStatus == PlayerStatus.OutGame))
     {
         Winner = player;
         GameControler.GameOver();
     }
 }
Example #3
0
        private void addPlayerRecord(RoleInGame self, RoleInGame other, ref List <string> msgsWithUrl)
        {
            if (self.Key == other.Key)
            {
                return;
            }
            if (self.othersContainsKey(other.Key))
            {
            }
            else
            {
                var otherPlayer = new OtherPlayers(self.Key, other.Key);
                //   otherPlayer.brokenParameterT1RecordChangedF = self.brokenParameterT1RecordChanged;
                self.othersAdd(other.Key, otherPlayer);
                //otherPlayer.setBrokenParameterT1Record(other.brokenParameterT1, ref msgsWithUrl);

                var fp = Program.dt.GetFpByIndex(other.StartFPIndex);
                // fromUrl = this._Players[getPosition.Key].FromUrl;
                if (self.playerType == RoleInGame.PlayerType.player)
                {
                    var webSocketID = ((Player)self).WebSocketID;
                    //var carsNames = other.ca;

                    //  var fp=  players[i].StartFPIndex
                    CommonClass.GetOthersPositionNotify_v2 notify = new CommonClass.GetOthersPositionNotify_v2()
                    {
                        c                 = "GetOthersPositionNotify_v2",
                        fp                = fp,
                        WebSocketID       = webSocketID,
                        key               = other.Key,
                        PlayerName        = other.PlayerName,
                        fPIndex           = other.StartFPIndex,
                        positionInStation = other.positionInStation,
                        isNPC             = other.playerType == RoleInGame.PlayerType.NPC,
                        isPlayer          = other.playerType == RoleInGame.PlayerType.player,
                        Level             = other.Level

                                            // var xx=  getPosition.Key
                    };
                    msgsWithUrl.Add(((Player)self).FromUrl);
                    msgsWithUrl.Add(Newtonsoft.Json.JsonConvert.SerializeObject(notify));
                }
            }
        }
Example #4
0
    /// <summary>
    /// Check the count of living players, if there is no player alive, reload the scene
    /// </summary>
    public IEnumerator CheckLivingPlayers()
    {
        if (!PhotonNetwork.offlineMode && localPlayer.IsDead)
        {
            yield return(new WaitForSeconds(2f));

            //TDS_UIManager.Instance.ResetUIManager();
            if (OtherPlayers.All(p => p.IsDead))
            {
                TDS_UIManager.Instance.StartCoroutine(TDS_UIManager.Instance.ResetInGameUI());
            }
            else if (OtherPlayers.Count > 0)
            {
                TDS_Camera.Instance.Target = OtherPlayers.Where(p => !p.IsDead).First().transform;
            }
            yield break;
        }
        else if (AllPlayers.All(p => p.IsDead))
        {
            TDS_UIManager.Instance.StartCoroutine(TDS_UIManager.Instance.ResetInGameUI());
        }
    }
        private void ReceiveAllPlayers(NetIncomingMessage inc)
        {
            var count = inc.ReadInt32();

            for (int n = 0; n < count; n++)
            {
                var player = new Player();
                inc.ReadAllProperties(player);
                if (player.Name == Player.Name)
                {
                    continue;
                }
                if (OtherPlayers.Any(p => p.Name == player.Name))
                {
                    var oldPlayer = OtherPlayers.FirstOrDefault(p => p.Name == player.Name);
                    oldPlayer._position.X = player._position.X;
                    oldPlayer._position.Y = player._position.Y;
                }
                else
                {
                    OtherPlayers.Add(player);
                }
            }
        }
        public void Update()
        {
            NetIncomingMessage inc;

            while ((inc = _client.ReadMessage()) != null)
            {
                if (inc.MessageType != NetIncomingMessageType.Data)
                {
                    continue;
                }
                var packageType = (PacketType)inc.ReadByte();
                switch (packageType)
                {
                case PacketType.AcceptedConnection:
                    break;

                case PacketType.Login:
                    if (inc.ReadBoolean())
                    {
                        Player.xPosition = inc.ReadFloat();
                        Player.yPosition = inc.ReadFloat();
                        ReceiveAllPlayers(inc);
                    }
                    break;

                //Recois un Packet de type nouveau joueur.
                case PacketType.NewPlayer:
                    //Créé l'instance du nouveau joueur
                    var player = new Player();
                    //Assigne les propriétés reçu au nouveau joueur
                    inc.ReadAllProperties(player);
                    //Si le nom du nouveau joueur est différent du nom du joueur alors on le rajoute à la liste
                    if (player.Name != Player.Name)
                    {
                        OtherPlayers.Add(player);
                    }
                    break;

                case PacketType.AllPlayers:
                    //Reçois tous les joueurs déjà présent.
                    ReceiveAllPlayers(inc);
                    break;

                case PacketType.Disconnected:
                    //Quand un joueur se déconnecte on lui envoie les propriétés du joueur déconnecté et on le supprime de la liste
                    var playerDc = new Player();
                    inc.ReadAllProperties(playerDc);
                    OtherPlayers.Remove(OtherPlayers.Find(x => x.Name == playerDc.Name));
                    break;

                case PacketType.Input:
                    var playerPos = new Player();
                    inc.ReadAllProperties(playerPos);
                    if (Player.Name == playerPos.Name)
                    {
                        Player._position.X = playerPos._position.X;
                        Player._position.Y = playerPos._position.Y;
                    }
                    else if (OtherPlayers.Count > 0)
                    {
                        try
                        {
                            OtherPlayers.Find(x => x.Name == playerPos.Name)._position.X = playerPos._position.X;
                            OtherPlayers.Find(y => y.Name == playerPos.Name)._position.Y = playerPos._position.Y;
                        }
                        catch
                        {
                        }
                    }
                    break;

                case PacketType.UPDATEPosition:
                    Fall();
                    break;

                default:
                    break;
                }
                //Fall();
            }
        }
Example #7
0
 private void Awake()
 {
     instance = this;
 }