Пример #1
0
        public BuffResult NetBuffResult(Scene scene, BuffData buff, int damageType, int damageValue, BuffType type, int delayView)
        {
            var caster = buff.GetCaster();
            var bear   = buff.GetBear();
            var nowHp  = bear.GetAttribute(eAttributeType.HpNow);

            if (scene != null && scene.isNeedDamageModify)
            {
                if (Scene.IsNeedChangeHp(bear) != null)
                {
                    nowHp = (int)(nowHp / scene.BeDamageModify);
                }
            }

            var result = new BuffResult
            {
                SkillObjId  = caster.ObjId,
                TargetObjId = bear.ObjId,
                BuffTypeId  = buff.GetBuffId(),
                Type        = type,
                Damage      = damageValue,
                ViewTime    = Extension.AddTimeDiffToNet(delayView),
                Param       = { damageType, nowHp }
            };

            return(result);
        }
Пример #2
0
        //刷新守城方的buff
        private void RefreshDefenderBuff(int buffId, bool isAdd)
        {
            var players = Camps[DefenderCampId].Players;

            if (isAdd)
            {
                foreach (var player in players)
                {
                    player.AddBuff(buffId, 1, player);
                }
            }
            else
            {
                foreach (var player in players)
                {
                    var buffs = player.BuffList.GetBuffById(buffId);
                    if (buffs.Count > 0)
                    {
                        var buff  = buffs[0];
                        var layer = buff.GetLayer();
                        if (layer > 1)
                        {
                            buff.SetLayer(layer - 1);
                            var replyMsg   = new BuffResultMsg();
                            var buffResult = new BuffResult
                            {
                                SkillObjId  = buff.mCasterId,
                                TargetObjId = player.ObjId,
                                BuffTypeId  = buffId,
                                BuffId      = buff.mId,
                                Type        = BuffType.HT_EFFECT,
                                ViewTime    = Extension.AddTimeDiffToNet(0)
                            };
                            if (buff.mBuff.IsView == 1)
                            {
                                buffResult.Param.Add(buff.GetLastSeconds());
                                buffResult.Param.Add(buff.GetLayer());
                                buffResult.Param.Add(buff.m_nLevel);
                            }
                            replyMsg.buff.Add(buffResult);
                            player.BroadcastBuffList(replyMsg);
                            GetBuff.DoEffect(this, player, buff, 0);
                        }
                        else
                        {
                            MissBuff.DoEffect(this, player, buff);
                            player.DeleteBuff(buff, eCleanBuffType.Clear);
                        }
                    }
                    else
                    {
                        Logger.Error("In RefreshDefenderBuff(). DeleteBuff error! buffs.Count == 0! player name = {0}",
                                     player.GetName());
                    }
                }
            }
        }
Пример #3
0
    public override void ShowDamage(BuffResult result)
    {
        if (!CanBeInteractive())
        {
            return;
        }

        base.ShowDamage(result);
    }
Пример #4
0
        //广播地面火球效果
        private void PosGuideBefore(ObjCharacter caster, ObjPlayer target, Vector2 pos, int d)
        {
            //var mTable = Table.GetSkill(5150);
            if (target == null)
            {
                return;
            }
            var buffId   = 1060;
            var replyMsg = new BuffResultMsg();
            var temp     = new BuffResult
            {
                Type       = BuffType.HT_EFFECT,
                BuffTypeId = buffId,
                ViewTime   = Extension.AddTimeDiffToNet(d)
            };

            temp.Param.Add(5150);
            temp.TargetObjId = target.ObjId;
            temp.Param.Add((int)(pos.X * 100));
            temp.Param.Add((int)(pos.Y * 100));
            temp.Param.Add((int)(caster.GetDirection().X *1000));
            temp.Param.Add((int)(caster.GetDirection().Y *1000));
            temp.Param.Add(1500); //mTable.CastParam[1]
            replyMsg.buff.Add(temp);
            target.BroadcastBuffList(replyMsg);
            SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddMilliseconds(1400 + d), () => { FireCast(pos); });
            if (MyRandom.Random(10000) < 5000)
            {
                DropItem(2, MyRandom.Random(MinGold, MaxGold), pos);

                var max = pos2.Count;
                if (IsInspired(target))
                {
                    max = Math.Max(GoldNumInspireMax, 0);
                }
                else
                {
                    max = Math.Max(GoldNumMax, 0);
                }
                // 修改掉落的堆数 走配置  跟是否鼓舞有关系
                oldList = pos2.RandRange(0, max);
                for (int i = 0; i < oldList.Count; ++i)
                {
                    DropItem(2, MyRandom.Random(MinGold, MaxGold), oldList[i]);
                }
            }
        }
Пример #5
0
    public IEnumerator WaitAddBuff(TimeSpan span, BuffResult buff)
    {
        yield return(new WaitForSeconds((float)span.TotalSeconds));

        AddBuff(buff);
    }
Пример #6
0
    private void ShowSkillIndicator(BuffResult buff, ObjCharacter character)
    {
        var skillId = buff.Param[0];

        var data = Table.GetSkill(skillId);

        if (data == null)
        {
            Logger.Log2Bugly("ShowSkillIndicator data =null");
            return;
        }
        if (GameLogic.Instance == null || GameLogic.Instance.Scene == null)
        {
            Logger.Log2Bugly("ShowSkillIndicator GameLogic.Instance =null");
            return;
        }
        //SkillTargetType targetType = (SkillTargetType)data.TargetType;
        var targetType = (SkillTargetType)ObjMyPlayer.GetSkillData_Data(data, eModifySkillType.TargetType);

        if (targetType == SkillTargetType.CIRCLE)
        {
            // correct the direction of npc or monster.
            character.TargetDirection = new Vector3(buff.Param[3] / 1000.0f, 0, buff.Param[4] / 1000.0f);

            var para0 = ObjMyPlayer.GetSkillData_Data(data, eModifySkillType.TargetParam1);

            GameLogic.Instance.Scene.CreateSkillRangeIndicator(character.gameObject,
                                                               Scene.SkillRangeIndicatorType.Circle,
                                                               para0, 0, Color.red, (caster, receiver) =>
            {
                StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[5]), () =>
                {
                    Destroy(caster);
                    Destroy(receiver);
                }));
            }, true);
        }
        else if (targetType == SkillTargetType.SECTOR || targetType == SkillTargetType.TARGET_SECTOR)
        {
            // correct the direction of npc or monster.
            character.TargetDirection = new Vector3(buff.Param[3] / 1000.0f, 0, buff.Param[4] / 1000.0f);

            GameLogic.Instance.Scene.CreateSkillRangeIndicator(character.gameObject, Scene.SkillRangeIndicatorType.Fan,
                                                               data.TargetParam[0], data.TargetParam[1], Color.red, (caster, receiver) =>
            {
                StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[5]), () =>
                {
                    Destroy(caster);
                    Destroy(receiver);
                }));
            }, true);
        }
        else if (targetType == SkillTargetType.RECT || targetType == SkillTargetType.TARGET_RECT)
        {
            // correct the direction of npc or monster.
            character.TargetDirection = new Vector3(buff.Param[3] / 1000.0f, 0, buff.Param[4] / 1000.0f);

            GameLogic.Instance.Scene.CreateSkillRangeIndicator(character.gameObject,
                                                               Scene.SkillRangeIndicatorType.Rectangle,
                                                               data.TargetParam[0], data.TargetParam[1], Color.red, (caster, receiver) =>
            {
                StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[5]), () =>
                {
                    Destroy(caster);
                    Destroy(receiver);
                }));
            }, true);
        }
        else if (targetType == SkillTargetType.SINGLE ||
                 targetType == SkillTargetType.TARGET_CIRCLE)
        {
            var x            = buff.Param[1] / 100.0f;
            var z            = buff.Param[2] / 100.0f;
            var y            = GameLogic.GetTerrainHeight(x, z);
            var o            = new GameObject();
            var objTransform = o.transform;
            objTransform.parent   = GameLogic.Instance.Scene.GlobalSkillIndicatorRoot.transform;
            objTransform.position = new Vector3(x, y, z);
            objTransform.forward  = new Vector3(buff.Param[3] / 1000.0f, 0, buff.Param[4] / 1000.0f);
            if (targetType == SkillTargetType.TARGET_CIRCLE)
            {
                GameLogic.Instance.Scene.CreateSkillRangeIndicator(o,
                                                                   Scene.SkillRangeIndicatorType.Circle,
                                                                   data.TargetParam[0], 0, Color.red,
                                                                   (caster, receiver) =>
                {
                    StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[5]), () => { Destroy(o); }));
                }, true);
            }
            else if (targetType == SkillTargetType.TARGET_SECTOR)
            {
                GameLogic.Instance.Scene.CreateSkillRangeIndicator(o,
                                                                   Scene.SkillRangeIndicatorType.Fan,
                                                                   data.TargetParam[0], data.TargetParam[1], Color.red, (caster, receiver) =>
                {
                    var casterTransform      = caster.transform;
                    casterTransform.position = new Vector3(x, y, z);
                    casterTransform.forward  = new Vector3(buff.Param[3] / 1000.0f, 0, buff.Param[4] / 1000.0f);

                    StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[5]), () => { Destroy(o); }));
                }, true);
            }
            else if (targetType == SkillTargetType.TARGET_RECT)
            {
                GameLogic.Instance.Scene.CreateSkillRangeIndicator(o,
                                                                   Scene.SkillRangeIndicatorType.Rectangle,
                                                                   data.TargetParam[0], data.TargetParam[1], Color.red, (caster, receiver) =>
                {
                    var casterTransform      = caster.transform;
                    casterTransform.position = new Vector3(x, y, z);
                    casterTransform.forward  = new Vector3(buff.Param[3] / 1000.0f, 0, buff.Param[4] / 1000.0f);

                    StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[5]), () => { Destroy(o); }));
                }, true);
            }
        }
    }
Пример #7
0
    public void AddBuff(BuffResult buff)
    {
        if (null == ObjManager.Instance.MyPlayer)
        {
            return;
        }

        // 如果5秒内,这个buff还没有被处理,那就算了
        // 通常这种情况发生于切后台后,服务器向客户端广播了很多buff
        // 但是客户端在后台没法处理,就累积起来了
        if (buff.ViewTime > 0 && buff.Type != BuffType.HT_RELIVE && buff.Type != BuffType.HT_DIE &&
            buff.Type != BuffType.HT_ADDBUFF &&
            buff.Type != BuffType.HT_DELBUFF && buff.Type != BuffType.HT_MOVE)
        {
            var viewTime = Extension.FromServerBinary((long)buff.ViewTime).AddSeconds(5);
            if (viewTime < Game.Instance.ServerTime)
            {
                return;
            }
        }

        var character = ObjManager.Instance.FindCharacterById(buff.TargetObjId);

        if (null == character)
        {
            //Logger.Warn("Don't find character[{0}].Buff[{1}]", buff.TargetObjId, (int)buff.Type);
            return;
        }

        if (buff.Type == BuffType.HT_RELIVE)
        {
            character.Relive();
            return;
        }

        if (buff.Type != BuffType.HT_MOVE)
        {
            character.ShowDamage(buff);
        }

        switch (buff.Type)
        {
        case BuffType.HT_NORMAL:
        case BuffType.HT_CRITICAL:
        case BuffType.HT_EXCELLENT:
        {
            //如果是这种伤害类型就不播被击动作
            if (buff.Param.Count > 0)
            {
                if (3 == buff.Param[0])
                {
                    break;
                }
            }

            if (character.GetObjType() == OBJ.TYPE.NPC)
            {
                if (character.GetCurrentStateName() == OBJ.CHARACTER_STATE.RUN)
                {
                    //character.GetAnimationController().Animation.Blend("Hit", 0.5f);
                    character.PlayAnimation(OBJ.CHARACTER_ANI.HIT, ani =>
                        {
                            if (character.GetCurrentStateName() == OBJ.CHARACTER_STATE.RUN)
                            {
                                character.PlayAnimation(OBJ.CHARACTER_ANI.RUN);
                            }
                        });
                }
                else
                {
                    character.DoHurt();
                }
            }
            else
            {
                character.DoHurt();
            }
        }
        break;

        case BuffType.HT_MISS:
            break;

        case BuffType.HT_CHANGE_SCENE:
        {
            EventDispatcher.Instance.DispatchEvent(new UIEvent_SyncBuffCell(buff));
            character.AddBuff(buff.BuffId, buff.BuffTypeId, buff.SkillObjId, buff.TargetObjId, false);
        }
        break;

        case BuffType.HT_ADDBUFF:
        {
            EventDispatcher.Instance.DispatchEvent(new UIEvent_SyncBuffCell(buff));
            character.AddBuff(buff.BuffId, buff.BuffTypeId, buff.SkillObjId, buff.TargetObjId);
            var table = Table.GetBuff(buff.BuffTypeId);
            if (null != table)
            {
                if (6 == table.Type)
                {
//眩晕
                    character.DoDizzy();
                }
            }
        }
        break;

        case BuffType.HT_DIE:
        {
            var delay =
                (float)(Extension.FromServerBinary((long)buff.ViewTime) - Game.Instance.ServerTime).TotalSeconds;
            if (delay <= 0.01)
            {
                character.DoDie();
            }
            else
            {
                character.DeleteObjTime = Time.time + delay;
                character.DelayDie(delay);
            }
            Logger.Debug("Die character[{0}].Buff[{1}]", buff.TargetObjId, (int)buff.Type);
        }
        break;

        case BuffType.HT_HEALTH:
            break;

        case BuffType.HT_DELBUFF:
        {
            EventDispatcher.Instance.DispatchEvent(new UIEvent_SyncBuffCell(buff));
            character.RemoveBuff(buff.BuffId);

            var table = Table.GetBuff(buff.BuffTypeId);
            if (null != table)
            {
                if (6 == table.Type)
                {
//眩晕
                    if (character.GetCurrentStateName() == OBJ.CHARACTER_STATE.DIZZY)
                    {
                        character.DoIdle();
                    }
                }
            }
        }
        break;

        case BuffType.HT_RELIVE:
            character.DoIdle();
            break;

        case BuffType.HT_EFFECT:
        {
            var record = Table.GetBuff(buff.BuffTypeId);
            if (record == null)
            {
                Logger.Log2Bugly(" AddBuff record = null");
                return;
            }
            EventDispatcher.Instance.DispatchEvent(new UIEvent_SyncBuffCell(buff));

            // 技能范围指示
            if (buff.Param.Count == 6)
            {
                ShowSkillIndicator(buff, character);
            }
            if (ObjManager.Instance == null || ObjManager.Instance.MyPlayer == null)
            {
                Logger.Log2Bugly(" AddBuff ObjManager.Instance.MyPlayer= null");
                return;
            }

            if (SoundManager.Instance == null || EffectManager.Instance == null)
            {
                Logger.Log2Bugly(" AddBuff SoundManager.Instance= null");
                return;
            }

            var isSelfCast      = buff.SkillObjId == ObjManager.Instance.MyPlayer.GetObjId();
            var showCameraShake = buff.TargetObjId == ObjManager.Instance.MyPlayer.GetObjId() ||
                                  isSelfCast;
            {
                var oldBuff = character.GetBuff(buff.BuffId);
                if (oldBuff != null)
                {
                    // 如果这个buff的特效还在加载,就先不播放了
                    if (oldBuff.State == BuffState.LoadingEffect)
                    {
                        return;
                    }

                    var effects = oldBuff.EffectRef;
                    // 如果这个buff的特效还没有结束,就不用播放这个特效了
                    for (var i = 0; i < effects.Count; i++)
                    {
                        if (EffectManager.Instance.HasEffect(effects[i].Uuid))
                        {
                            return;
                        }
                    }

                    for (var i = 0; i < oldBuff.EffectId.Count; i++)
                    {
                        if (EffectManager.Instance.HasEffect(oldBuff.EffectId[i]))
                        {
                            return;
                        }
                    }

                    if (record.Sound != -1)
                    {
                        if (oldBuff.SoundId > 0)
                        {
                            SoundManager.Instance.StopSoundEffectByTag(oldBuff.SoundId);
                            SoundManager.Instance.PlaySoundEffect(record.Sound, 1.0f, oldBuff.SoundId, isSelfCast);
                        }
                        else
                        {
                            oldBuff.SoundId = SoundManager.NextTag;
                            SoundManager.Instance.PlaySoundEffect(record.Sound, 1.0f, oldBuff.SoundId, isSelfCast);
                        }
                    }
                }
                else
                {
                    SoundManager.Instance.PlaySoundEffect(record.Sound, 1, 0, isSelfCast);
                }

                var __array3       = record.Effect;
                var __arrayLength3 = __array3.Length;
                for (var __i3 = 0; __i3 < __arrayLength3; ++__i3)
                {
                    var effect = __array3[__i3];
                    {
                        if (effect == -1)
                        {
                            continue;
                        }

                        var tableData = Table.GetEffect(effect);
                        if (tableData != null)
                        {
                            Vector3?pos = null;
                            if (buff.Param.Count == 6)
                            {
                                var x = buff.Param[1] / 100.0f;
                                var z = buff.Param[2] / 100.0f;
                                var y = GameLogic.GetTerrainHeight(x, z);
                                pos = new Vector3(x, y, z);
                            }
                            EffectManager.Instance.CreateEffect(tableData, character, pos, null, null,
                                                                (tableData.BroadcastType == 0 && showCameraShake) || tableData.BroadcastType == 1);
                        }
                    }
                }
            }
        }
        break;

        case BuffType.HT_NODAMAGE:
            break;

        case BuffType.HT_Fire_DAMAGE:
            break;

        case BuffType.HT_Ice_DAMAGE:
            break;

        case BuffType.HT_Poison_DAMAGE:
            break;

        case BuffType.HT_MOVE:
        {
            if (buff.Param[3] > 0)
            {
                character.StartCoroutine(WaitToDoSomething(TimeSpan.FromMilliseconds(buff.Param[3]),
                                                           () => { character.ForceMoveTo(buff.Param[0] / 1000.0f, buff.Param[1] / 1000.0f, buff.Param[2]); }));
            }
            else
            {
                character.ForceMoveTo(buff.Param[0] / 1000.0f, buff.Param[1] / 1000.0f, buff.Param[2]);
            }
        }
        break;

        case BuffType.HT_MANA:
            break;

        case BuffType.HT_REBOUND:
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }