Ejemplo n.º 1
0
    public void ItemUse()
    {
        if (m_unit == null)
        {
            return;
        }

        if (m_unit.CurUseItem == null)
        {
            return;
        }

        GameObject effObj = null;
        CParticle  effect = null;

        switch (m_unit.CurUseItem.UseItemType)
        {
        case UseItemType.RECORVE:
        {
            m_unit.Status.ChargeHp(m_unit.CurUseItem.Value);
            effObj = CObjectPool.Inst.GetEffect(EffectType.Particle, 2);
            if (effObj == null)
            {
                break;
            }
            effect = effObj.GetComponent <CParticle>();
            effect.Show(m_unit);
            effect.transform.position = transform.position;
        }
        break;

        case UseItemType.STAMINA:
        {
            m_unit.Status.StaminaCharge(m_unit.CurUseItem.Value);
            effObj = CObjectPool.Inst.GetEffect(EffectType.Particle, 3);
            if (effObj == null)
            {
                break;
            }
            effect = effObj.GetComponent <CParticle>();
            effect.Show(m_unit);
            effect.transform.position = transform.position;
        }
        break;

        case UseItemType.BUFF:
        {
            switch (m_unit.CurUseItem.BuffType)
            {
            case BuffType.Element:
            {
                if (m_unit.MainHook != null)
                {
                    int nElement = Random.Range(5, 8);
                    effObj = CObjectPool.Inst.GetEffect(EffectType.Particle, nElement);

                    if (effObj == null)
                    {
                        break;
                    }

                    effect = effObj.GetComponent <CParticle>();
                    effect.Show(m_unit);
                    effect.transform.parent        = m_unit.MainHook.transform;
                    effect.transform.localPosition = Vector3.zero;

                    if (m_unit.UnitUI != null)
                    {
                        m_unit.UnitUI.BuffIn(m_unit.CurUseItem.BuffType, (Stat.Element)(nElement - 8));
                    }
                }
            }
            break;

            case BuffType.None:
                break;

            default:
            {
                effObj = CObjectPool.Inst.GetEffect(EffectType.Particle, 4);
                if (effObj == null)
                {
                    break;
                }
                effect = effObj.GetComponent <CParticle>();
                effect.Show(m_unit);
                effect.transform.parent        = transform;
                effect.transform.localPosition = Vector3.zero;
                if (m_unit.UnitUI != null)
                {
                    m_unit.UnitUI.BuffIn(m_unit.CurUseItem.BuffType);
                }
            }
            break;
            }
        }
        break;

        case UseItemType.BIND:
            break;

        case UseItemType.SHOOT:
            break;
        }

        m_unit.CurUseItem = null;
    }
Ejemplo n.º 2
0
    protected override void OnTriggerEnter(Collider other)
    {
        if (m_unit == null)
        {
            return;
        }

        HitType    hitType    = HitType.None;
        ActionAnim actionAnim = m_unit.ActCtrl.PastAnim;

        CBaseCollider baseCollider = other.GetComponent <CBaseCollider>();

        if (baseCollider != null)
        {
            baseCollider.ApponentColliderIn(m_weapon.WeaponStat, hitType, actionAnim);

            if (baseCollider is CArmorCollider || baseCollider is CGuardCollider)
            {
                return;
            }
        }

        CUnit otherUnit = other.GetComponent <CUnit>();

        if (actionAnim != null)
        {
            hitType = m_unit.ActCtrl.PastAnim.hitType;
        }

        if (otherUnit != null && otherUnit.UnitTag != m_unit.UnitTag)
        {
            otherUnit.GetDamage(m_weapon.WeaponStat, hitType, m_unit, actionAnim);
            if (CObjectPool.Inst != null)
            {
                GameObject hitObject = null;
                CParticle  particle  = null;
                switch (m_weapon.WeaponStat.physicsType)
                {
                case Stat.PhysicalType.Slash:
                    hitObject = CObjectPool.Inst.GetEffect(EffectType.Particle, 1);
                    break;

                case Stat.PhysicalType.Strike:
                    hitObject = CObjectPool.Inst.GetEffect(EffectType.Particle, 0);
                    break;
                }

                if (hitObject == null)
                {
                    return;
                }
                particle = hitObject.GetComponent <CParticle>();
                if (particle != null)
                {
                    particle.Show(m_unit);
                    hitObject.transform.position = transform.position;
                    hitObject.SetActive(true);
                }
            }
        }
    }