示例#1
0
        IEnumerator CastSkill(GameObject targetPlayer)
        {
            GetAttr().GetComponent <SkillInfoComponent> ().SetRandomActive();
            var activeSkill       = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            var skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, targetPlayer);

            Log.AI("Skill SetAni " + activeSkill.skillData.AnimationName);

            var realAttackTime = activeSkill.skillData.AttackAniTime / GetAttr().GetSpeedCoff();
            var rate           = GetAttr().animation[activeSkill.skillData.AnimationName].length / realAttackTime;

            SetAni(activeSkill.skillData.AnimationName, rate, WrapMode.Once);
            var physic = GetAttr().GetComponent <PhysicComponent>();

            while (GetAttr().animation.isPlaying&& !quit)
            {
                if (CheckEvent())
                {
                    break;
                }

                //自动向目标旋转
                Vector3 dir = targetPlayer.transform.position - GetAttr().transform.position;
                dir.y = 0;
                var newDir = Vector3.Slerp(GetAttr().transform.forward, dir, Time.deltaTime * FastRotateSpeed);
                physic.TurnTo(newDir);
                yield return(null);
            }
            skillStateMachine.Stop();
        }
示例#2
0
        /// <summary>
        /// 初始化特定事件发生时候的技能层
        /// 或者 创建孩子技能
        /// </summary>
        /// <param name="item">Item.</param>
        /// <param name="evt">Evt.</param>
        void InitLayout(SkillDataConfig.EventItem item, MyEvent evt)
        {
            if (item.layout != null)
            {
                var g = Instantiate(item.layout) as GameObject;
                g.transform.parent = transform;

                //陷阱粒子效果 位置是 当前missile爆炸的位置
                //瞬间调整SkillLayout的方向为 攻击者的正方向
                g.transform.localPosition = InitPos;
                var y = attacker.transform.localRotation.eulerAngles.y;
                g.transform.localRotation = Quaternion.Euler(new Vector3(0, y, 0));
                g.transform.localScale    = Vector3.one;


                var runner = g.AddComponent <SkillLayoutRunner>();
                runner.stateMachine = this;
                runner.Event        = item;
                runner.triggerEvent = evt;
                allRunners.Add(g);
                Log.AI("SkillLayout " + item.layout.name);
            }
            else if (item.childSkillId != 0 && item.childSkillId != -1)
            {
                Log.AI("Create Child Skill " + item.childSkillId);
                SkillLogic.CreateSkillStateMachine(attacker, Util.GetSkillData(item.childSkillId, 1), evt.missile.position);
            }
        }
示例#3
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);
     //GetAttr ().GetComponent<AnimationController> ().SetAnimationSampleRate (100);
 }
示例#4
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);
        }
示例#5
0
        public void OnlyShowDeadEffect()
        {
            _characterState = CharacterState.Dead;
            var sdata = GetDeadSkill();

            if (sdata != null)
            {
                StartCoroutine(SkillLogic.MakeSkill(gameObject, sdata, transform.position));
            }
        }
示例#6
0
 void OnEvent(MyEvent evt)
 {
     if (evt.type == MyEvent.EventType.HitTarget)
     {
         var target = evt.target;
         //在目标身上立即添加这个武器Buff造成的伤害Buff
         //Hurt Direct 但是伤害数值0 WeaponDamagePCT= 0
         var skmachine = SkillLogic.CreateSkillStateMachine(obj,
                                                            Util.GetSkillData(
                                                                System.Convert.ToInt32(affix.GetPara(PairEnum.Abs)), 1), Vector3.zero, target);
     }
 }
示例#7
0
 protected override bool CheckEventOverride(MyAnimationEvent.Message msg)
 {
     Log.AI("CheckEventOverride " + msg.type);
     if (msg.type == MyAnimationEvent.MsgType.BOMB)
     {
         Log.AI("CheckBombEvent " + msg.type);
         var sdata = Util.GetSkillData(137, 1);
         aiCharacter.GetAttr().StartCoroutine(SkillLogic.MakeSkill(aiCharacter.GetAttr().gameObject, sdata, GetAttr().transform.position));
         aiCharacter.ChangeState(AIStateEnum.DEAD);
         return(true);
     }
     return(base.CheckEventOverride(msg));
 }
示例#8
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());
            }
        }
示例#9
0
 /// <summary>
 ///子弹伤害计算也交给skillLayoutRunner执行
 /// </summary>
 /// <param name="other">Other.</param>
 void DoDamage(Collider other)
 {
     if (SkillLogic.IsEnemy(attacker, other.gameObject) && !missileData.DontHurtObject)
     {
         if (!string.IsNullOrEmpty(skillData.HitSound))
         {
             BackgroundSound.Instance.PlayEffect(skillData.HitSound);
         }
         if (runner != null)
         {
             runner.DoDamage(other.gameObject);
         }
     }
 }
示例#10
0
 /// <summary>
 ///子弹伤害计算也交给skillLayoutRunner执行
 /// </summary>
 /// <param name="other">Other.</param>
 void DoDamage(Collider other)
 {
     if (SkillLogic.IsEnemy(runner.stateMachine.attacker, other.gameObject))
     {
         var skillData = runner.stateMachine.skillFullData.skillData;
         if (!string.IsNullOrEmpty(skillData.HitSound))
         {
             BackgroundSound.Instance.PlayEffect(skillData.HitSound);
         }
         if (runner != null)
         {
             runner.DoDamage(other.gameObject);
         }
     }
 }
示例#11
0
        public void NetworkBuff(GCPlayerCmd cmd)
        {
            var attacker = ObjectManager.objectManager.GetPlayer(cmd.BuffInfo.Attacker);

            if (attacker != null)
            {
                var sk       = Util.GetSkillData(cmd.BuffInfo.SkillId, 1);
                var skConfig = SkillLogic.GetSkillInfo(sk);
                var evt      = skConfig.GetEvent(cmd.BuffInfo.EventId);
                if (evt != null)
                {
                    var pos = cmd.BuffInfo.AttackerPosList;
                    var px  = pos[0] / 100.0f;
                    var py  = pos[1] / 100.0f;
                    var pz  = pos[2] / 100.0f;
                    gameObject.GetComponent <BuffComponent>().AddBuff(evt.affix, new Vector3(px, py, pz));
                }
            }
        }
示例#12
0
        /// <summary>
        /// 首先判断场景模式:
        ///     普通场景
        ///     网络场景
        ///
        ///
        /// </summary>
        /// <returns><c>true</c> if is enemy the specified a b; otherwise, <c>false</c>.</returns>
        /// <param name="a">The alpha component.</param>
        /// <param name="b">The blue component.</param>
        public static bool IsEnemy(GameObject a, GameObject b)
        {
            var scene = WorldManager.worldManager.GetActive();

            if (scene.IsNet)
            {
                if (a != b)
                {
                    return(true);
                }
            }
            var enemyTag = SkillLogic.GetEnemyTag(a.tag);

            if (b.tag == enemyTag)
            {
                return(true);
            }
            return(false);
        }
示例#13
0
        IEnumerator DamageNear()
        {
            while (!IsDie)
            {
                yield return(new WaitForSeconds(3));

                BackgroundSound.Instance.PlayEffect("skill/fireimp1");
                var stateMachine = SkillLogic.CreateSkillStateMachine(obj, Util.GetSkillData(129, 1), obj.transform.position, null);
                if (affix.fireParticle != null)
                {
                    var evt = new MyEvent(MyEvent.EventType.SpawnParticle);
                    evt.particleOffset = new Vector3(0, 1, 0);
                    evt.particle2      = affix.fireParticle;
                    evt.boneName       = null;
                    evt.player         = obj;
                    MyEventSystem.myEventSystem.PushEvent(evt);
                }
            }
        }
示例#14
0
 //获取技能的客户端表现逻辑配置
 //TODO: 获取宠物的技能
 public SkillDataConfig GetSkillConfig()
 {
     return(SkillLogic.GetSkillInfo(activeSkill));
 }
示例#15
0
        /*
         *客户端表现粒子和服务器计算伤害的数值分离开来
         */
        void OnTriggerEnter(Collider other)
        {
            Log.AI("Bullet collider enemy " + other.name + " " + other.tag);
            if (SkillLogic.IsEnemy(attacker, other.gameObject))
            {
                //攻击多个目标只释放一次 DieParticle
                CreateHitParticle();

                //计算随机的弹射 反射方向
                if (LeftRicochets > 0)
                {
                    Log.AI("Generate new bullet " + LeftRicochets);
                    LeftRicochets--;
                    initPos = transform.position;
                    //子弹应该冲入怪物群中
                    transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + Random.Range(-missileData.RandomAngle, missileData.RandomAngle), 0));
                    //sleepTime = IgnoreTime;
                }
                else
                {
                    //地震是穿透的因此只会等待粒子自然死亡
                    //非穿透性子弹
                    if (!missileData.piercing)
                    {
                        GameObject.Destroy(gameObject);
                    }
                }

                //伤害多个目标
                if (missileData.IsAOE)
                {
                    AOEDamage();
                }
                else                   //只伤害一个目标
                                       //TODO:通过SkillDamageCaculate计算伤害 Level Information
                {
                    DoDamage(other);
                }

                //非穿透性子弹
                if (!missileData.piercing)
                {
                    var evt = new MyEvent(MyEvent.EventType.EventMissileDie);
                    evt.missile = transform;
                    MyEventSystem.myEventSystem.PushLocalEvent(attacker.GetComponent <KBEngine.KBNetworkView> ().GetLocalId(), evt);
                }
                //TODO::撞击其它玩家如何处理
            }
            else if (other.tag == attacker.tag)
            {
            }
            else                //装到墙体 或者建筑物 等对象身上 则 反射  Not used
            {
                Log.AI("Bullet colldier with Wall " + gameObject.name);
                if (missileData.HitParticle != null)
                {
                    GameObject g = Instantiate(missileData.HitParticle) as GameObject;
                    NGUITools.AddMissingComponent <RemoveSelf> (g);
                    g.transform.position = transform.position;
                    g.transform.parent   = ObjectManager.objectManager.transform;
                }

                if (LeftRicochets > 0)
                {
                    Log.AI("Generate new bullet " + LeftRicochets);
                    LeftRicochets--;
                    initPos = transform.position;
                    transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + 180 + Random.Range(-missileData.RandomAngle, missileData.RandomAngle), 0));
                    //sleepTime = IgnoreTime;
                }
                else
                {
                    if (!missileData.piercing)
                    {
                        GameObject.Destroy(gameObject);
                    }
                }
                if (!missileData.piercing)
                {
                    var evt = new MyEvent(MyEvent.EventType.EventMissileDie);
                    evt.missile = transform;
                    MyEventSystem.myEventSystem.PushLocalEvent(attacker.GetComponent <KBEngine.KBNetworkView> ().GetLocalId(), evt);
                }
            }
        }
示例#16
0
        /// <summary>
        /// 延迟等待
        /// 判定是否是一次性伤害技能 还是持续性伤害
        ///
        /// 开始判定伤害,技能没有结束
        /// 无伤害只移动对象
        ///
        ///
        /// </summary>
        void Update()
        {
            passTime += Time.deltaTime;
            if (passTime < delayTime)
            {
                return;
            }
            if (Once && damageYet)
            {
                return;
            }
            if (!runner || !runner.stateMachine || !runner.stateMachine.attacker)
            {
                return;
            }

            if (enable && !runner.stateMachine.isStop)
            {
                if (!NoHurt)
                {
                    //物理碰撞检测 玩家附近 或者 碰撞体附近的单位
                    Collider[] hitColliders;
                    if (SyncWithPlayer)
                    {
                        hitColliders = Physics.OverlapSphere(runner.stateMachine.attacker.transform.position, radius, SkillDamageCaculate.GetDamageLayer());
                    }
                    else
                    {
                        hitColliders = Physics.OverlapSphere(transform.position, radius, SkillDamageCaculate.GetDamageLayer());
                    }

                    for (int i = 0; i < hitColliders.Length; i++)
                    {
                        if (SkillLogic.IsEnemy(runner.stateMachine.attacker, hitColliders [i].gameObject))
                        {
                            if (!hurtEnemy.Contains(hitColliders [i].gameObject))
                            {
                                if (shape == Shape.Sphere)
                                {
                                    DoDamage(hitColliders [i].gameObject);
                                    hurtEnemy.Add(hitColliders [i].gameObject);
                                }
                                else if (shape == Shape.Angle)
                                {
                                    Log.AI("DamageHit " + runner.stateMachine.name + " " + hitColliders [i].name);
                                    var dir = hitColliders [i].gameObject.transform.position - transform.position;
                                    var cos = Vector3.Dot(dir.normalized, transform.forward);
                                    if (cos > cosAngle)
                                    {
                                        DoDamage(hitColliders [i].gameObject);
                                        hurtEnemy.Add(hitColliders [i].gameObject);
                                    }
                                }
                            }
                        }
                    }
                    Log.AI("Check Damage Shape " + runner.stateMachine.name);
                    damageYet = true;
                }

                ///DamageShape 开始移动玩家 同时也移动玩家
                if (runner != null && runner.Event.attachOwner)
                {
                    Log.Sys("Move Attack With DamageShape");
                    if (!enableYet)
                    {
                        StartCoroutine(MoveOwner());
                    }
                }
                enableYet = true;
            }
        }
示例#17
0
 //TODO:后续做成全局Static函数  CommonAI 静态一次性函数
 //查找附近敌人不考虑方向
 GameObject NearestEnemy()
 {
     return(SkillLogic.FindNearestEnemy(GetAttr().gameObject));
 }
示例#18
0
 void Start()
 {
     ai.ChangeState(AIStateEnum.IDLE);
     SkillLogic.CreateSkillStateMachine(gameObject, Util.GetSkillData(128, 1), transform.position, null);
 }
示例#19
0
        /*
         * 伤害计算过程
         *      1:伤害对象判定  客户端做
         *      2:伤害数值确定   服务端 或者客户端
         *      3:伤害效果施展 例如击退  服务端 或者 客户端
         */

        //TODO:增加摇杆控制攻击方向功能 这样人物会根据摇杆方向来确定攻击目标
        IEnumerator WaitForAttackAnimation(Animation animation)
        {
            var playerMove  = GetAttr().GetComponent <MoveController>();
            var camRight    = playerMove.camRight;
            var camForward  = playerMove.camForward;
            var vcontroller = playerMove.vcontroller;
            var physics     = playerMove.GetComponent <PhysicComponent>();

            var rd = Random.Range(1, 3);

            BackgroundSound.Instance.PlayEffect("onehandswinglarge" + rd);
            skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position);
            Log.AI("Wait For Combat Animation");
            //GameObject enemy = NearestEnemy ();
            float passTime = 0;
            //var transform = GetAttr ().transform;
            bool hitYet = false;

            do
            {
                if (!hitYet && GetEvent().onHit)
                {
                    hitYet = true;
                }
                if (CheckEvent())
                {
                    break;
                }

                float v = 0;
                float h = 0;
                if (vcontroller != null)
                {
                    h = vcontroller.inputVector.x; //CameraRight
                    v = vcontroller.inputVector.y; //CameraForward
                }

                if (Mathf.Abs(h) > 0.1f || Mathf.Abs(v) > 0.1f)
                {
                    Vector3 moveDirection   = playerMove.transform.forward;
                    Vector3 targetDirection = h * camRight + v * camForward;
                    if (targetDirection != Vector3.zero)
                    {
                        moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Time.deltaTime, 0);
                    }
                    moveDirection = moveDirection.normalized;
                    //playerMove.transform.rotation = Quaternion.LookRotation (moveDirection);
                    physics.TurnTo(moveDirection);
                    var movement = moveDirection * walkSpeed;
                    physics.MoveSpeed(movement);
                }
                if (passTime >= animation [attackAniName].length * 0.8f / animation [attackAniName].speed)
                {
                    break;
                }
                passTime += Time.deltaTime;

                var vhValue = Mathf.Abs(v) + Mathf.Abs(h);
                if (hitYet && vhValue > 0.2f)
                {
                    //stopAttack = true;
                    break;
                }

                yield return(null);
            } while(!quit);

            Log.Ani("Animation is Playing stop " + attackAniName);
            skillStateMachine.Stop();
        }