Beispiel #1
0
        public override void Run()
        {
            _rendToMaterialsMap = MaterialUtil.GetOriginalMaterials(gameObject);

            MaterialUtil.AddMaterial(gameObject, Material);

            InvokeUtil.RunLater(this, Revert, LifeTime);
        }
Beispiel #2
0
        public override void Run()
        {
            base.Run();

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

            InvokeUtil.RunLater(this, () => { _shouldFocusOnTarget = true; }, FocusOnTargetDelay);
        }
Beispiel #3
0
        private void Update()
        {
            if (Input.GetMouseButtonDown(1))
            {
                var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    if (MarkFx != null)
                    {
                        MarkFx.TargetPosition = hit.point;
                        FxObjectInstancer.InstantiateOnCollisionFx(MarkFx, new CollisionPoint
                        {
                            Point  = hit.point,
                            Normal = 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 <MaterialAdder>();
                        materialAdded.Material = _materialAdder.Material;
                        materialAdded.LifeTime = _materialAdder.LifeTime;
                        materialAdded.Run();

                        InvokeUtil.RunLater(this, () =>
                        {
                            Destroy(materialAdded);
                            _markedObjects.Remove(gameObjectId);
                        }, LifeTime);
                    }
                    else
                    {
                        if (_markedPositions.Count >= MaxTargets)
                        {
                            return;
                        }
                        _markedPositions.Add(hit.point);
                        InvokeUtil.RunLater(this, () => { _markedPositions.Remove(hit.point); }, LifeTime);
                    }
                }
            }
        }
Beispiel #4
0
 private void OnEnable()
 {
     if (RunAtStart)
     {
         InvokeUtil.RunLater(this, delegate
         {
             Setup();
             Run();
         }, Delay);
     }
 }
Beispiel #5
0
        public override void Run()
        {
            base.Run();

            //Revert
            InvokeUtil.RunLater(this, delegate
            {
                MaterialUtil.ReplaceMaterial(_originalMaterials);
                _originalMaterials.Clear();
            }, LifeTime);
        }