Example #1
0
    // return a string with the added hp
    public string UsePotion(PlayerScript potionUser)
    {
        PartyStats partyStats = this.gameObject.transform.parent.gameObject.GetComponent <PartyStats>();
        Potion     currPotion = potionUser.Potions[potionUser.currPotionInd];

        bool shouldRevive = false;

        if (this.HP <= 0 && currPotion.HPBoost > 0)
        {
            shouldRevive = true;
        }

        string toReturn = this.GainHP(currPotion.HPBoost);

        if (toReturn == "0")
        {
            toReturn = currPotion.MPBoost.ToString() + " MP gained";
        }
        else
        {
            StartCoroutine(playHealthAnimation("HealthUp"));
        }
        partyStats.partyMP += currPotion.MPBoost;

        if (shouldRevive)
        {
            _playerPartsAnimator.SetBool("dead", false);
            if (healthyBodyPart && deadBodyPart)
            {
                healthyBodyPart.SetActive(true);
                deadBodyPart.SetActive(false);
            }

            myTBS = GameObject.Find("TurnBasedSystem").GetComponent <TurnBasedSystem>();
            if (this.name == "Player")
            {
                this.tag = "PlayerUnit";
                myTBS.shouldTurnOffFlips = -1;
            }
            else if (this.name == "Companion")
            {
                this.tag = "CompanionUnit";
                myTBS.shouldTurnOffFlips = -1;
            }
        }
        return(toReturn);
    }
Example #2
0
    ///[SerializeField]
    ///private GameObject resetButton;

    void Start()
    {
        partyCore    = this.gameObject.GetComponent <PartyStats>();
        partyMove    = this.gameObject.GetComponent <PlayerMovementControles>();
        lastPosition = characterRep.transform.position;
    }
Example #3
0
    public void UseAttack(GameObject target, int i)
    {
        PlayerScript targetPlayerScript = target.GetComponent <PlayerScript>();
        PartyStats   currPartyStats     = party.GetComponent <PartyStats>();
        Attack       chosenAtk          = _player.Attacks[i];

        myTBS = GameObject.Find("TurnBasedSystem").GetComponent <TurnBasedSystem>();

        // Handling damage:
        if (currPartyStats.partyMP >= chosenAtk.MpDemand)
        {
            currPartyStats.partyMP -= chosenAtk.MpDemand;

            // signal animation to start
            StartCoroutine(playPlayerAnimation("isAttack"));
            if (chosenAtk.MpDemand > 0 && _playerStarAnimator)
            {
                StartCoroutine(playStarAnimation("changedAttribute"));
            }

            // Activating effects:
            for (int k = 0; k < chosenAtk.Effects.Length; k++)
            {
                if (myTBS.activeEffects.Find(myItem => myItem.name == chosenAtk.Effects[k].name))
                {
                    // already active:
                    chosenAtk.Effects[k].UpdateDuration();
                }
                else
                {
                    chosenAtk.Effects[k].DoAction();
                    myTBS.activeEffects.Add(chosenAtk.Effects[k]);
                }
            }

            if (chosenAtk.IsPureEffect)
            {
                myTBS.NextTurn();
            }
            else
            {
                bool didHit = TryHit(target);
                if (!didHit)
                {
                    if (target.name == "Boss")
                    {
                        UpdateInfoHUD(target, "Miss!", 1.6f, 0.9f);
                    }
                    else
                    {
                        UpdateInfoHUD(target, "Miss!", 1.6f, 0.0f);
                    }

                    StartCoroutine(WaitForNextTurn());
                }
                else
                {
                    float enhancement   = Random.Range(chosenAtk.LowerRangeEnhancer, chosenAtk.UpperRangeEnhancer);
                    float baseWeaponDmg = Random.Range(_player.Weapon.DmgMin, _player.Weapon.DmgMax);
                    float dmg           = (baseWeaponDmg + _player.Strength) * enhancement;
                    // Rounding to a whole number:
                    dmg = Mathf.Round(dmg);
                    float criticalProbVal = Random.value;
                    if (criticalProbVal <= chosenAtk.CriticalEnhancementProb)
                    {
                        if (target.name == "Boss")
                        {
                            UpdateInfoHUD(target, "Critical", 2.7f, 0.9f);
                        }
                        else
                        {
                            UpdateInfoHUD(target, "Critical", 2.7f, 0.0f);
                        }

                        dmg *= chosenAtk.CriticalEnhancementRatio;
                    }
                    // float attackMultiplier = (Random.value * (this.maxAttackMultiplier - this.minAttackMultiplier)) + this.minAttackMultiplier;
                    targetPlayerScript.ReceiveDamage(dmg);
                }
            }
        }
        else
        {
            UpdateInfoHUD(this.gameObject, "Missing Star Power", 4.0f, 0.0f);
            myTBS.PlayTurn(this.gameObject);
        }
    }