Ejemplo n.º 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);
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 4
0
 public void LeaveQueue(CustomerGroup group)
 {
     queue.Remove(group);
 }
Ejemplo n.º 5
0
 public void EnterQueue(CustomerGroup group)
 {
     queue.Add(group);
 }
Ejemplo n.º 6
0
 public void SetGroup(CustomerGroup group)
 {
     photonView.RPC("NetworkSetGroup", PhotonTargets.AllBuffered, group.GetComponent <PhotonView>().viewID);
 }