Ejemplo n.º 1
0
    private BattleText CreateObjects(Combatant combatant)
    {
        BattleText bt = null;
        GameObject txtObj = new GameObject();
        Transform trans = TransformHelper.GetChild(this.posChild, combatant.prefabInstance.transform);
        txtObj.transform.position = trans.position;
        if(DataHolder.BattleSystemData().mountTexts)
        {
            txtObj.transform.parent = trans;
        }
        if(GUISystemType.ORK.Equals(DataHolder.GameSettings().guiSystemType))
            bt = txtObj.AddComponent<BattleText>();
        else
            bt = (BattleTextGUI)txtObj.AddComponent<BattleTextGUI>();

        if(this.spawnPrefab)
        {
            GameObject pref = this.GetPrefab();
            if(pref != null)
            {
                trans = TransformHelper.GetChild(this.prefabChild, combatant.prefabInstance.transform);
                pref.transform.position = trans.position+trans.TransformDirection(this.prefabOffset);
                pref.transform.rotation = trans.rotation;
                if(DataHolder.BattleSystemData().mountTexts)
                {
                    pref.transform.parent = trans;
                }
                if(this.prefabTime > 0)
                {
                    DestroyAfterTime comp = pref.AddComponent<DestroyAfterTime>();
                    comp.time = this.prefabTime;
                }
            }
        }
        if(this.playAudio)
        {
            AudioSource s = combatant.GetAudioSource();
            if(s != null)
            {
                s.PlayOneShot(this.GetAudioClip());
            }
        }
        return bt;
    }
Ejemplo n.º 2
0
    /*
    ============================================================================
    Use functions
    ============================================================================
    */
    public bool Use(Combatant user, int element, Combatant target, float damageFactor, float damageMultiplier)
    {
        bool hit = false;

        if(target.IsBlockBaseAttacks())
        {
            DataHolder.BattleSystemData().blockTextSettings.ShowText("", target);
        }
        else if((user is Enemy || this.ConsumeItems()) &&
            (!this.hitChance || DataHolder.GameSettings().GetRandom() <=
            (DataHolder.Formulas().formula[this.hitFormula].Calculate(user, target) + user.GetHitBonus())))
        {
            hit = true;

            int eID = user.GetEffectAttackElement();
            if(eID < 0)
            {
                eID = element;
            }

            ValueChange[] changes = this.consume;
            AudioClip clip = null;

            if(this.hasCritical && DataHolder.GameSettings().GetRandom() <=
                DataHolder.Formula(user.baseCritical).Calculate(user, target) + user.GetCriticalBonus())
            {
                changes = this.criticalConsume;
                clip = this.GetCriticalAudio();
            }

            if(clip == null)
            {
                clip = this.GetAttackAudio();
            }

            if(clip != null && target.prefabInstance != null)
            {
                AudioSource s = target.GetAudioSource();
                if(s != null)
                {
                    s.PlayOneShot(clip);
                }
            }

            for(int i=0; i<changes.Length; i++)
            {
                if(changes[i].active)
                {
                    int change = changes[i].ChangeValue(i, eID, user, target, true, damageFactor, damageMultiplier);
                    if(this.absorb)
                    {
                        change *= this.absorbValue;
                        change /= 100;
                        user.status[i].AddValue(change, true, false, true);
                    }
                }
            }

            this.stealChance.Steal(user, target);
        }
        else
        {
            DataHolder.BattleSystemData().missTextSettings.ShowText("", target);
        }

        return hit;
    }