Пример #1
0
 /// Create a new instance
 /// @param template The template GameObject to spawn instances of
 /// @param spawnObjectEvery Spawn a new instance this often
 /// @param maxPoolSize Allow at most this many objects to exist
 /// @param callback Callback to provide animation curve, etc.
 public ObjectStream(GameObject template, float spawnObjectEvery, int maxPoolSize, SpawnCallback <TStream> factory)
 {
     this.SpawnObjectEvery = spawnObjectEvery;
     this._factory         = factory;
     _pool   = new SpawnedObjectPool(Option.Some(template), maxPoolSize);
     Elapsed = spawnObjectEvery;
 }
Пример #2
0
        private static IEnumerator delayedSpawn(SpawnCallback callback, Action <SpawnCallback, Vector3> spawnAction, float duration, Vector3 pos)
        {
            // wait
            yield return(new WaitForSecondsRealtime(duration));

            // spawn
            spawnAction(callback, pos);
        }
Пример #3
0
 public void SpawnPreviewModel(string meshName, Vector3 position, bool valid, SpawnCallback callback)
 {
     SpawnModel(meshName, position, (obj) =>
     {
         BackupMaterials(obj);
         obj.GetComponent <MeshRenderer>().SetAllMaterial(valid ? PreviewMaterial : InvalidPreviewMaterial);
         callback.Invoke(obj);
     });
 }
Пример #4
0
        public override void spawnAction(SpawnCallback callback, Vector3 pos)
        {
            base.spawnAction(callback, pos);

            Light2D newLight = newGameObject.GetComponent <Light2D>();

            if (newLight)
            {
                newLight.color = new Color(Mathf.Clamp(newLight.color.r + Random.Range(-variance, variance), 0, 1), Mathf.Clamp(newLight.color.g + Random.Range(-variance, variance), 0, 1), Mathf.Clamp(newLight.color.b + Random.Range(-variance, variance), 0, 1));
            }
        }
Пример #5
0
 public void spawn(SpawnCallback callback, Vector3 pos)
 {
     // wait X seconds before spawning
     if (delay != 0)
     {
         StartCoroutine(delayedSpawn(callback, spawnAction, delay, pos));
     }
     // spawm immediately
     else
     {
         spawnAction(callback, pos);
     }
 }
Пример #6
0
        public virtual void spawnAction(SpawnCallback callback, Vector3 pos)
        {
            // spawn and positionned newly object
            TryGetNextObject(transform.position, transform.rotation, out newGameObject);
            newGameObject.transform.localPosition = pos;

            // do callback
            callback?.Invoke(newGameObject);

            // play spawn sound
            if (spawnSound != "")
            {
                AudioCtrl.Instance.playSoundEvent.Invoke(spawnSound);
            }
        }
Пример #7
0
        public static DisposeCallback RegisterSpawning(DemoOpenInfo info, Key key, SpawnCallback callback)
        {
            EventHandler <KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e)
            {
                if (e.Key == key)
                {
                    callback(info.Viewport.MousePosition);
                }
            };

            Events.KeyboardDown += downHandler;
            return(delegate()
            {
                Events.KeyboardDown -= downHandler;
            });
        }
Пример #8
0
 public static extern int startHaggle(SpawnCallback callback);
Пример #9
0
 public Spawner(SpawnCallback spawnCallback)
 {
     _onSpawnMonster += spawnCallback;
 }
Пример #10
0
 public Spawner(SpawnCallback spawnCallback)
 {
     _onSpawnMonster += spawnCallback;
 }
Пример #11
0
        public void SpawnModel(string address, Vector3 position, SpawnCallback callback)
        {
            var obj = ActivatePoolObject(address, position, transform);

            callback.Invoke(obj);
        }
Пример #12
0
        private void InitModel(string address, Vector3 position, SpawnCallback callback)
        {
            var op = Addressables.InstantiateAsync(address, position, Quaternion.identity, transform);

            op.Completed += (AsyncOperationHandle <GameObject> obj) => callback.Invoke(obj.Result);
        }
Пример #13
0
        public override void spawnAction(SpawnCallback callback, Vector3 pos)
        {
            base.spawnAction(callback, pos);

            //GameCtrl.Instance.player.control.animator = GameObject.FindGameObjectWithTag("Player").GetComponent<Animator>();
        }
Пример #14
0
        public static DisposeCallback RegisterMaintainSpawning(DemoOpenInfo info, Key key, SpawnCallback callback)
        {
            IPhysicsEntity current = null;
            EventHandler <KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e)
            {
                if (e.Key == key)
                {
                    current = callback(info.Viewport.MousePosition);
                }
            };
            EventHandler <KeyboardEventArgs> upHandler = delegate(object sender, KeyboardEventArgs e)
            {
                if (e.Key == key)
                {
                    if (current != null)
                    {
                        current.Lifetime.IsExpired = true;
                        current = null;
                    }
                }
            };

            Events.KeyboardDown += downHandler;
            Events.KeyboardUp   += upHandler;
            return(delegate()
            {
                Events.KeyboardDown -= downHandler;
                Events.KeyboardUp -= upHandler;
            });
        }
Пример #15
0
 public static DisposeCallback RegisterMaintainSpawning(DemoOpenInfo info, Key key, SpawnCallback callback)
 {
     IPhysicsEntity current = null;
     EventHandler<KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e)
     {
         if (e.Key == key)
         {
             current = callback(info.Viewport.MousePosition);
         }
     };
     EventHandler<KeyboardEventArgs> upHandler = delegate(object sender, KeyboardEventArgs e)
     {
         if (e.Key == key)
         {
             if (current != null)
             {
                 current.Lifetime.IsExpired = true;
                 current = null;
             }
         }
     };
     Events.KeyboardDown += downHandler;
     Events.KeyboardUp += upHandler;
     return delegate()
     {
         Events.KeyboardDown -= downHandler;
         Events.KeyboardUp -= upHandler;
     };
 }
Пример #16
0
 public static DisposeCallback RegisterSpawning(DemoOpenInfo info, Key key, SpawnCallback callback)
 {
     EventHandler<KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e)
     {
         if (e.Key == key)
         {
              callback(info.Viewport.MousePosition);
         }
     };
     Events.KeyboardDown += downHandler;
     return delegate()
     {
         Events.KeyboardDown -= downHandler;
     };
 }
Пример #17
0
 public void SpawnPreviewModel(StructureDefinition.StructureType type, Vector3 position, bool valid, SpawnCallback callback)
 {
     SpawnPreviewModel(_structureDefinitionManager.GetAssetNameForStructureType(type), position, valid, callback);
 }
Пример #18
0
 static public extern int startHaggle(SpawnCallback callback);
Пример #19
0
        public void SpawnUIElement(string name, Transform parent, SpawnCallback callback)
        {
            var op = Addressables.InstantiateAsync(name, parent.transform.position, Quaternion.identity, parent);

            op.Completed += (AsyncOperationHandle <GameObject> obj) => callback.Invoke(obj.Result);
        }