Example #1
0
    }//on start of the object fill in all of the player data

    void Awake()
    {
        Data = new DbPlayer();
        info = Data.GetPlayerByUserName(PlayerPrefs.GetString("userName"));

        userName.text    = info.UserName;
        chipsAmount.text = info.Money.ToString();

        if (info.Money > 30000)
        {
            status.sprite = Status[4];
        }
        else
        if (info.Money < 30000 && info.Money > 20000)
        {
            status.sprite = Status[3];
        }
        else
        if (info.Money < 20000 && info.Money > 15000)
        {
            status.sprite = Status[2];
        }
        else
        if (info.Money < 15000 && info.Money > 5000)
        {
            status.sprite = Status[1];
        }
        else
        {
            status.sprite = Status[0];
        }

        playersImage.sprite = avatars[info.PlayerImage];
    }
Example #2
0
    public void LoginClick()//function that check the user name and the password after a user tries to Login
    {
        db = new DbPlayer();


        if (db.ExistUser(userName.text))
        {
            if (!db.isUserConnected(userName.text))
            {
                PlayerData info = db.GetPlayerByUserName(userName.text);

                if (info.Password == Password.text)
                {
                    PlayerPrefs.SetString("userName", info.UserName);
                    PlayerPrefs.SetInt("ImageOffset", info.PlayerImage);
                    PlayerPrefs.Save();
                    db.addUserConnection(info.UserName);

                    SceneManager.LoadScene("lobbytest");
                }
                else
                {
                    Errors.text = "Worng Password";
                }
            }
            else
            {
                Errors.text = "This User Allready Conntected";
            }
        }
        else
        {
            Errors.text = "User Dont Exist In The Data Base";
        }
    }
Example #3
0
    public void exitRoom()
    {
        buttonSound.Play();

        if (isServer && players.Count > 1)
        {
            return;
        }



        DbPlayer   db   = new DbPlayer();
        PlayerData Info = db.GetPlayerByUserName(localPlayer.playerPanel.userNameText.text);

        Info.Money += localPlayer.money;
        db.UpdatePlayer(Info);
        RemovePlayer(localPlayer);

        if (isServer)
        {
            LobbyScene.singleton.StopHost();
            Destroy(LobbyScene.singleton.gameObject);
            return;
        }


        if (isClient)
        {
            LobbyScene.singleton.StopClient();
            Destroy(localPlayer);
            return;
        }
    }//exit the room after saving the player new score in the data base to the lobby scene
Example #4
0
    }//a function that remove a player from the room

    public override void OnServerDisconnect(NetworkConnection conn)
    {
        foreach (var playerController in conn.playerControllers)
        {
            var player = playerController.gameObject.GetComponent <texasPlayer>();
            playerSlots[player.playerId] = null;
            PlayerData playerData = db.GetPlayerByUserName(player.name);
            playerData.Money = player.money;
            db.UpdatePlayer(playerData);
            RoomManager.singleton.RemovePlayer(player);
        }

        base.OnServerDisconnect(conn);
    }//a function for the case that server disconnect
Example #5
0
    public void exitRoom()
    {
        buttonSound.Play();
        DbRoom dbRoom = new DbRoom();
        Room   room   = dbRoom.getRoomInfo();

        if (isServer && players.Count > 1)
        {
            return;
        }



        DbPlayer   db   = new DbPlayer();
        PlayerData Info = db.GetPlayerByUserName(localPlayer.playerPanel.userNameText.text);

        Info.Money += localPlayer.money - 1000;
        db.UpdatePlayer(Info);
        RemovePlayer(localPlayer);
        room.amountOfPlayers--;
        dbRoom.UpdateRoom(room);



        if (isServer)
        {
            dbRoom.deleteRoom(room);
            NetworkManager.singleton.StopHost();
            RemovePlayer(localPlayer);
            //Destroy(LobbyScene.singleton.gameObject);
            NetworkManager.singleton.StopClient();
            Destroy(localPlayer);
            NetworkManager.Shutdown();
            //Debug.Log("after destroying the local player");
            return;
        }


        if (!isServer && isClient)
        {
            RemovePlayer(localPlayer);
            NetworkManager.singleton.StopClient();
            Destroy(localPlayer);
            return;
        }
    }//exit the room after saving the player new score in the data base to the lobby scene
Example #6
0
    public void ServerNextHand()//the Game restart
    {
        nextHandWaiting = true;
        MainPot         = 0;
        ServerClearHands();
        ServerEnterGameState(CardConstants.GameTurnState.ShufflingDeck, "Start Game", MainPot);


        if (localPlayer.money == 0)
        {
            DbPlayer   db   = new DbPlayer();
            PlayerData Info = db.GetPlayerByUserName(localPlayer.playerPanel.userNameText.text);
            localPlayer.money += 1000;
            Info.Money        -= 1000;
            db.UpdatePlayer(Info);
        }

        ServerNextState("ServerState_StartDeck");
    }//stating the game after show down function
Example #7
0
    // Use this for initialization
    void Start()
    {
        Data = new DbPlayer();
        info = Data.GetPlayerByUserName(PlayerPrefs.GetString("userName"));

        userName.text    = info.UserName;
        chipsAmount.text = info.Money.ToString();

        if (info.Status == "A")
        {
            status.sprite = Status[0];
        }

        if (info.Status == "B")
        {
            status.sprite = Status[1];
        }

        if (info.Status == "C")
        {
            status.sprite = Status[2];
        }

        if (info.Status == "D")
        {
            status.sprite = Status[3];
        }

        if (info.Status == "E")
        {
            status.sprite = Status[4];
        }


        playersImage.sprite = avatars[info.PlayerImage];
    }//on start of the object fill in all of the player data