Esempio n. 1
0
    //如何体现攻速呢??
    public override void Attack(int type)
    {
        if (!(type == 1 || type == 0))
        {
            return;
        }

        if (_PlayerControl.GetPlayerState() != PlayerState.Jump)
        {
            float DamageValue = Attritube.GetFloat(PlayerAttritubeType.Attack);

            switch (type)
            {
            case 0:
                _Animator.SetInteger("State", (int)_AnimState.Attack);
                break;

            case 1:
                _Animator.SetInteger("State", (int)_AnimState.Attack_2);
                DamageValue *= 0.75f;
                break;

            default:
                break;
            }


            if (!OnAttack)
            {
                StartCoroutine(OnAttackWhile(_Weapon.GetComponent <ColliderMessage>(), DamageValue));
            }
        }
    }
    /// <summary>
    /// 受到伤害处理
    /// </summary>
    /// <param name="value"></param>
    public virtual void Damage(float value)
    {
        OnDamage = true;

        if (this == null)
        {
            return;
        }

        NewDamageText(value);

        float Hp    = Attritube.GetFloat(UnitDynamicAttritubeType.Hp);
        float MaxHp = Attritube.GetFloat(UnitStaticAttritubeType.MaxHp);

        if ((Hp -= value) <= 0)
        {
            Death();
        }

        Attritube.SetAttr(UnitDynamicAttritubeType.Hp, Hp);

        FlashHpBat(Hp, MaxHp);

        if (value < 0)
        {
            StartCoroutine(DamageColor(Color.green));
        }
        else
        {
            StartCoroutine(DamageColor(Color.red));
        }
    }
Esempio n. 3
0
    public override void Damage(float value)
    {
        base.Damage(value);

        float Hp    = Attritube.GetFloat(UnitDynamicAttritubeType.Hp);
        float MaxHp = Attritube.GetFloat(UnitStaticAttritubeType.MaxHp);

        _PlayerStateBarContorl.SetHpBarLength(Hp / MaxHp);
    }
    /// <summary>
    /// 创建一个伤害文本
    /// </summary>
    /// <param name="value">伤害量</param>
    /// <param name="disdent">离父距离</param>
    /// <param name="SizeMult">大小倍数,伤害量是MaxHP的100%则文本大小为SizeMult倍</param>
    /// <param name="MinSize">最大size</param>
    /// <param name="MaxSize">最小size</param>
    /// <returns>创建的文本</returns>
    GameObject NewDamageText(float value, Vector3 Offset, float disdent, float SizeMult, float MinSize, float MaxSize)
    {
        if (_PlayerCamera == null)
        {
            _PlayerCamera = GameObject.Find("PlayerCamera");
        }

        GameObject textC = (GameObject)Instantiate(Resources.Load(_DamageTextC_Prefab_Path));

        textC.transform.position = transform.position + Vector3.Normalize(_PlayerCamera.transform.position - transform.position) * disdent + Offset;
        textC.GetComponentInChildren <Text>().text = "" + (int)value;
        textC.transform.localScale *= Mathf.Clamp(SizeMult * (value / Attritube.GetFloat(UnitStaticAttritubeType.MaxHp)), MinSize, MaxSize);
        return(textC);
    }
Esempio n. 5
0
    public override void InitUnitMonoBehaciour()
    {
        _Renderer = _Model.GetComponent <SkinnedMeshRenderer>();

        _PlayerControl = GetComponent <PlayerControl>();

        _PlayerCamera = GameObject.Find("PlayerCamera");

        StateBatContorl.SetHpBarLength(Attritube.GetFloat(PlayerAttritubeType.Hp) / Attritube.GetFloat(PlayerAttritubeType.MaxHp));

        StateBatContorl.SetMpBarLength(Attritube.GetFloat(PlayerAttritubeType.Mp) / Attritube.GetFloat(PlayerAttritubeType.MaxMp));

        StateBatContorl.SetLevelText(Attritube.GetIntger(PlayerAttritubeType.Level));

        _UnitMove = GetComponent <PlayerMove>();
    }
Esempio n. 6
0
    public IEnumerator Attacking(GameObject go)
    {
        OnAttack = true;

        while (IsTurning())
        {
            yield return(new WaitForSeconds(Time.deltaTime));
        }

        while (go != null)
        {
            _Actions.Fire();

            UnitMonoBehaciour targetMono = go.GetComponent <UnitMonoBehaciour>();

            DoBuff(targetMono);

            float Damage = Attritube.GetFloat(UnitStaticAttritubeType.Attack) + Attritube.GetFloat(UnitDynamicAttritubeType.AttackAdd);

            BoomParcitle(go, Damage);

            targetMono.Damage(Damage);

            ParticleContorl.Play(ParticleType.fire, FireMouse, Fire.transform);

            //if (AttackIdel >= 1f)
            //{
            _Actions.Idle();
            //}

            if (go == null)
            {
                break;
            }

            float idel = Attritube.GetFloat(UnitStaticAttritubeType.AttackSpeed) + Attritube.GetFloat(UnitDynamicAttritubeType.AttackSpeedAdd);

            yield return(new WaitForSeconds(idel));
        }

        _Actions.Idle();

        OnAttack = false;

        SelectAttackGameObject();
    }
Esempio n. 7
0
    public void PlayerInit()
    {
        _PlayerStateBarContorl.SetHpBarLength(1);
        _PlayerStateBarContorl.SetMpBarLength(0);
        _PlayerStateBarContorl.SetLevelText(0);

        Attritube = base.LoadAttritube("CannonTower", typeof(UnitStaticAttritubeType));

        Attritube.SetAttr(UnitDynamicAttritubeType.Mp, 0);

        foreach (var item in BuffList)
        {
            Destroy(item);
        }

        BuffList = new List <CannonBUFF>();
    }
Esempio n. 8
0
    public void MpAdd(float value)
    {
        float mp    = Attritube.GetFloat(UnitDynamicAttritubeType.Mp);
        float maxMP = Attritube.GetFloat(UnitStaticAttritubeType.MaxMp);

        mp += value;

        if (mp >= maxMP)
        {
            PlayerLevelUp();
        }
        else
        {
            _PlayerStateBarContorl.SetMpBarLength(mp / maxMP);
            Attritube.SetAttr(UnitDynamicAttritubeType.Mp, mp);
            Attritube.SetAttr(UnitStaticAttritubeType.MaxMp, maxMP);
        }
    }
Esempio n. 9
0
    public void PlayerLevelUp()
    {
        float maxMP = Attritube.GetFloat(UnitStaticAttritubeType.MaxMp);

        maxMP += GameContorl.LevelMpAdd;

        int level = Attritube.GetIntger(UnitStaticAttritubeType.Level);

        level++;

        _PlayerStateBarContorl.SetLevelText(level);

        _PlayerStateBarContorl.SetMpBarLength(0);
        Attritube.SetAttr(UnitDynamicAttritubeType.Mp, 0);
        Attritube.SetAttr(UnitStaticAttritubeType.MaxMp, maxMP);
        Attritube.SetAttr(UnitStaticAttritubeType.Level, level);

        GameContorl.RandomBuff();
    }