Пример #1
0
 public virtual IEnumerator SlideIn(FightingEntity user, List <FightingEntity> targets)
 {
     if (slideType == SlideType.STEP_FORWARD)
     {
         Vector3 destination = user.transform.position;
         destination.x += user.IsHeroTeam() ? -stepForwardDistance : stepForwardDistance;
         yield return(GameManager.Instance.time.GetController().StartCoroutine(Slide(user.transform, user.transform.position, destination)));
     }
     else if (slideType == SlideType.MELEE)
     {
         Vector3 destination         = Vector3.zero;
         float   averageTargetRadius = 0;
         foreach (FightingEntity target in targets)
         {
             destination         += target.transform.position;
             averageTargetRadius += target.GetComponent <FighterPositions>().fighterRadius;
         }
         destination         /= targets.Count;
         averageTargetRadius /= targets.Count;
         // Distance target and destination based on the reach of this attack and the width of the target
         float distance = meleeReach + averageTargetRadius;
         destination.x += user.IsHeroTeam() ? distance : -distance;
         yield return(GameManager.Instance.time.GetController().StartCoroutine(Slide(user.transform, user.transform.position, destination)));
     }
 }
Пример #2
0
    public void Initialize(FightingEntity target, int damage, DamageType damageType)
    {
        // Format based on damage type
        if (damageType == DamageType.HEALING)
        {
            damage            = Mathf.Abs(damage);
            _damageText.color = _healColour;
        }
        else if (damageType == DamageType.MANA_RECOVERY)
        {
            _damageText.color = _manaRecoveryColour;
        }

        // Set position
        FighterPositions uiPositions = target.GetComponent <FighterPositions>();

        if (uiPositions != null)
        {
            _worldPosition = uiPositions.damagePopup.position;
        }
        else
        {
            Debug.LogWarning(target.name + " has no damagePopupLocation");
        }
        _worldToScreen.SetWorldPoint(_worldPosition);

        SetText(damage);
        GameManager.Instance.time.GetController().StartCoroutine(Fade());
    }
Пример #3
0
    public override bool QueueAction(FightingEntity user, string[] splitCommand)
    {
        List <int> targetIds = this.GetAllPossibleTargetIds();

        user.SetQueuedAction(this, targetIds);
        return(true);
    }
Пример #4
0
 public BattleFight(BattleField field, FightingEntity fighter, QueuedAction action, BattleUI ui)
 {
     this._field       = field;
     this.fighter      = fighter;
     this.queuedAction = action;
     this._ui          = ui;
 }
Пример #5
0
    public void FinishQTE(FightingEntity user, List <FightingEntity> targets, float power)
    {
        PlayerStats           before, after;
        List <DamageReceiver> receivers = new List <DamageReceiver>();
        int rawDamage = GetRawDamage(user.stats, power);

        foreach (FightingEntity target in targets)
        {
            int damage = (int)(rawDamage * target.stats.GetDamageMultiplierResistance());
            if (!target.IsHeroTeam())
            {
                damage *= 2;
            }
            InstantiateDamagePopup(target, damage);

            before = (PlayerStats)target.stats.Clone();
            target.stats.hp.ApplyDelta(-damage);
            after = (PlayerStats)target.stats.Clone();

            receivers.Add(new DamageReceiver(target, before, after));
        }

        FightResult result = new FightResult(user, this, receivers);

        _battleFight.EndFight(result, this);
    }
Пример #6
0
 public DamageReceiver(FightingEntity fighter, PlayerStats before, PlayerStats after, List <StatusAilment> ailments)
 {
     this.fighter  = fighter;
     this.before   = before;
     this.after    = after;
     this.ailments = ailments;
 }
Пример #7
0
 public FightResult(FightingEntity fighter, ActionBase action, DamageReceiver receiver)
 {
     this.fighter   = fighter;
     this.action    = action;
     this.receivers = new List <DamageReceiver>();
     this.receivers.Add(receiver);
 }
Пример #8
0
    private void UpdateTargetSelectionUI()
    {
        if (potentialTargets == null)
        {
            return;
        }

        for (int i = 0; i < potentialTargets.Count; i++)
        {
            this.SetMaterialOutline(i, false);
        }

        if (this._commandSelector != null)
        {
            // Single target
            int            index  = _commandSelector.GetChoice();
            FightingEntity target = potentialTargets[index];
            this.SetMaterialOutline(index, true);
        }
        else
        {
            // All targets
            for (int i = 0; i < potentialTargets.Count; i++)
            {
                this.SetMaterialOutline(i, true);
            }
        }
    }
Пример #9
0
    private void SetHeroTarget()
    {
        HeroActionConfirmed();

        HeroMenuAction menuAction = GetHeroMenuAction();

        menuAction.targetIndex    = this._commandSelector.GetChoice();
        menuAction.onBackCallback = this.OnTargetChooseBackCallback;

        HeroMenuAction moveMenuAction = GetPreviousHeroMenuAction();

        ActionBase heroAction = moveMenuAction.currentHeroChoices[moveMenuAction.targetIndex].action;

        switch (heroAction.targetInfo.targetType)
        {
        case TargetType.SINGLE:
            List <FightingEntity> possibleTargets = heroAction.GetAllPossibleActiveTargets(this._field.GetHeroPlayer());
            FightingEntity        target          = possibleTargets[menuAction.targetIndex];
            this._field.GetHeroPlayer().SetQueuedAction(heroAction, new List <int> {
                target.targetId
            });
            break;

        case TargetType.ALL:
            List <int> allEnemies = this._field.GetActiveEnemyObjects().Map((EnemyObject enemy) => enemy.targetId);
            this._field.GetHeroPlayer().SetQueuedAction(heroAction, allEnemies);
            break;

        default:
            break;
        }

        this._field.GetHeroPlayer().PlaySound("confirm"); //TODO: Look towards consolidating use here
        this._heroMenuActions.Push(new HeroMenuAction(MenuState.WAITING));
    }
Пример #10
0
    private List <HeroActionChoice> GetHeroActionChoices(ActionType type)
    {
        FightingEntity          heroPlayer         = this._field.GetHeroPlayer();
        List <ActionBase>       actions            = this._field.GetHeroPlayer().GetFilteredActions(type);
        List <HeroActionChoice> currentHeroChoices = new List <HeroActionChoice>();

        foreach (ActionBase action in actions)
        {
            currentHeroChoices.Add(new HeroActionChoice(action.name, action));
        }

        if (type == ActionType.BASIC)
        {
            if (_field.GetHeroPlayer().GetFilteredActions(ActionType.MAGIC).Count != 0)
            {
                currentHeroChoices.Insert(1, new HeroActionChoice("Magic", null));
            }
        }

        HeroMenuAction menuAction = GetHeroMenuAction();

        menuAction.targetIndex        = 0;
        menuAction.currentHeroChoices = currentHeroChoices;

        return(currentHeroChoices);
    }
Пример #11
0
    public void SetTurnOrder(List <FightingEntity> fighters)
    {
        this.turnOrderHeaderText.gameObject.SetActive(true);
        turnTexts   = new List <BasicText>();
        this.arrows = new List <GameObject>();
        this.index  = 0;
        for (int i = 0; i < fighters.Count; i++)
        {
            FightingEntity fighter          = fighters[i];
            BasicText      instantiatedText = Instantiate <BasicText>(turnTextPrefab);
            instantiatedText.text.SetText(fighter.Name);
            instantiatedText.text.color = fighter.GetOrderColor();



            instantiatedText.transform.SetParent(turnOrderParent);
            turnTexts.Add(instantiatedText);

            if (i != fighters.Count - 1)
            {
                GameObject arrow = Instantiate(arrowPrefab);
                arrow.transform.SetParent(turnOrderParent);
                arrows.Add(arrow);
            }
        }
    }
Пример #12
0
    public override IEnumerator SlideIn(FightingEntity user, List <FightingEntity> targets)
    {
        // Slide toward enemies despite Explosion targeting all fighters
        List <FightingEntity> enemyTargets = targets.Filter(target => target.isEnemy());

        yield return(GameManager.Instance.time.GetController().StartCoroutine(base.SlideIn(user, enemyTargets)));
    }
Пример #13
0
    public override FightResult ApplyEffect(FightingEntity user, List <FightingEntity> targets)
    {
        PlayerStats           before, after;
        List <DamageReceiver> receivers = new List <DamageReceiver>();

        foreach (FightingEntity target in targets)
        {
            before = (PlayerStats)target.stats.Clone();
            // Debuff user, buff others
            if (target == user)
            {
                target.ailmentController.TryInflictAilment(debuffAilment);
            }
            else
            {
                target.ailmentController.TryInflictAilment(buffAilment);
            }
            after = (PlayerStats)target.stats.Clone();
            receivers.Add(new DamageReceiver(user, before, after, new List <StatusAilment>()
            {
                debuffAilment.statusAilment
            }));
        }
        return(new FightResult(user, this, receivers));
    }
Пример #14
0
    public int GetManaRestored(FightingEntity user, float power)
    {
        float baseMana     = user.stats.physical.GetValue() * effects.physicalScaling + user.stats.special.GetValue() * effects.specialScaling;
        int   manaRestored = (int)(baseMana * power);

        return(manaRestored);
    }
Пример #15
0
 public override bool QueueAction(FightingEntity user, string[] splitCommand)
 {
     user.SetQueuedAction(this, new List <int> {
         GameManager.Instance.battleComponents.field.GetHeroPlayer().targetId
     });
     return(true);
 }
Пример #16
0
    private bool CheckCost(FightingEntity user, ActionChoiceResult response)
    {
        PlayerStats stats = user.stats;

        if (stats.hp.GetValue() <= actionCost.HP)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "HP", name, actionCost.HP));
            return(false);
        }
        else if (stats.mana.GetValue() < actionCost.mana)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "MANA", name, actionCost.mana));
            return(false);
        }
        else if (currPP < actionCost.PP)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "PP", name, actionCost.PP));
            return(false);
        }
        else if (user is Mook && ((Mook)user).stamina.GetStamina() < actionCost.stamina)
        {
            response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST);
            response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "STAMINA", name, actionCost.stamina));
            return(false);
        }

        return(true);
    }
Пример #17
0
    public override FightResult ApplyEffect(FightingEntity user, List <FightingEntity> targets)
    {
        ManaShiftQTE qte = Instantiate(_manaShiftQTE).GetComponent <ManaShiftQTE>();

        qte.Initialize(user, targets, this);
        return(new FightResult(user, this));
    }
Пример #18
0
    public virtual FightResult ApplyEffect(FightingEntity user, List <FightingEntity> targets)
    {
        PlayerStats           before, after;
        List <DamageReceiver> receivers = new List <DamageReceiver>();

        foreach (FightingEntity target in targets)
        {
            int damage = GetDamageToTarget(user, target);
            InstantiateDamagePopup(target, damage);

            before = (PlayerStats)target.stats.Clone();
            target.stats.hp.ApplyDelta(-damage);
            List <StatusAilment> inflicted = InflictStatuses(target);
            after = (PlayerStats)target.stats.Clone();

            // TODO: Unit test this
            //if (before.hp.GetValue() - after.hp.GetValue() != damage) {
            //    Debug.LogError("ERROR: Logging stats doesn't match real thing!: " + after.hp.GetValue() + " " + before.hp.GetValue() + " " + damage);
            //}


            receivers.Add(new DamageReceiver(target, before, after, inflicted));
        }
        return(new FightResult(user, this, receivers));
    }
Пример #19
0
 protected void TargetFlash(FightingEntity target)
 {
     if (targetFlash)
     {
         GameManager.Instance.time.GetController().StartCoroutine(target.GetAnimController().Flash());
     }
 }
Пример #20
0
    public virtual bool QueueAction(FightingEntity user, string[] splitCommand)
    {
        if (targetInfo.targetType == TargetType.SINGLE && splitCommand.Length == 2)
        {
            int targetId = this.GetTargetIdFromString(splitCommand[1], user);
            user.SetQueuedAction(this, new List <int> {
                targetId
            });
        }
        else if (targetInfo.targetType == TargetType.ALL && splitCommand.Length == 1)
        {
            List <int> targetIds = GetAllPossibleActiveTargets(user).Map(target => target.targetId);
            user.SetQueuedAction(this, targetIds);
        }
        else if (targetInfo.targetType == TargetType.RANDOM && splitCommand.Length == 1)
        {
            user.SetQueuedAction(this, new List <int> {
            });
        }
        else if (targetInfo.targetType == TargetType.NONE && splitCommand.Length == 1)
        {
            user.SetQueuedAction(this, new List <int> {
            });
        }

        return(true);
    }
Пример #21
0
    private bool CheckValidTarget(FightingEntity user, string[] splitCommand, ActionChoiceResult response)
    {
        bool res = false;

        if (targetInfo.targetType == TargetType.SINGLE && splitCommand.Length == 2)
        {
            int targetId = this.GetTargetIdFromString(splitCommand[1], user);
            res = targetId != -1;
        }
        else if (targetInfo.targetType == TargetType.ALL && splitCommand.Length == 1)
        {
            res = true;
        }
        else if (targetInfo.targetType == TargetType.RANDOM && splitCommand.Length == 1)
        {
            res = true;
        }
        else if (targetInfo.targetType == TargetType.NONE && splitCommand.Length == 1)
        {
            res = true;
        }

        if (!res)
        {
            response.SetState(ActionChoiceResult.State.INVALID_TARGET);
            response.AddMessage(string.Format(Messages.WRONG_NUMBER_OF_TARGETS, name, this.GetExampleCommandString()));
        }
        return(res);
    }
Пример #22
0
    private float _avgEffectiveness = -1f;  // [-1 , 1], try some moves before effectiveness goes up

    public FightingEntityAI(FightingEntity fe, float precision, float weight)
    {
        this._char = fe;
        _precision = precision;
        _weight    = weight;
        InitializeMovesetScore(this._char.actions, _precision);
    }
Пример #23
0
 public override bool QueueAction(FightingEntity user, string[] splitCommand)
 {
     user.SetQueuedAction(this, new List <int> {
         user.targetId
     });
     return(true);
 }
Пример #24
0
 protected void InstantiateDamagePopup(FightingEntity target, int damage, DamageType damageType)
 {
     if (damagePopupCanvasPrefab != null)
     {
         DamagePopup popup = Instantiate(damagePopupCanvasPrefab).GetComponent <DamagePopup>();
         popup.Initialize(target, damage, damageType);
     }
 }
Пример #25
0
 public bool TargetsDead(FightingEntity user, List <int> targetIds)
 {
     if (targetInfo.targetType == TargetType.NONE || targetInfo.targetType == TargetType.RANDOM)
     {
         return(false);
     }
     return(GetTargets(user, targetIds).Count == 0);
 }
Пример #26
0
 protected List <FightingEntity> SetTargets(FightingEntity user, List <FightingEntity> targets)
 {
     if (targetInfo.targetType == TargetType.RANDOM)
     {
         return(GetNewTargets(user));
     }
     return(targets);
 }
Пример #27
0
    protected override void AnimateUser(FightingEntity user)
    {
        AnimationController controller = user.GetAnimController();

        controller.AddToTrack("idle", "defend start", false, 0);
        controller.AddToTrack("idle", "defend end", false, 2f);
        controller.AddToTrack("idle", "idle", true, 0);
    }
Пример #28
0
 // Return targets that should be focused during this action
 public List <FightingEntity> GetFocusedTargets(FightingEntity user, List <int> targetIds)
 {
     if (targetInfo.targetType == TargetType.RANDOM)
     {
         return(GetAllPossibleActiveTargets(user));
     }
     return(GetTargets(user, targetIds));
 }
Пример #29
0
 public override bool QueueAction(FightingEntity user, string[] splitCommand)
 {
     // Can only use mana pot on Hero
     user.SetQueuedAction(this, new List <int> {
         0
     });
     return(true);
 }
Пример #30
0
    protected override void AnimateUser(FightingEntity user)
    {
        AnimationController controller = user.GetAnimController();
        int track = controller.TakeFreeTrack();

        controller.AddToTrack(track, "heal start", false, 0);
        controller.AddToTrack(track, "heal end", false, 1.5f);
        controller.EndTrackAnims(track);
    }