Пример #1
0
        public override void EnterState()
        {
            base.EnterState();
            cmd = aiCharacter.lastCmd;
            aiCharacter.blackboard[AIParam.SkillCmd] = new AIEvent()
            {
                cmd = cmd.proto
            };

            var target       = cmd.skillAction.Target;
            var targetPlayer = ObjectManager.objectManager.GetPlayer(target);

            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();

            skillStateMachine     = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, targetPlayer);
            skillStateMachine.cmd = cmd.proto;

            var time    = Util.FrameToFloat(aiCharacter.lastCmd.skillAction.RunFrame);
            var dir     = cmd.skillAction.Dir;
            var physics = aiCharacter.GetAttr().GetComponent <IPhysicCom>();

            physics.TurnToDir(dir);
            holdTime = time;

            var npcConfig = aiCharacter.attribute.npcConfig;
            var actConfig = npcConfig.GetActionBySkillId(cmd.proto.SkillAction.SkillId);

            if (actConfig == null)
            {
                Debug.LogError("NpcSkill:" + MobaUtil.PrintObj(npcConfig) + ":" + cmd.proto);
            }
            var aniName = actConfig.aniName;

            aiCharacter.PlayAniInTime(aniName, time);
        }
Пример #2
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.Id + " lev " + skillData.skillData.Level + " ra " + 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);
                }
            }
        }
Пример #3
0
        public SkillFullInfo GetDefaultSkill()
        {
            var sd = Util.GetSkillData(GetDefaultSkillId(), GetDefaultSkillLevel());
            var sk = new SkillFullInfo(sd);

            return(sk);
        }
Пример #4
0
 public override void EnterState()
 {
     base.EnterState();
     Log.AI("Enter Skill State ");
     //启动技能状态机 启动动画
     activeSkill       = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
     skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData,
                                                            GetAttr().transform.position);
 }
Пример #5
0
 public void UpdateShortcutsInfo(IList <ShortCutInfo> shortCutInfo)
 {
     skillSlots = new List <SkillFullInfo>();
     foreach (ShortCutInfo s in shortCutInfo)
     {
         var full = new SkillFullInfo(s);
         skillSlots.Add(full);
     }
     MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.UpdateShortCut);
 }
Пример #6
0
        public override IEnumerator RunLogic()
        {
            tower       = GetAttr().GetComponent <TankPhysicComponent>().tower.transform;
            tower2      = Util.FindChildRecursive(tower, "tower2").gameObject;
            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            var skInfo = GetAttr().GetComponent <SkillInfoComponent>();

            MyEventSystem.PushLocalEventStatic(GetAttr().GetNetView().GetLocalId(), MyEvent.EventType.UseSkill);
            yield return(GetAttr().StartCoroutine(Shoot()));
        }
Пример #7
0
        public override void EnterState()
        {
            base.EnterState();
            Log.AI("Enter Pet Skill State ");
            //启动技能状态机 启动动画
            activeSkill       = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, null);

            SetAni(activeSkill.skillData.AnimationName, 1f, WrapMode.Once);
        }
Пример #8
0
        public void InitSkillShotAfterSelectSkill(int PlayerModelInGame)
        {
            var npcConfig = NpcDataManager.Instance.GetConfig(PlayerModelInGame);
            var sk1       = npcConfig.GetAction(ActionType.Skill1);

            skillSlots = new List <SkillFullInfo>();
            var full = new SkillFullInfo(sk1.skillId, 0);

            skillSlots.Add(full);
            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.UpdateShortCut);
        }
Пример #9
0
        //注册监听玩家的OnHit事件处理
        public override void EnterState()
        {
            Log.AI("Enter HumanCombat state");
            base.EnterState();

            pressAttack     = false;
            attackPressTime = Time.time;
            attackId        = 0;
            SetAttrState(CharacterState.Attacking);

            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
        }
Пример #10
0
        public override void EnterState()
        {
            base.EnterState();
            Log.AI("sentry Enter Skill State ");
            activeSkill       = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, aiCharacter.GetEnemy());

            SetAni(activeSkill.skillData.AnimationName, 1f, WrapMode.Once);
            if (GetAttr().ObjUnitData.AttachToMaster)
            {
                GetAttr().StartCoroutine(TraceMaster());
            }
        }
Пример #11
0
        public override void EnterState()
        {
            base.EnterState();
            cmd         = aiCharacter.lastCmd;
            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            var target       = cmd.skillAction.Target;
            var targetPlayer = ObjectManager.objectManager.GetPlayer(target);

            skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, targetPlayer);
            var time = Util.FrameToFloat(aiCharacter.lastCmd.skillAction.RunFrame);
            var dir  = cmd.skillAction.Dir;

            holdTime = time;
        }
Пример #12
0
        public override IEnumerator RunLogic()
        {
            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            var attackAniName  = GetAttackAniName();
            var realAttackTime = activeSkill.skillData.AttackAniTime / GetAttr().GetSpeedCoff();
            var rate           = GetAttr().GetComponent <Animation>() [attackAniName].length / realAttackTime;

            PlayAni(attackAniName, rate, WrapMode.Once);
            yield return(GetAttr().StartCoroutine(WaitForAttackAnimation(GetAttr().GetComponent <Animation>())));

            aiCharacter.SetRun();
            //等动画彻底播放完成
            yield return(new WaitForSeconds(0.1f));
        }
Пример #13
0
        void SetShortSkillData(int skId, int index)
        {
            foreach (SkillFullInfo s in skillSlots)
            {
                if (s.skillId == skId)
                {
                    skillSlots.Remove(s);
                    break;
                }
            }
            foreach (SkillFullInfo s in skillSlots)
            {
                if (s.shortSlotId == index)
                {
                    skillSlots.Remove(s);
                    break;
                }
            }
            var full = new SkillFullInfo(skId, index);

            skillSlots.Add(full);
            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.UpdateShortCut);
        }
Пример #14
0
        /// <summary>
        /// 初始化右下角的技能快捷栏
        /// 初始化技能列表
        /// </summary>
        /// <returns>The from network.</returns>
        public IEnumerator InitFromNetwork()
        {
            Log.Net("Init Skill slots");
            CGLoadShortcutsInfo.Builder b = CGLoadShortcutsInfo.CreateBuilder();
            KBEngine.PacketHolder       p = new KBEngine.PacketHolder();
            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, b, p)));

            var shortData = p.packet.protoBody as GCLoadShortcutsInfo;

            skillSlots = new List <SkillFullInfo>();
            foreach (ShortCutInfo s in shortData.ShortCutInfoList)
            {
                var full = new SkillFullInfo(s);
                skillSlots.Add(full);
            }
            Log.Net("Init Skill slots over " + skillSlots.Count);
            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.UpdateShortCut);


            Log.Sys("LoadSkillPanel");
            //获取特定技能面板的技能点 所有面板公用这些技能点
            CGLoadSkillPanel.Builder ls = CGLoadSkillPanel.CreateBuilder();
            ls.SkillSort = SkillSort.ACTIVE_SKILL;
            KBEngine.PacketHolder p2 = new KBEngine.PacketHolder();
            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, ls, p2)));

            Log.Net("FinishLoad");
            var data = p2.packet.protoBody as GCLoadSkillPanel;

            //distributedSkillPoint = data.Distributed;
            if (data.HasTotalPoint)
            {
                totalSkillPoint = data.TotalPoint;
            }
            else
            {
                totalSkillPoint = 0;
            }
            Dictionary <int, SkillInfo> skIdToInfo = new Dictionary <int, SkillInfo>();

            Log.GUI("SkillInfoList " + data.SkillInfosList.Count + " totalPoint " + totalSkillPoint);

            foreach (SkillInfo sk in data.SkillInfosList)
            {
                skIdToInfo [sk.SkillInfoId] = sk;
            }

            var myJob = MyLib.ObjectManager.objectManager.GetMyJob();

            Log.Sys("SkillMyJob AndList " + myJob);
            //从服务器加载对应的技能数据 两部分: 配置的职业技能 服务器加载的技能
            foreach (var s in GameData.SkillConfig)
            {
                if (s.job == myJob)
                {
                    if (skIdToInfo.ContainsKey(s.id))
                    {
                        activeSkill.Add(new SkillFullInfo(skIdToInfo [s.id]));
                    }
                    else
                    {
                        var skInfo = SkillInfo.CreateBuilder();
                        skInfo.SkillInfoId = s.id;
                        skInfo.Level       = 0;
                        skInfo.Pos         = 0;
                        activeSkill.Add(new SkillFullInfo(skInfo.Build()));
                    }
                }
            }

            var learnedSkill = PlayerData.GetLearnedSkill();

            foreach (var s in learnedSkill.SkillInfosList)
            {
                var old = activeSkill.Find(item => item.skillId == s.SkillInfoId);
                if (old != null)
                {
                    //old.Pos = s.Pos;
                }
                else
                {
                    var skInfo = SkillInfo.CreateBuilder(s);
                    activeSkill.Add(new SkillFullInfo(skInfo.Build()));
                }
            }
            Log.Sys("MySkillCount " + activeSkill.Count);
        }
Пример #15
0
 public override IEnumerator RunLogic()
 {
     activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
     tower       = Util.FindChildRecursive(GetAttr().transform, "tower").transform;
     yield return(GetAttr().StartCoroutine(Shoot()));
 }