private void OnEnable()
        {
            camera.position = cameraPositions[0].position;
            camera.rotation = cameraPositions[0].rotation;
            currentCat      = CategorySelection.none;

            clothes = GameManagers.GetResourcesManager().GetAllClothItems();
            weapons = GameManagers.GetResourcesManager().GetAllWeapons();

            string modelId         = GameManagers.GetProfile().modelId;
            string primaryWeapon   = GameManagers.GetProfile().itemIds[0];
            string secondaryWeapon = GameManagers.GetProfile().itemIds[1];

            for (int i = 0; i < clothes.Count; i++)
            {
                if (string.Equals(clothes[i].name, modelId))
                {
                    clothIndex = i;
                    break;
                }
            }

            for (int i = 0; i < weapons.Count; i++)
            {
                if (string.Equals(weapons[i].name, primaryWeapon))
                {
                    primaryWeaponIndex = i;
                    break;
                }

                if (string.Equals(weapons[i].name, secondaryWeapon))
                {
                    secondaryWeaponIndex = i;
                    break;
                }
            }

            offlineState.LoadCharacterModel(clothes[clothIndex].name);

            if (primaryWeaponObject != null)
            {
                Destroy(primaryWeaponObject);
            }
            primaryWeaponObject = CreateWeapon(weapons[primaryWeaponIndex], primaryWeaponParent);

            if (secondaryWeaponObject != null)
            {
                Destroy(secondaryWeaponObject);
            }
            secondaryWeaponObject = CreateWeapon(weapons[secondaryWeaponIndex], secondaryWeaponParent);
        }
Пример #2
0
        public void OnPhotonInstantiate(PhotonMessageInfo info)
        {
            states = GetComponent <StateManager>();
            states.InitReferences();
            mTransform = this.transform;
            object[] data = photonView.InstantiationData;

            states.photonId = (int)data[0];
            string modelId = (string)data[2];

            states.LoadCharacterModel(modelId);

            MultiplayerManager m = MultiplayerManager.singleton;

            this.transform.parent = m.GetMRef().referencesParent;

            PlayerHolder playerHolder = m.GetMRef().GetPlayer(states.photonId);

            playerHolder.states = states;

            string weaponId = (string)data[1];

            Debug.Log("Weapon ID: " + weaponId);
            states.inventory.weaponID = weaponId;

            if (photonView.IsMine)
            {
                states.isLocal = true;
                states.SetCurrentState(local);
                initLocalPlayer.Execute(states);
            }
            else
            {
                states.isLocal = false;
                states.SetCurrentState(client);
                initClientPlayer.Execute(states);
                states.multiplayerListener = this;
            }
        }