Example #1
0
        //TODO::支持单人副本和多人副本功能 取决于  是否直接通知MyAnimationEvent
        //根据技能信息和玩家信息 得到实际的 伤害  NpcAttribute  SkillFullInfo

        /*
         *      伤害计算过程
         *      1:伤害对象判定  客户端做
         *      2:伤害数值确定   服务端 或者客户端
         *      3:伤害效果施展 例如击退  服务端 或者 客户端
         */
        public static void DoDamage(GameObject attacker, SkillFullInfo skillData, GameObject enemy)
        {
            if (enemy.GetComponent <MyAnimationEvent>() != null)
            {
                var attribute = attacker.GetComponent <NpcAttribute>();
                //技能施展方是我方则可以计算技能伤害否则只做技能表现
                if (enemy.GetComponent <NpcAttribute>().IsMine())
                {
                    var  rd         = Random.Range(0, 100);
                    var  rate       = 1;
                    bool isCritical = false;
                    if (rd < attribute.GetCriticalRate())
                    {
                        rate       = 2;
                        isCritical = true;
                    }
                    //在基础攻击力上面提升的比例
                    var damage = (int)(attribute.Damage * (skillData.skillData.WeaponDamagePCT / 100.0f) * rate);
                    Log.Sys("calculate Damage Rate " + skillData.skillData.WeaponDamagePCT);

                    NetDateInterface.FastDamage(
                        attribute.GetComponent <KBEngine.KBNetworkView>().GetServerID(),
                        enemy.GetComponent <KBEngine.KBNetworkView>().GetServerID(),
                        damage,
                        isCritical
                        );

                    enemy.GetComponent <MyAnimationEvent>().OnHit(attacker, damage, isCritical);
                    var hitTarget = new MyEvent(MyEvent.EventType.HitTarget);
                    hitTarget.target = enemy;
                    hitTarget.skill  = skillData.skillData;
                    MyEventSystem.myEventSystem.PushLocalEvent(attribute.GetLocalId(), hitTarget);
                }
            }
        }
Example #2
0
        void Start()
        {
            if (Event.attaches)
            {
                StartCoroutine(FollowAttacker());
            }

            if (Event.affix.effectType != Affix.EffectType.None && Event.affix.target == Affix.TargetType.Self)
            {
                if (stateMachine.attacker != null && stateMachine.attacker.GetComponent <NpcAttribute>().IsMine())
                {
                    stateMachine.attacker.GetComponent <BuffComponent>().AddBuff(Event.affix);
                    NetDateInterface.FastMoveAndPos();
                    NetDateInterface.FastAddBuff(Event.affix, stateMachine.attacker, stateMachine.attacker, stateMachine.skillFullData.skillId, Event.EvtId);
                }
            }


            var skillConfig = Event.layout.GetComponent <SkillLayoutConfig>();

            if (skillConfig != null)
            {
                StartCoroutine(ShowParticle());
            }
        }
Example #3
0
        /// <summary>
        /// 反弹伤害无法触发HitTarget事件
        /// </summary>
        /// <param name="attacker">Attacker.</param>
        /// <param name="WeaponDamagePCT">Weapon damage PC.</param>
        /// <param name="enemy">Enemy.</param>
        public static void DoDamage(GameObject attacker, int WeaponDamagePCT, GameObject enemy)
        {
            if (enemy.GetComponent <MyAnimationEvent>() != null)
            {
                if (enemy.GetComponent <NpcAttribute>().IsMine())
                {
                    var  attribute  = attacker.GetComponent <NpcAttribute>();
                    var  rate       = 1;
                    bool isCritical = false;

                    //在基础攻击力上面提升的比例
                    //调整基础比例
                    var damage = (int)(attribute.Damage * (WeaponDamagePCT / 100.0f) * rate);
                    Log.Sys("calculate Damage Rate SimpleDamage " + WeaponDamagePCT);
                    NetDateInterface.FastDamage(
                        attribute.GetComponent <KBEngine.KBNetworkView>().GetServerID(),
                        enemy.GetComponent <KBEngine.KBNetworkView>().GetServerID(),
                        damage,
                        isCritical
                        );
                    enemy.GetComponent <MyAnimationEvent>().OnHit(attacker, damage, isCritical);

                    /*
                     * var hitTarget = new MyEvent(MyEvent.EventType.HitTarget);
                     * hitTarget.target = enemy;
                     * hitTarget.skill = null;
                     * MyEventSystem.myEventSystem.PushLocalEvent(attribute.GetLocalId(), hitTarget);
                     */
                }
            }
        }
Example #4
0
        /// <summary>
        /// 本地使用技能同时通知代理
        /// 绕过LogicCommand 本地执行不需要LogicCommand队列
        /// </summary>
        /// <param name="skillData">Skill data.</param>
        static void UseSkill(SkillData skillData)
        {
            ObjectManager.objectManager.GetMyPlayer().GetComponent <MyAnimationEvent>().OnSkill(skillData);

            NetDateInterface.FastMoveAndPos();
            NetDateInterface.FastUseSkill(skillData.Id);
        }
Example #5
0
        /// <summary>
        /// 和使用普通技能一样
        /// </summary>
        public void PlayerAttack()
        {
            //连击3招
            var skillId   = ObjectManager.objectManager.GetMyPlayer().GetComponent <SkillInfoComponent> ().GetDefaultSkillId();
            var skillData = Util.GetSkillData(skillId, 1);

            ObjectManager.objectManager.GetMyPlayer().GetComponent <MyAnimationEvent>().OnSkill(skillData);

            NetDateInterface.FastMoveAndPos();
            NetDateInterface.FastUseSkill(skillId);
        }
Example #6
0
 public void DoDamage(GameObject g)
 {
     Log.AI("SkillLayout DoDamage " + Event.affix.effectType);
     if (Event.affix.effectType != Affix.EffectType.None && Event.affix.target == Affix.TargetType.Enemy)
     {
         //Buff目标是本地控制
         //通过ID来控制复制信息 实体都要有ID才便于复制
         //if(stateMachine.attacker.GetComponent<NpcAttribute>().IsMine()) {
         if (g.GetComponent <NpcAttribute>().IsMine())
         {
             g.GetComponent <BuffComponent>().AddBuff(Event.affix, stateMachine.attacker.transform.position);
             NetDateInterface.FastMoveAndPos();
             NetDateInterface.FastAddBuff(Event.affix, stateMachine.attacker, g, stateMachine.skillFullData.skillId, Event.EvtId);
         }
     }
     stateMachine.DoDamage(g);
 }
Example #7
0
        void MsgHandler(KBEngine.Packet packet)
        {
            var proto = packet.protoBody as GCPlayerCmd;

            Debug.Log("Map3Receive: " + proto);
            var cmds = proto.Result.Split(' ');

            if (cmds [0] == "Login")
            {
                myId = Convert.ToInt32(cmds [1]);
                ObjectManager.objectManager.RefreshMyServerId(myId);
            }
            else if (cmds [0] == "Add")
            {
                ObjectManager.objectManager.CreateOtherPlayer(proto.AvatarInfo);
                PlayerDataInterface.DressEquip(proto.AvatarInfo);
            }
            else if (cmds [0] == "Remove")
            {
                ObjectManager.objectManager.DestroyPlayer(proto.AvatarInfo.Id);
            }
            else if (cmds [0] == "Update")
            {
                var player = ObjectManager.objectManager.GetPlayer(proto.AvatarInfo.Id);
                if (player != null)
                {
                    var sync = player.GetComponent <PlayerSync>();
                    if (sync != null)
                    {
                        sync.NetworkMove(proto.AvatarInfo);
                    }
                }
                else
                {
                }
            }
            else if (cmds [0] == "Damage")
            {
                //SkillDamageCaculate.DoNetworkDamage(proto);
                var dinfo = proto.DamageInfo;
                var enemy = ObjectManager.objectManager.GetPlayer(dinfo.Enemy);
                if (enemy != null)
                {
                    var sync = enemy.GetComponent <PlayerSync>();
                    if (sync != null)
                    {
                        sync.DoNetworkDamage(proto);
                    }
                }
            }
            else if (cmds [0] == "Skill")
            {
                var sk     = proto.SkillAction;
                var player = ObjectManager.objectManager.GetPlayer(sk.Who);
                if (player != null)
                {
                    var sync = player.GetComponent <PlayerSync>();
                    if (sync != null)
                    {
                        sync.NetworkAttack(sk);
                    }
                }
            }
            else if (cmds [0] == "Buff")
            {
                var sync = NetDateInterface.GetPlayer(proto.BuffInfo.Target);
                if (sync != null)
                {
                    sync.NetworkBuff(proto);
                }
            }
        }
Example #8
0
 void SyncMyPos()
 {
     NetDateInterface.SyncPosDirHP();
 }