コード例 #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
ファイル: LuckyMeLib.cs プロジェクト: iamsamwood/ENCODERS
 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
ファイル: DemoHelper.cs プロジェクト: bsvercl/physics2d
 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
ファイル: DemoHelper.cs プロジェクト: bsvercl/physics2d
 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
ファイル: LuckyMeLib.cs プロジェクト: eikoyoneki/haggle
 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);
        }