Exemple #1
0
        private void Activate(AbilityComponent ability, GameManager manager)
        {
            var activation = CreateActivateAbilityMessage(manager);

            activation.ActivatorEntity = ability.OwnerEntity;
            activation.TargetEntity    = ability.OwnerEntity;
            activation.AbilityEntity   = ability.Entity;

            manager.Process(activation);
        }
Exemple #2
0
        private Direction GetRequiredHeading(
            AbilityComponent ability,
            PositionComponent activatorPosition,
            Point targetCell)
        {
            switch (ability.Activation)
            {
            case ActivationType.Manual:
            case ActivationType.WhileToggled:
                return(activatorPosition.Heading.Value);

            case ActivationType.Targeted:
                var targetDirection = activatorPosition.LevelCell.DifferenceTo(targetCell);
                if (targetDirection.Length() == 0)
                {
                    return(activatorPosition.Heading.Value);
                }

                var octantsToTurn          = 0;
                var targetOctantDifference = targetDirection.OctantsTo(activatorPosition.Heading.Value);
                var maxOctantDifference    = ability.HeadingDeviation;
                if (targetOctantDifference > maxOctantDifference)
                {
                    octantsToTurn = targetOctantDifference - maxOctantDifference;
                }
                else if (targetOctantDifference < -maxOctantDifference)
                {
                    octantsToTurn = targetOctantDifference + maxOctantDifference;
                }

                var newDirection = (int)activatorPosition.Heading.Value - octantsToTurn;
                if (newDirection < 0)
                {
                    newDirection += 8;
                }
                else if (newDirection > 8)
                {
                    newDirection -= 8;
                }

                return((Direction)newDirection);

            default:
                throw new InvalidOperationException(
                          $"Ability {ability.Name} on entity {activatorPosition.EntityId} cannot be activated manually.");
            }
        }
Exemple #3
0
        public static ActivationType GetTrigger(AbilityComponent ability)
        {
            switch (ability.Action)
            {
            case AbilityAction.Default:
            case AbilityAction.Modifier:
            case AbilityAction.Drink:
                return(ActivationType.Default);

            case AbilityAction.Hit:
            case AbilityAction.Slash:
            case AbilityAction.Chop:
            case AbilityAction.Stab:
            case AbilityAction.Poke:
            case AbilityAction.Impale:
            case AbilityAction.Bludgeon:
            case AbilityAction.Punch:
            case AbilityAction.Kick:
            case AbilityAction.Touch:
            case AbilityAction.Headbutt:
            case AbilityAction.Claw:
            case AbilityAction.Bite:
            case AbilityAction.Suck:
            case AbilityAction.Sting:
            case AbilityAction.Hug:
            case AbilityAction.Trample:
            case AbilityAction.Digestion:
                return(ActivationType.OnMeleeAttack);

            case AbilityAction.Shoot:
            case AbilityAction.Throw:
            case AbilityAction.Spit:
            case AbilityAction.Breath:
            case AbilityAction.Gaze:
            case AbilityAction.Scream:
            case AbilityAction.Spell:
            case AbilityAction.Explosion:
                return(ActivationType.OnRangedAttack);

            default:
                throw new ArgumentOutOfRangeException(nameof(ability), ability.Action.ToString());
            }
        }