示例#1
0
        public bool Apply(EventType type, IEntity sender, object eventData)
        {
            if (IsFighter(sender))
            {
                var vector           = (Vector)eventData;
                var targetCoordinate = _positionSystem.CoordinateOf(sender) + vector;

                var entitiesAtPosition = _positionSystem.EntitiesAt(targetCoordinate);

                if (entitiesAtPosition.Any(IsFighter))
                {
                    var defender = entitiesAtPosition.Single(e => IsFighter(e));

                    var action = new ActionEventData {
                        Action = ActionType.MeleeAttack, Parameters = $"{sender.EntityId},{defender.EntityId}", Speed = null, KeyPress = null
                    };

                    if (_eventSystem.Try(EventType.Action, sender, action))
                    {
                        _animatedMovementSystem.StartAnimatedMovement(sender, new List <AnimationMovement> {
                            new AnimationMovement(new VectorDouble((double)vector.X / (double)-2, (double)vector.Y / (double)-2), 750)
                        });
                    }

                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        public bool Apply(EventType type, IEntity sender, object eventData)
        {
            var vector = (Vector)eventData;

            positionSystem.Move(sender, vector);
            _animatedMovementSystem.StartAnimatedMovement(sender, vector, 500);

            eventRuleSystem.Try(EventType.SpendTime, sender, new SpendTimeEventData()
            {
                Ticks = sender.Get <Actor>().Speed
            });

            return(true);
        }