Пример #1
0
    IEnumerator InstantiateBox()
    {
        while (boxToInstantiate.Count > 0 && PosFree.Count > 0)
        {
            yield return(new WaitForSeconds(1.2f));

            if (PosFree.Contains(PosInstantiation.Count() - 2))
            {
                int posIndex = PosInstantiation.Count() - 1;
                int finalPosIndex;

                Poolable           foodToInstantiate = PoolManager.Instance.Get(boxToInstantiate[0], true);
                BoxDatasController box  = foodToInstantiate.GetComponent <BoxDatasController>();
                PhotonView         view = foodToInstantiate.GetComponent <PhotonView>();

                foodToInstantiate.transform.position = PosInstantiation[posIndex].position;
                foodToInstantiate.transform.rotation = PosInstantiation[posIndex].rotation;

                box.Init();
                box.SetActive(false);
                box.Grabable.onGrab += OnGrabBox;

                boxInPos.Add(box, posIndex);

                PosFree.Remove(posIndex);

                finalPosIndex = GetFinalBoxPosition(posIndex);

                boxInPos[box] = finalPosIndex;
                PosFree.Remove(finalPosIndex);

                StartCoroutine(TranslateBoxToPosition(box, posIndex));

                photonView.RPC("InstantiateBox", RpcTarget.Others, boxToInstantiate[0].Key, boxToInstantiate[0].Value, posIndex, finalPosIndex, view.ViewID);

                boxToInstantiate.RemoveAt(0);
            }

            yield return(0);
        }

        yield return(0);
    }
Пример #2
0
    void InstantiateBox(string _alimentName, AlimentState _alimentState, int posFree, int finalPos, int viewID)
    {
        //Debug.Log("Receive RPC InstantiateBox :" + _alimentName + " AlimentState:" + _alimentState + " viewID:" + viewID);
        KeyValuePair <string, AlimentState> key = new KeyValuePair <string, AlimentState>(_alimentName, _alimentState);

        Poolable           foodToInstantiate = PoolManager.Instance.Get(key, viewID);
        BoxDatasController box = foodToInstantiate.GetComponent <BoxDatasController>();

        foodToInstantiate.transform.position = PosInstantiation[posFree].position;
        foodToInstantiate.transform.rotation = PosInstantiation[posFree].rotation;

        box.Init();
        box.SetActive(false);
        box.Grabable.onGrab += OnGrabBox;

        boxInPos.Add(box, posFree);

        PosFree.Remove(posFree);

        boxInPos[box] = finalPos;
        PosFree.Remove(finalPos);

        StartCoroutine(TranslateBoxToPosition(box, posFree));
    }