示例#1
0
    void Update()
    {
        if (localPlayer == null)
        {
            localPlayer = GameObject.Find("local player");
            if (controlPanel.activeSelf)
            {
                controlPanel.SetActive(false);
            }
        }
        else
        {
            if (animator == null || networkAnimator == null || actionControl == null)
            {
                animator        = localPlayer.GetComponent <Animator>();
                networkAnimator = localPlayer.GetComponent <NetworkAnimator>();
                actionControl   = localPlayer.GetComponent <ActionControl>();
                localId         = actionControl.netId.ToString();
            }
            if (!controlPanel.activeSelf && !disableControl)
            {
                ResetControl();
            }
            if (disableControl && controlPanel.activeSelf)
            {
                controlPanel.SetActive(false);
            }
        }

        if (oponent == null)
        {
            if (isSet)
            {
                isSet = false;
            }
            oponent = GameObject.Find("oponent");
        }
        else
        {
            if (!isSet)
            {
                shootAnimator.SetTrigger("Shoot");
                RefreshEverything();
                actionControl.SetOwnRatio(localPlayer.GetComponent <NetworkIdentity>().netId.ToString(), localPlayer.GetComponent <Player>().ratio);
                isSet = true;
            }
        }

        if (localPlayer == null && oponent == null && !isRefresed)
        {
            RefreshEverything();
        }

        GetKeyInput();
    }