Esempio n. 1
0
        public void SpawnAsset(SpawnInitParams paramObject, int idPhoton)
        {
            if (GameStateData.GetWrapperCollection().Exist(paramObject.IdInstance))
            {
                Debug.Log($"Object with id {paramObject.IdInstance} already exist!");
                return;
            }

            Contexts contexts = Contexts.sharedInstance;
            var      entity   = contexts.game.CreateEntity();

            entity.AddSpawnAsset(paramObject, idPhoton);
        }
Esempio n. 2
0
        /// <summary>
        ///     Initialize object in platform
        /// </summary>
        /// <param name="idObject">Object type id. Used for save.</param>
        /// <param name="spawnInitParams">Parameters for spawn</param>
        /// <param name="spawnedGameObject">Game object for init</param>
        public static void InitObject(int idObject, SpawnInitParams spawnInitParams, GameObject spawnedGameObject, Config config)
        {
            //var photonView = AddPhoton(spawnedGameObject, spawnInitParams.spawnAsset.IdPhoton);
            PhotonView photonView     = AddPhoton(spawnedGameObject, 0);
            GameObject gameObjectLink = spawnedGameObject;
            int        idLocation     = spawnInitParams.IdLocation;
            int        idServer       = spawnInitParams.IdServer;
            int        idInstance     = spawnInitParams.IdInstance;
            bool       embedded       = spawnInitParams.Embedded;
            string     name           = spawnInitParams.Name;
            var        parentId       = spawnInitParams.ParentId;

            ObjectController parent = null;

            if (parentId != null)
            {
                parent = GameStateData.GetObjectInLocation(parentId.Value);
            }

            WrappersCollection wrappersCollection = null;

            if (idLocation != 0)
            {
                wrappersCollection = GameStateData.GetWrapperCollection();
            }

            InitObjectParams initObjectParams = new InitObjectParams
            {
                Id                 = idInstance,
                IdObject           = idObject,
                IdLocation         = idLocation,
                IdServer           = idServer,
                Asset              = gameObjectLink,
                Name               = name,
                Photonview         = photonView,
                RootGameObject     = spawnedGameObject,
                WrappersCollection = wrappersCollection,
                Parent             = parent,
                Embedded           = embedded,
                Config             = config
            };

            var newController = new ObjectController(initObjectParams);

            ObjectControllerCreated?.Invoke(newController);
        }