Пример #1
0
        /// <summary>
        ///     播放受伤血浮动
        /// </summary>
        /// <param name="isDodge">是否闪避</param>
        /// <param name="isCrit">是否暴击</param>
        /// <param name="isParry">是否格挡</param>
        /// <param name="cutHp">掉血量</param>
        /// <param name="curHp">总的血量</param>
        /// <param name="color">掉血数字颜色</param>
        public virtual void AddHudView(bool isDodge, bool isCrit, bool isParry, int cutHp, int curHp, Color color)
        {
            var    type      = HeadInfoItemType.TypeNormal;
            string value     = "";
            Color  showColor = color;

            if (isDodge) // 闪避
            {
                showColor = Color.green;
                value     = "MISS!";
                type      = HeadInfoItemType.TypeDodge;
            }
            else
            {
                if (isCrit)
                {
                    value     = "暴击" + cutHp;
                    showColor = Color.cyan;
                    type      = HeadInfoItemType.TypeCrit;
                }
                else
                {
                    if (isParry)
                    {
                        value = "格挡" + cutHp;
                    }
                    else
                    {
                        value = "-" + cutHp;
                    }
                }
            }
            Vector3 pos = MeController.transform.position;

            pos.y += MeController.GetMeByType <ActionDisplay>().BoxCollider2D.size.y *0.6f;
            HeadInfoItemManager.Instance.ShowHeadInfo(value, showColor, pos, MeController.Me.CurFaceDire, type);
            BaseRoleVo.CurHp = curHp >= 0 ? (uint)curHp : 0;
        }
Пример #2
0
        /// <summary>
        ///     攻击伤害检测
        /// </summary>
        public bool CheckDamage(Vector3 effectPosition, int index)
        {
            SysSkillBaseVo skillVo = CurrentSkillVo;

            print(skillVo.unikey);
            if (!MeController.Me.IsUsing)
            {
                return(false);
            }
            bool result = false;

            switch (MeController.Me.Type)
            {
            case DisplayType.PET:
                result = DamageCheck.Instance.CheckPetInjured2D(MeController, skillVo, effectPosition,
                                                                _selfTransform.position,
                                                                MeController.Me.CurFaceDire, GetEnemyDisplay(), _currentActionVo.IsBullet, _checkedTime, index,
                                                                AppMap.Instance.mapParser.NeedSyn);
                break;

            case DisplayType.ROLE:
                //主角攻击的伤害检测
                bool needSyn = AppMap.Instance.mapParser.NeedSyn;
                if (MeController.GetMeVo().Id == AppMap.Instance.me.GetVo().Id)
                {
                    result = DamageCheck.Instance.CheckMeInjured2D(MeController, skillVo, effectPosition,
                                                                   _selfTransform.position,
                                                                   MeController.Me.CurFaceDire, GetEnemyDisplay(), _currentActionVo.IsBullet, _checkedTime,
                                                                   index, needSyn);
                    if (result)
                    {
                        CameraEffectManager.NormalAttackShake();
                        if (MeVo.instance.CurMp < MeVo.instance.Mp)
                        {
                            MeVo.instance.CurMp += 1;
                        }
                        PlayBeAttackedSound(skillVo.unikey);     //播放受击音效
                    }
                }
                else
                {
                    //其他玩家攻击的伤害检测
                    var playerVo = MeController.GetMeVoByType <PlayerVo>();
                    result = DamageCheck.Instance.CheckPlayerInjured2D(MeController, skillVo, playerVo, effectPosition,
                                                                       _selfTransform.position,
                                                                       MeController.Me.CurFaceDire, GetEnemyDisplay(), _currentActionVo.IsBullet, _checkedTime, index, needSyn);
                    if (!needSyn && result)
                    {
                        if (playerVo.CurMp < playerVo.Mp)
                        {
                            playerVo.CurMp += 1;
                        }
                    }
                }
                break;

            case DisplayType.MONSTER:     //怪物攻击的碰撞检测
                result = DamageCheck.Instance.MonsterCheckInjured2D(MeController, skillVo, effectPosition, _selfTransform.position,
                                                                    MeController.Me.CurFaceDire, (MeController.Me.GetVo() as MonsterVo), index);
                if (MeController.Me.DefenceEffect != null)
                {
                    MeController.Me.DefenceEffect.transform.position = Vector3.one * 1000;
                }
                break;

            case DisplayType.Trap:
                DamageCheck.Instance.TrapCheckInjured2D(skillVo, effectPosition,
                                                        MeController.Me.CurFaceDire, (MeController.GetMeByType <TrapDisplay>().BoxCollider2D));
                break;
            }
            if (skillVo.shake && MeController.GetMeVo().Id == MeVo.instance.Id)
            {
                CameraEffectManager.ShakeCamera(0, 0.6f); //增加技能震屏效果
            }
            if (result)
            {
                _checkedTime++;
            }
            return(result);
        }