示例#1
0
    public override void OnStartLocalPlayer()
    {
        Camera.main.transform.SetParent(transform);
        Camera.main.transform.localPosition = new Vector2(0, 0);

        playerNameObj.transform.localPosition = new Vector2(-0.05f, 0.25f);
        playerNameObj.transform.localScale    = new Vector2(0.1f, 0.1f);

        string name = PlayerNameInput.DisplayName;

        CmdSetupPlayer(name);

        //Setting stats
        maxHp      = 100;
        currentHp  = maxHp;
        experience = 0;
        level      = 1;

        //If player is host and client, auto ready
        if (!isClientOnly)
        {
            isReady = true;
        }

        if (SceneManager.GetActiveScene().buildIndex == 2)
        {
            /*
             * NetworkManager2 nm2 = FindObjectOfType<NetworkManager2>();
             * nm2.checkPlayerClass(netIdentity.netId);*/
            //Finding components
            NetworkManager3 nm3 = FindObjectOfType <NetworkManager3>();
            nm3.checkPlayerClass(netIdentity.netId);
            talentTree  = FindObjectOfType <TalentTree>();
            hud         = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUD>();
            deathScreen = FindObjectOfType <DeathUI>();
            winScreen   = FindObjectOfType <WinUI>();

            talentTree.GetComponent <Canvas>().enabled = false;
            CmdSetMaxHealth(currentHp, maxHp, netId);
            CmdSetMaxExp(experience, 100, level, netId);
        }
        else if (SceneManager.GetActiveScene().buildIndex == 1)
        {
            //Finding components
            hud = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUD>();

            CmdSetMaxHealth(currentHp, maxHp, netId);
            CmdSetMaxExp(experience, 100, level, netId);
        }

        activateClassScripts();
    }
示例#2
0
    public void rpcStartGame()
    {
        /*
         * NetworkManager2 nm2 = FindObjectOfType<NetworkManager2>();
         * int buildIndex = SceneManager.GetActiveScene().buildIndex + 1;
         * SceneManager.LoadScene(buildIndex);
         * nm2.ServerChangeScene(SceneManager.GetSceneByBuildIndex(buildIndex).name);*/
        NetworkManager3 nm3        = FindObjectOfType <NetworkManager3>();
        int             buildIndex = SceneManager.GetActiveScene().buildIndex + 1;

        SceneManager.LoadScene(buildIndex);
        nm3.ServerChangeScene(SceneManager.GetSceneByBuildIndex(buildIndex).name);
    }
示例#3
0
 private void Start()
 {
     networkManager = FindObjectOfType <NetworkManager3>();
 }