Пример #1
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(instance);
     }
     instance = this;
 }
        public void OnClientEvent(Client player, string eventName, params object[] arguments)
        {
            if (eventName.Equals("onClientStartLogin"))
            {
                string password = (string)arguments[0];

                MySqlCommand doesPlayerExistInDb = TTRPG.Mysql.Conn.CreateCommand();

                doesPlayerExistInDb.CommandText = "SELECT * FROM user WHERE Nickname = @nickname";
                doesPlayerExistInDb.Parameters.AddWithValue("@nickname", player.name);

                DataTable result = new DataTable();

                result.Load(doesPlayerExistInDb.ExecuteReader());

                string salt       = (string)result.Rows[0]["Salt"];
                string dbPassword = (string)result.Rows[0]["Password"];

                if (PasswordHelper.Hash(password, salt).Equals(dbPassword))
                {
                    // Password was correct and now Update fingerprint and last login
                    // before starting Login process
                    if (!DevServer.CheckDevServerLogin(player, result.Rows[0]))
                    {
                        MySqlCommand updateUserEntryCommand = TTRPG.Mysql.Conn.CreateCommand();
                        updateUserEntryCommand.CommandText =
                            "UPDATE user SET Last_Fingerprint = @fingerprint, Last_Login=current_timestamp() WHERE Nickname=@nickname";
                        updateUserEntryCommand.Parameters.AddWithValue("fingerprint",
                                                                       player.getSyncedData("fingerprint"));
                        updateUserEntryCommand.Parameters.AddWithValue("nickname", player.name);

                        updateUserEntryCommand.ExecuteNonQuery();

                        EnsureAllDatabaseTableEntries((Int32)result.Rows[0]["ID"]);
                        StartLoginProcess(player, result.Rows[0]);

                        player.setSyncedData("loggedin", true);
                        API.consoleOutput("Account " + player.name + "(" + player.getSyncedData("ID") + ") logged in.");
                        player.invincible = false;
                        PlayerSpawnManager.Spawn(player);

                        TTRPG.Api.exported.scoreboard.setPlayerScoreboardData(player, "ID", result.Rows[0]["ID"].ToString());
                        TTRPG.Api.exported.scoreboard.setPlayerScoreboardData(player, "Nickname", player.name);

                        MoneyManager.RefreshPlayerMoneyDisplay(player);
                        RpLevelManager.CalculateAndSetLevelOfPlayer(player);
                        RpLevelManager.RefreshPlayerRpAndLevelDisplay(player);
                        UpdatePlayerPlayTime.UpdatePlayerPlayTimeDisplay(player);
                    }
                }
                else
                {
                    player.sendNotification("System-Error", "Das Passwort, dass du eingegeben hast, ist fehlerhaft.",
                                            false);
                    player.triggerEvent("startLogin", player.name);
                }
            }
        }
Пример #3
0
 private void Awake()
 {
     if (singleton == null)
     {
         singleton = this;
     }
     else if (singleton != this)
     {
         Destroy(gameObject);
     }
 }
Пример #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Пример #5
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(instance);
         instance = this;
     }
 }
Пример #6
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }


        SpawnPlayers();
    }
Пример #7
0
    public void OnEndDrag(PointerEventData _eventData)
    {
        GameObject.Find("AuthorizedDropZone").GetComponent <SpriteRenderer>().enabled = false;
        if (m_available == false)
        {
            return;
        }

        if (m_spawnManager == null)
        {
            m_spawnManager = new List <PlayerSpawnManager>(Component.FindObjectsOfType <PlayerSpawnManager>())
            {
            }
        }
Пример #8
0
    // Start is called before the first frame update
    void Start()
    {
        playerHUDContainer  = GameObject.Find("PlayerHUDs");
        playerHUDRContainer = GameObject.Find("PlayerHUDsR");
        playerManager       = GameObject.Find("PlayerManager");
        playerSpawnManager  = playerManager.GetComponent <PlayerSpawnManager>();

        for (int i = 0; i < playerSpawnManager.GetPlayerCount(); i++)
        {
            GameObject playerHUD = Resources.Load <GameObject>("UI/PlayerHUDBox");
            playerHUD.GetComponent <HUDBoxPlayerTracker>().player = playerSpawnManager.GetPlayer(i);
            if (playerSpawnManager.GetPlayer(i).GetComponent <InputToIntent>().team == 1)
            {
                Instantiate(playerHUD, playerHUDContainer.transform);
            }
            else
            {
                Instantiate(playerHUD, playerHUDRContainer.transform);
            }
        }
    }
Пример #9
0
    public void BeginGame(string _matchID)
    {
        // Spawn in GameManager;
        GameObject newSpawnManager = Instantiate(spawnManagerPrefab);

        NetworkServer.Spawn(newSpawnManager);
        newSpawnManager.GetComponent <NetworkMatchChecker>().matchId = _matchID.ToGuid();
        PlayerSpawnManager spawnManager = newSpawnManager.GetComponent <PlayerSpawnManager>();

        for (int i = 0; i < matches.Count; i++)
        {
            if (matches[i].matchID == _matchID)
            {
                foreach (var player in matches[i].players)
                {
                    Player _player = player.GetComponent <Player>();
                    Debug.Log($"Spawning player {_player.playerName}");
                    spawnManager.SpawnPlayer();
                }
                break;
            }
        }
    }
Пример #10
0
 void Start()
 {
     instance     = this;
     playerSpawns = gameObject.GetComponentsInChildren <Transform>();
 }
Пример #11
0
 private void Awake()
 {
     PlayerSpawnManager.AddSpawnPoint(transform);
     Debug.Log("Spawn point added");
 }
Пример #12
0
 private void OnDestroy()
 {
     PlayerSpawnManager.RemoveSpawnPoint(transform);
     Debug.Log("Spawn point deleted");
 }
Пример #13
0
 private void Start()
 {
     playerSpawnManager = facade.GetComponent <MainPlayerSpawnManager>();
     spawnManager       = facade.GetComponent <PlayerSpawnManager>();
     adjuster           = facade.GetComponent <PositionAdjuster>();
 }
Пример #14
0
 void Start()
 {
     instance = this;
     playerSpawns = gameObject.GetComponentsInChildren<Transform>();
 }