コード例 #1
0
        void NetworkSetGroup(int viewId)
        {
            PhotonView groupView = PhotonView.Find(viewId);

            if (groupView == null)
            {
                Debug.LogError("Unable to set Customer group, group does not exist: " + viewId);
                return;
            }

            this.group = groupView.GetComponent <CustomerGroup>();
            this.transform.SetParent(group.transform);
        }
コード例 #2
0
        public Vector3 GetQueuePosition(CustomerGroup group)
        {
            float offset = 0;

            foreach (CustomerGroup queueGroup in queue)
            {
                if (queueGroup == group)
                {
                    break;
                }
                offset += positionSpacing;
            }

            return(transform.position + transform.TransformDirection(new Vector3(0, 0, offset)));
        }
コード例 #3
0
        /// <summary>
        /// Spawn a random group of customers.
        /// </summary>
        private void SpawnCustomers()
        {
            groupChance.Sort((obj1, obj2) =>
            {
                if (obj1.groupChance < obj2.groupChance)
                {
                    return(-1);
                }
                if (obj1.groupChance == obj2.groupChance)
                {
                    return(0);
                }

                return(1);
            });

            float dice = Random.Range(0, 100);

            foreach (GroupChance group in groupChance)
            {
                if (dice > group.groupChance)
                {
                    continue;
                }

                GameObject    groupObject   = PhotonNetwork.Instantiate(this.customerGroupPrefab.name, transform.position, Quaternion.identity, 0);
                CustomerGroup customerGroup = groupObject.GetComponent <CustomerGroup>();
                for (int i = 0; i < group.groupSize; i++)
                {
                    //Get random Customer Prefab
                    int index = Random.Range(0, customerPrefabs.Count);

                    Vector3 spawn      = transform.position;
                    float   spawnRange = 0.5f;
                    spawn = new Vector3(spawn.x + Random.Range(-spawnRange, spawnRange), spawn.y, spawn.z + Random.Range(-spawnRange, spawnRange));

                    GameObject customerObj = PhotonNetwork.Instantiate(this.customerPrefabs[index].name, spawn, Quaternion.identity, 0);
                    Customer   customer    = customerObj.GetComponent <Customer>();
                    customer.SetGroup(customerGroup);
                }

                return;
            }
        }
コード例 #4
0
 public void LeaveQueue(CustomerGroup group)
 {
     queue.Remove(group);
 }
コード例 #5
0
 public void EnterQueue(CustomerGroup group)
 {
     queue.Add(group);
 }
コード例 #6
0
 public void SetGroup(CustomerGroup group)
 {
     photonView.RPC("NetworkSetGroup", PhotonTargets.AllBuffered, group.GetComponent <PhotonView>().viewID);
 }