Exemplo n.º 1
0
    private void GetInput()
    {
        //This function will move EVERY player, which we dont want!
        //Only move player objects that the player has authority over (their own characters)
        if (!isLocalPlayer)
        {
            return;
        }

        if (isDead)
        {
            return;
        }

        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);

        if (warriorScript.enabled)
        {
            warriorScript.warriorUpdate();
        }
        else if (mageScript.enabled)
        {
            mageScript.mageUpdate();
        }

        //Talking to NPC
        if (SceneManager.GetActiveScene().buildIndex == 1)
        {
            NPC          npc   = GameObject.FindObjectOfType <NPC>();
            LobbyManager lobby = GameObject.FindObjectOfType <LobbyManager>();
            if (Input.GetKeyDown(KeyCode.Space) && npc.playerInRange)
            {
                if (!npc.dialogBox.activeInHierarchy)
                {
                    npc.dialogBox.SetActive(true);
                    npc.dialogText.text = npc.dialog;
                    lobby.player        = this;
                }
            }
        }

        //Talent tree
        if (SceneManager.GetActiveScene().buildIndex == 2)
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                talentTree.GetComponent <Canvas>().enabled = true;
                talentTree.playerId = netIdentity.netId;
            }
        }
    }
Exemplo n.º 2
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();
    }