示例#1
0
    public override void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var currentWorldModel = WorldModelService.Instance.GetCurrentWorldModelLayer();

        foreach (var targetsIdentifier in commandData.targetsIdentifiers)
        {
            if (currentWorldModel.TryGetUnit(targetsIdentifier, out var target))
            {
                foreach (var effect in commandData.unitAbility.AbilityEffects)
                {
                    if (effect is TauntEffect tauntEffect)
                    {
                        tauntEffect.OptionalTarget = UnitManager.Instance.GetActiveCharacter(commandData.actor);
                        tauntEffect.tauntTarget    = tauntEffect.OptionalTarget;
                        target.UnitState.AddActionEffect(effect);
                        continue;
                    }

                    target.UnitState.AddActionEffect(effect);
                    effect.SimulateAffect(target, false);
                }
            }
            else
            {
                Debug.LogError($"Couldn't apply ActionEffects to unit {targetsIdentifier} as it doesn't exist in current world model");
            }
        }
        commandData.onCommandCompletedCallback?.Invoke();
    }
示例#2
0
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalCommandData = null)
    {
        var actor  = UnitManager.Instance.GetActiveCharacter(commandData.actor);
        var target = UnitManager.Instance.GetActiveCharacter(commandData.targetsIdentifiers[0]);

        actor.TriggerMoveToUnit(target, commandData.onCommandCompletedCallback);
    }
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalCommandData = null)
    {
        if (commandData.targetsIdentifiers.Count == 0)
        {
            Debug.Log("[AttackUnitCommand] Attempting to attack multiple targets with no targets");
            return;
        }

        if (commandData.targetsIdentifiers.Count > 1)
        {
            Debug.Log("[AttackUnitCommand] Attempting to attack multiple targets with single AttackUnitCommand");
        }

        var actor = UnitManager.Instance.GetActiveCharacter(commandData.actor);

        actor.TriggerAttackAnim(null, () =>
        {
            commandData.onCommandCompletedCallback?.Invoke();

            if (commandData.targetsIdentifiers[0] == null)
            {
                Debug.LogError($"[AttackUnitCommand] Missing target in command data");
                return;
            }

            var target = UnitManager.Instance.GetActiveCharacter(commandData.targetsIdentifiers[0]);
            if (target != null)
            {
                target.ReciveDamage(applyBaseDamage ? actor.Unit.UnitData.BaseDamage : 0);
            }
        });
    }
 public AbilitySequenceHandler(Queue <AbstractUnitCommand> abilityQueue, CommonCommandData commonCommandData, OptionalCommandData optionalCommandData, Action onAbilitySequenceFinished)
 {
     currentQueue                   = new Queue <AbstractUnitCommand>(abilityQueue);
     this.commonCommandData         = commonCommandData;
     this.optionalCommandData       = optionalCommandData;
     this.onAbilitySequenceFinished = onAbilitySequenceFinished;
 }
 public AbilitySequenceHandler(TurnAction turnAction, Action onAbilitySequenceFinished)
 {
     currentQueue                   = new Queue <AbstractUnitCommand>(turnAction.QueueOfCommands);
     commonCommandData              = turnAction.CommonCommandData;
     optionalCommandData            = turnAction.OptionalCommandData;
     this.onAbilitySequenceFinished = onAbilitySequenceFinished;
 }
    public override void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var currentWorldModel = WorldModelService.Instance.GetCurrentWorldModelLayer();

        if (currentWorldModel.TryGetUnit(commandData.targetsIdentifiers[0], out var target))
        {
            if (applyBaseDamage)
            {
                if (currentWorldModel.TryGetUnit(commandData.actor, out var actor))
                {
                    target.UnitState.ApplyDamage(actor.UnitData.BaseDamage);
                }
                else
                {
                    Debug.LogError($"Couldn't find actor Unit with {commandData.actor} UnitIdentifier");
                }
            }
            else
            {
                target.UnitState.ApplyDamage(0);
            }
        }
        else
        {
            Debug.LogError($"Couldn't find target Unit with {commandData.targetsIdentifiers[0]} UnitIdentifier");
        }
        commandData.onCommandCompletedCallback?.Invoke();
    }
示例#7
0
 public override void Execute(CommonCommandData commandData, OptionalCommandData optionalData = null)
 {
     foreach (var target in commandData.targetsIdentifiers)
     {
         var targetUnit = UnitManager.Instance.GetActiveCharacter(target);
         Instantiate(ParticlePrefab, targetUnit.transform);
     }
     commandData.onCommandCompletedCallback?.Invoke();
 }
示例#8
0
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var actor = UnitManager.Instance.GetActiveCharacter(commandData.actor);

        actor.TriggerAttackAnim(null, () =>
        {
            commandData.onCommandCompletedCallback?.Invoke();
        });
    }
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalCommandData = null)
    {
        if (optionalCommandData == null || optionalCommandData.Position == null)
        {
            Debug.Log("[MoveUnitCommand] Move unit command requires OptionalCommandData object with position");
        }

        var actor          = UnitManager.Instance.GetActiveCharacter(commandData.actor);
        var targetPosition = optionalCommandData.Position;

        actor.TriggerMoveToEmpty(targetPosition, commandData.onCommandCompletedCallback);
    }
示例#10
0
    public override void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var currentWorldModel       = WorldModelService.Instance.GetCurrentWorldModelLayer();
        var actor                   = UnitManager.Instance.GetActiveCharacter(commandData.actor);
        var target                  = UnitManager.Instance.GetActiveCharacter(commandData.targetsIdentifiers[0]);
        var deltaPositionNormalized = (actor.transform.position - target.transform.position).normalized;

        deltaPositionNormalized = teleportType == TeleportType.InFront ? deltaPositionNormalized : -deltaPositionNormalized;

        actor.Unit.UnitData.Position = target.transform.position + deltaPositionNormalized * DISTANCE_AFTER_TELEPORT;

        commandData.onCommandCompletedCallback?.Invoke();
    }
示例#11
0
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var unit     = UnitManager.Instance.GetActiveCharacter(commandData.actor);
        var particle = Instantiate(ParticlePrefab, unit.transform);

        var rotation = -Mathf.Atan2(unit.transform.position.z - optionalData.Position.z, unit.transform.position.x - optionalData.Position.x) * Mathf.Rad2Deg - 90;

        particle.transform.rotation = Quaternion.Euler(90f, rotation, 0f);

        DOVirtual.DelayedCall(delayDuration, () =>
        {
            commandData.onCommandCompletedCallback?.Invoke();
        });
    }
    public override void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var CurrentWorldModelLayer = WorldModelService.Instance.GetCurrentWorldModelLayer();

        if (CurrentWorldModelLayer.TryGetUnit(commandData.actor, out var actor))
        {
            actor.UnitData.Position = optionalData.Position;
        }
        else
        {
            Debug.LogError($"Couldn't find actor Unit with {commandData.actor} UnitIdentifier");
        }
        commandData.onCommandCompletedCallback?.Invoke();
    }
示例#13
0
    public override void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        var CurrentWorldModelLayer = WorldModelService.Instance.GetCurrentWorldModelLayer();

        if (CurrentWorldModelLayer.TryGetUnit(commandData.actor, out var actor) && CurrentWorldModelLayer.TryGetUnit(commandData.targetsIdentifiers[0], out var target))
        {
            var deltaPositionNormalized = (actor.UnitData.Position - target.UnitData.Position).normalized;
            actor.UnitData.Position = target.UnitData.Position + deltaPositionNormalized * STOP_BEFORE_TARGET_DISTANCE;
        }
        else
        {
            Debug.LogError($"Couldn't find actor Unit with {commandData.actor} UnitIdentifier or target Unit with {commandData.targetsIdentifiers[0]} UnitIdentifier");
        }
        commandData.onCommandCompletedCallback?.Invoke();
    }
    public void OnTargetsChosen(TargetingResultData targetingResultData)
    {
        if (activeAbility == null)
        {
            Debug.LogError("[PlayerActionManager] Trying to dispatch OnTargetsChosen with no active ability!");
            return;
        }

        Debug.Log($"Dispatching ability {activeAbility.AbilityName} on {targetingResultData.targetPoint} with {targetingResultData.unitIdentifiers.Count}");

        var commonCommandData   = new CommonCommandData(activeCharacter.GetUnitIdentifier(), targetingResultData.unitIdentifiers, activeAbility, null);
        var optionalCommandData = new OptionalCommandData(targetingResultData.targetPoint);

        new AbilitySequenceHandler(activeAbility.AbilityCommandQueue, commonCommandData, optionalCommandData, EndPlayerActionPhase).Begin();
    }
示例#15
0
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalCommandData = null)
    {
        var actor  = UnitManager.Instance.GetActiveCharacter(commandData.actor);
        var target = UnitManager.Instance.GetActiveCharacter(commandData.targetsIdentifiers[0]);
        var deltaPositionNormalized = (actor.transform.position - target.transform.position).normalized;

        deltaPositionNormalized = teleportType == TeleportType.InFront ? deltaPositionNormalized : -deltaPositionNormalized;

        actor.TriggerMoveToEmpty(target.transform.position + deltaPositionNormalized * DISTANCE_AFTER_TELEPORT, null, true);

        var actorRotation = -Mathf.Atan2(actor.transform.position.z - target.transform.position.z, actor.transform.position.x - target.transform.position.x) * Mathf.Rad2Deg - 90;

        actor.transform.rotation = Quaternion.Euler(0f, actorRotation, 0f);

        commandData.onCommandCompletedCallback?.Invoke();
    }
示例#16
0
    public override void Execute(CommonCommandData commandData, OptionalCommandData optionalData = null)
    {
        foreach (var targetIdentifier in commandData.targetsIdentifiers)
        {
            var target = UnitManager.Instance.GetActiveCharacter(targetIdentifier);

            foreach (var effect in commandData.unitAbility.AbilityEffects)
            {
                if (effect is TauntEffect tauntEffect)
                {
                    tauntEffect.OptionalTarget = UnitManager.Instance.GetActiveCharacter(commandData.actor);
                    tauntEffect.tauntTarget    = tauntEffect.OptionalTarget;
                    target.Unit.UnitState.AddActionEffect(effect);
                    target.RefreshLabel();
                    continue;
                }

                target.Unit.UnitState.AddActionEffect(effect);
                effect.Affect(target, false);
            }
        }
        commandData.onCommandCompletedCallback?.Invoke();
    }
 public TurnAction(Queue <AbstractUnitCommand> queueOfCommands, CommonCommandData commonCommandData, OptionalCommandData optionalCommandData)
 {
     QueueOfCommands     = queueOfCommands;
     CommonCommandData   = commonCommandData;
     OptionalCommandData = optionalCommandData;
 }
 public abstract void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null);
示例#19
0
 public override void Simulate(CommonCommandData commandData, OptionalCommandData optionalData = null)
 {
     commandData.onCommandCompletedCallback?.Invoke();
 }
 public abstract void Execute(CommonCommandData commandData, OptionalCommandData optionalData = null);