Example #1
0
        /// <summary>
        /// 技能的朝向
        /// 攻击目标由服务器决定
        /// </summary>
        /// <param name="skillId"></param>
        /// <param name="skillLevel"></param>
        public static void FastUseSkill(int skillId, int skillLevel)
        {
            Log.Sys("FastUseSkill: " + skillId + " lev " + skillLevel);
            var sc = WorldManager.worldManager.GetActive();

            if (sc.IsNet && sc.CanFight)
            {
                var me  = ObjectManager.objectManager.GetMyPlayer();
                var pos = me.transform.position;
                var dir = (int)me.transform.localRotation.eulerAngles.y;

                /*
                 * var tower = me.GetComponent<TankPhysicComponent>().tower;
                 * if (tower == null)
                 * {
                 *  return;
                 * }
                 * var dir = (int)tower.transform.eulerAngles.y;
                 */


                var cg     = CGPlayerCmd.CreateBuilder();
                var skInfo = SkillAction.CreateBuilder();
                skInfo.Who        = ObjectManager.objectManager.GetMyServerID();
                skInfo.SkillId    = skillId;
                skInfo.SkillLevel = skillLevel;

                var ip = NetworkUtil.ConvertPos(pos);
                skInfo.X   = ip[0];
                skInfo.Y   = ip[1];
                skInfo.Z   = ip[2];
                skInfo.Dir = dir;

                /*
                 * if (skillId == 1)
                 * {
                 *  var attribute = me.GetComponent<NpcAttribute>();
                 *  skInfo.IsStaticShoot = attribute.GetStaticShootBuff();
                 * }
                 */

                var target   = SkillLogic.FindNearestEnemy(me);
                var targetId = 0;
                if (target != null)
                {
                    targetId = target.GetComponent <NpcAttribute>().GetNetView().GetServerID();
                }
                skInfo.Target = targetId;

                cg.SkillAction = skInfo.Build();
                cg.Cmd         = "Skill";
                //sc.BroadcastMsg(cg);
                sc.BroadcastKCP(cg);
            }
        }
Example #2
0
        public static void FastUseSkill(int skillId)
        {
            var sc = WorldManager.worldManager.GetActive();

            if (sc.IsNet)
            {
                var cg     = CGPlayerCmd.CreateBuilder();
                var skInfo = SkillAction.CreateBuilder();
                skInfo.Who     = ObjectManager.objectManager.GetMyServerID();
                skInfo.SkillId = skillId;
                cg.SkillAction = skInfo.Build();
                cg.Cmd         = "Skill";
                sc.BroadcastMsg(cg);
            }
        }