public override void Run()
 {
     Cell.StartCoroutine(
         Tweens.AnimateMaterialsColorCoroutine(
             Cell.GetComponentsInChildren <Renderer>().Select(r => r.material).ToList(),
             Color.red,
             3,
             onCompleted: () => { EventActionFinished?.Invoke(this); }));
 }
        public override void Update(float deltaTime)
        {
            var fullMovingVector = _movingVector * Robot.MoveSpeed * deltaTime;
            var vectorToTarget   = _targetRobotPosition - Robot.transform.position;

            if (vectorToTarget.sqrMagnitude < fullMovingVector.sqrMagnitude)
            {
                Robot.transform.position = _targetRobotPosition;
                EventActionFinished?.Invoke(this);
            }
            else
            {
                Robot.transform.Translate(fullMovingVector, Space.World);
            }
        }
        public override void Update(float deltaTime)
        {
            var fullRotationAngle =
                (_direction == RotationDirection.Left ? -1.0f : 1.0f) * Robot.RotationSpeed * deltaTime;
            var remainingRotationAngle = Quaternion.Angle(Robot.transform.rotation, _targetRobotRotation);

            if (Mathf.Abs(remainingRotationAngle) < Mathf.Abs(fullRotationAngle))
            {
                Robot.transform.rotation = _targetRobotRotation;
                EventActionFinished?.Invoke(this);
            }
            else
            {
                Robot.transform.Rotate(0.0f, fullRotationAngle, 0.0f, Space.World);
            }
        }
Esempio n. 4
0
        public override void Run()
        {
            var beeper = Robot.GetComponentInChildren <Beeper>();

            // TODO: refactor to async tasks to avoid callback hell
            Robot.StartCoroutine(Tweens.MoveTransformCoroutine(
                                     Robot.Arms,
                                     Robot.Arms.position - Vector3.up * Robot.ArmsTravellingDistance,
                                     Robot.ArmsMovingSpeed,
                                     onCompleted: () =>
            {
                beeper.transform.SetParent(_cell.transform);

                Robot.StartCoroutine(Tweens.MoveTransformCoroutine(
                                         Robot.Arms,
                                         Robot.Arms.position + Vector3.up * Robot.ArmsTravellingDistance,
                                         Robot.ArmsMovingSpeed,
                                         onCompleted: () => { EventActionFinished?.Invoke(this); }));
            }));
        }
Esempio n. 5
0
        public override void Run()
        {
            // TODO: refactor to async tasks to avoid callback hell
            _beeper.StartCoroutine(Tweens.RotateTransformCoroutine(_beeper.transform, Robot.transform.rotation, 90.0f,
                                                                   onCompleted: () =>
            {
                Robot.StartCoroutine(Tweens.MoveTransformCoroutine(
                                         Robot.Arms,
                                         Robot.Arms.position - Vector3.up * Robot.ArmsTravellingDistance,
                                         Robot.ArmsMovingSpeed,
                                         onCompleted: () =>
                {
                    _beeper.transform.SetParent(Robot.Arms);

                    Robot.StartCoroutine(Tweens.MoveTransformCoroutine(
                                             Robot.Arms,
                                             Robot.Arms.position + Vector3.up * Robot.ArmsTravellingDistance,
                                             Robot.ArmsMovingSpeed,
                                             onCompleted: () => { EventActionFinished?.Invoke(this); }));
                }));
            }));
        }