private void FixedUpdate()
        {
            if (!IsRunning)
            {
                return;
            }

            var healableObjects = ObjectsFinder.FindObjects(transform.position);

            foreach (var healable in healableObjects)
            {
                var healableGo = healable.gameObject;

                if (!_healableObjectsInArea.ContainsKey(healableGo))
                {
                    var offset         = new Vector3(0, healable.bounds.center.y, 0);
                    var targetPosition = healable.transform.position + offset;
                    var healingGo      = Instantiate(HealingFx, targetPosition, Quaternion.identity);
                    healingGo.transform.parent = healable.transform;

                    var healingPs = healingGo.GetComponent <ParticleSystem>();

                    _healableObjectsInArea[healableGo] = healingPs;

                    SFX_InvokeUtil.RunLater(this, delegate
                    {
                        healingPs.Stop();
                        Destroy(healingPs.gameObject, 1f);
                        _healableObjectsInArea.Remove(healableGo);
                    }, healingPs.main.duration);
                }
            }
        }
Ejemplo n.º 2
0
        public override void Run()
        {
            base.Run();

            _addedTime = Time.time;

            if (_isMaterialAdded)
            {
                return;
            }

            if (Targets != null && Targets.Length > 0)
            {
                foreach (var target in Targets)
                {
                    GetMaterialsAndFillCollection(target);
                }
            }
            else
            {
                GetMaterialsAndFillCollection(gameObject);
            }

            _isMaterialAdded = true;


            SFX_InvokeUtil.RunLater(this, Stop, LifeTime);
        }
        public override void Run()
        {
            base.Run();

            transform.LookAt(LaunchPosition);
            _rigidbody.AddForce((LaunchPosition - transform.position).normalized * LaunchForce, ForceMode.Impulse);

            SFX_InvokeUtil.RunLater(this, () => { _shouldFocusOnTarget = true; }, FocusOnTargetDelay);
        }
Ejemplo n.º 4
0
        private void OnEnable()
        {
            Setup();

            if (RunAtStart)
            {
                SFX_InvokeUtil.RunLater(this, Run, Delay);
            }
        }
Ejemplo n.º 5
0
        public override void Run()
        {
            base.Run();

            //Revert
            SFX_InvokeUtil.RunLater(this, delegate
            {
                SFX_MaterialUtil.ReplaceMaterial(_originalMaterials);
                _originalMaterials.Clear();
            }, LifeTime);
        }
 private void OnEnable()
 {
     if (RunAtStart)
     {
         SFX_InvokeUtil.RunLater(this, delegate
         {
             Setup();
             Run();
         }, Delay);
     }
 }
Ejemplo n.º 7
0
        public override void Run()
        {
            base.Run();

            var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (!Physics.Raycast(ray, out hit))
            {
                return;
            }

            if (MarkFx != null)
            {
                SFX_FxObjectInstancer.InstantiateFx(MarkFx, hit.point, hit.normal);
            }

            if (MarkTargetMode == MarkMode.GameObject)
            {
                if (_markedObjects.Count >= MaxTargets)
                {
                    return;
                }

                var gameObjectId = hit.transform.gameObject.GetInstanceID();
                if (_markedObjects.ContainsKey(gameObjectId))
                {
                    return;
                }

                _markedObjects[gameObjectId] = hit.transform.gameObject;
                var materialAdded = hit.transform.gameObject.AddComponent <SFX_MaterialAdder>();
                materialAdded.Material = MarkMaterial;
                materialAdded.LifeTime = MarkLifeTime;

                SFX_InvokeUtil.RunLater(this, () =>
                {
                    materialAdded.Stop();
                    Destroy(materialAdded);
                    _markedObjects.Remove(gameObjectId);
                }, LifeTime);
            }
            else
            {
                if (_markedPositions.Count >= MaxTargets)
                {
                    return;
                }
                _markedPositions.Add(hit.point);
                SFX_InvokeUtil.RunLater(this, () => { _markedPositions.Remove(hit.point); }, LifeTime);
            }
        }
Ejemplo n.º 8
0
        public override void Stop()
        {
            base.Stop();

            var timeDiff = Time.time - _addedTime;

            if (timeDiff < LifeTime)
            {
                //call again
                SFX_InvokeUtil.RunLater(this, Stop, LifeTime - timeDiff);
                return;
            }

            SFX_MaterialUtil.ReplaceMaterial(_rendToMaterialsMap);
            _rendToMaterialsMap.Clear();
            _isMaterialAdded = false;
        }