Пример #1
0
    public void CmdOnRedClick()//按下红色队伍按钮
    {
        Debug.Log("red button");
        if (!isClient)
        {
            return;
        }
        canvas.SetActive(false);
        //MainCamera.SetActive(true);
        _term = 1;//1是红
        //RpcChangetrem(1);
        iscontrol = true;
        print(_term);
        PlayerRemoter pc = PlayerManager.Instance.GetLocalPlayer();

        Debug.Log(pc.GetCharacterObject());
        Debug.Log(pc.isServer);
        if (pc.GetCharacterObject() == null && !pc.isServer)
        {
            Debug.Log("start spawn");
            pc.CmdSpawnPlayer();
        }
        else
        {
            Debug.Log("error");
        }
    }
    void OnGUI()
    {
        PlayerRemoter player = PlayerManager.Instance.GetLocalPlayer();

        if (!player.isServer && player.GetCharacterObject() == null)
        {
            if (GUI.Button(new Rect(10, 120, 200, 20), "Spawn"))
            {
                player.CmdSpawnPlayer();
            }
            GUI.Box(new Rect(Screen.width / 2 - 150, 70, 300, 40), instructionsSpawn);
        }

        if (player.isServer)
        {
            GUI.Box(new Rect(Screen.width / 2 - 150, 120, 300, 40), instructionsOnServer);
        }
        else
        {
            GUI.Box(new Rect(Screen.width / 2 - 150, 120, 300, 80), instructionsOnMovingClient + instructionsOnOtherClient);
        }
    }