示例#1
0
    public override IEnumerator SlowUpdate()
    {
        if (IsServer)
        {
            managerScript = GameObject.FindGameObjectWithTag("manager").GetComponent <RecipeManagerScript>();

            submissionHeight = GameObject.FindGameObjectWithTag("sub").transform.position.y;
        }
        if (IsClient)
        {
        }
        while (IsServer)
        {
            if (this.transform.position.y > submissionHeight)
            {
                myParticle.Play();
                myAudio.Play();

                managerScript.RecieveOrder(recipeScript.ToString());

                MyCore.NetDestroyObject(NetId);
                //destroy
            }

            yield return(new WaitForSeconds(0.2f)); //potentially slower
        }
    }
    public override IEnumerator SlowUpdate()
    {
        if (IsLocalPlayer)
        {
            this.gameObject.tag = "playerManager";
            yield return(new WaitForSeconds(0.4f));//wait for scene

            pollManager = GameObject.FindGameObjectWithTag("poll");
            lobbyScript = pollManager.GetComponent <Lobby>();
            lobbyScript.AddClient(NetId);


            managerScript = GameObject.FindGameObjectWithTag("manager").GetComponent <RecipeManagerScript>();

            int tempId = MyCore.LocalPlayerId;
            //Debug.Log("My core local="+tempId);
            SendCommand("NID", tempId.ToString());
            otherOrder = true;

            this.transform.GetChild(0).gameObject.SetActive(true); // turn on UI
        }
        if (IsServer)
        {
            playerIsLeft  = false;
            playerIsRight = false;

            //for string to prefab transfrom array
            foodDictionary = new Dictionary <string, int>();
            foodDictionary.Add("Watermelon", 9);
            foodDictionary.Add("Egg", 18);
            foodDictionary.Add("Toast", 20);
            foodDictionary.Add("Daikon", 16);
            foodDictionary.Add("Tea", 10);

            cookwareDictionary = new Dictionary <string, int>();
            cookwareDictionary.Add("Cup", 8);
            cookwareDictionary.Add("Plate", 11);
            cookwareDictionary.Add("Pan", 17);
            cookwareDictionary.Add("Pot", 15);

            //spawnPos = GameObject.FindGameObjectWithTag("spawn").transform;
            spawnManager = GameObject.FindGameObjectWithTag("spawnManger").GetComponent <SpawnManagerScript>();
        }
        //true update
        while (IsServer)
        {
            if (playerIsLeft)
            {
                SendUpdate("LTS", "X");
            }
            else if (playerIsRight)
            {
                SendUpdate("RTS", "X");
            }



            yield return(new WaitForSeconds(0.5f)); //potentially slower
        }
    }