Пример #1
0
        public override bool ProcChooseCastPoint(int skillBagIndex)
        {
            if (m_monsterData.skillIds.Count < skillBagIndex || skillBagIndex <= 0)
            {
                return(false);
            }
            skillBagIndex--;
            EntityParent theTarget = GetTargetEntity();

            if (theTarget == null)
            {
                return(false);
            }
            int skillId = m_monsterData.skillIds[skillBagIndex];

            if (!SkillData.dataMap.ContainsKey(skillId))
            {
                return(false);
            }
            int castRange = GetSkillRange(skillId);

            float entityRadius = theTarget.MonsterData.scaleRadius;

            if (entityRadius <= 0.1f)
            {
                entityRadius = (float)theTarget.GetIntAttr("scaleRadius");
            }

            return(GetMovePointStraight((int)(castRange * 0.7f)));// + entityRadius * 0.7f
        }
Пример #2
0
        //---------------------------------------AI Action相关begin------------------------------------------------


        public override bool ProcMercenaryAOI()
        {
            EntityParent enemy = GetTargetEntity();

            if (enemy != null && enemy.curHp > 0)
            {//目标没死继续杀这个
                return(true);
            }
            blackBoard.enemyId = 0;

            //雇佣兵找敌人
            //遍历entities
            foreach (KeyValuePair <uint, Mogo.Game.EntityParent> pair in MogoWorld.Entities)
            {
                EntityParent entity = pair.Value;

                if (entity.Transform != null && entity.m_factionFlag != m_factionFlag && entity.curHp > 0 && !(entity is EntityMonster))
                {
                    float entityRadius = entity.MonsterData.scaleRadius;
                    if (entityRadius <= 0.1f)
                    {
                        entityRadius = (float)entity.GetIntAttr("scaleRadius");
                    }

                    //和主人的距离小于10米
                    float entityDistance = Vector3.Distance(entity.Transform.position, MogoWorld.thePlayer.Transform.position) - entityRadius * 0.01f;
                    if (entityDistance > 8.0f)
                    {
                        continue;
                    }

                    blackBoard.enemyId = entity.ID;

                    motor.SetTargetToLookAt(entity.Transform);

                    break;
                }
            }
            if (blackBoard.enemyId <= 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #3
0
        // 状态处理
        public void Process(EntityParent theOwner, params System.Object[] args)
        {
            MogoMotor theMotor = theOwner.motor;

            if (theOwner is EntityMonster || (theOwner is EntityPlayer && !(theOwner is EntityMyself)))
            {
                theOwner.ApplyRootMotion(false);
                theOwner.SetSpeed(1);
                theMotor.SetSpeed(0.4f);


                //服务器没有同步其他玩家的速度,这里暂时硬编码处理,
                //待确定其他玩家与怪物移动位移的控制方案再修改(程序控制还是动作位移)
                if (theOwner.speed == 0)
                {
                    theMotor.SetExrtaSpeed(6);
                }
                else
                {
                    theMotor.SetExrtaSpeed(theOwner.speed);
                }
                return;
            }
            else if (theOwner is EntityDummy || theOwner is EntityMercenary)
            {
                theOwner.ApplyRootMotion(false);
                //theOwner.SetSpeed(1);
                theMotor.SetSpeed(0.4f * theOwner.aiRate);
                theMotor.SetExrtaSpeed(theOwner.GetIntAttr("speed") * 0.01f * theOwner.blackBoard.speedFactor * theOwner.aiRate);
            }
            else
            {
                theOwner.ApplyRootMotion(true);
                // theOwner.SetSpeed(1);
                theMotor.SetSpeed(0.4f);
            }
            theMotor.isMovable = true;
        }
Пример #4
0
        public bool GetMovePointStraight(int skillRange)
        {
            // LoggerHelper.Error("GetMovePointStraight");
            EntityParent enemy     = GetTargetEntity();
            Container    enemyTrap = GetTargetContainer();

            if (enemy == null && enemyTrap == null)
            {
                return(false);
            }

            if (enemy != null)
            {
                if (enemy.Transform == null)
                {
                    LoggerHelper.Error("enemy.Transform == null");
                }
                else if (Transform == null)
                {
                    LoggerHelper.Error("Transform == null");
                }
                int distance = skillRange;

                float entityRadius = enemy.MonsterData.scaleRadius;
                if (entityRadius <= 0.1f)
                {
                    entityRadius = (float)enemy.GetIntAttr("scaleRadius");
                }

                int curdistance = (int)(Vector3.Distance(Transform.position, enemy.Transform.position) * 100 - entityRadius);

                if (distance >= curdistance)// || curdistance-distance < 0.1f
                {
                    StopMove();
                    return(false);
                }
                else
                {
                    blackBoard.navTargetDistance = (uint)skillRange + (uint)entityRadius;
                    blackBoard.movePoint         = enemy.Transform.position;
                }

                float tmpDis = Vector3.Distance(Transform.position, new Vector3(blackBoard.movePoint.x, Transform.position.y, blackBoard.movePoint.z));
                if (tmpDis < 1.0f)
                {
                    StopMove();
                    return(false);
                }


                return(true);
            }
            else if (enemyTrap != null)
            {
                if (enemyTrap.transform == null)
                {
                    LoggerHelper.Error("enemy.Transform == null");
                }
                else if (Transform == null)
                {
                    LoggerHelper.Error("Transform == null");
                }
                int distance    = skillRange;
                int curdistance = (int)(Vector3.Distance(Transform.position, enemyTrap.transform.position) * 100);

                if (distance >= curdistance)// || curdistance-distance < 0.1f
                {
                    StopMove();
                    return(false);
                }
                else
                {
                    blackBoard.navTargetDistance = (uint)skillRange;
                    blackBoard.movePoint         = enemyTrap.transform.position;
                }

                float tmpDis = Vector3.Distance(Transform.position, new Vector3(blackBoard.movePoint.x, Transform.position.y, blackBoard.movePoint.z));
                if (tmpDis < 1.0f)
                {
                    StopMove();
                    return(false);
                }


                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        // 状态处理
        public void Process(EntityParent theOwner, params Object[] args)
        {
            if (theOwner == null || theOwner.Transform == null)
                return;

            if (theOwner.IsDeath())
                return;

            if (args.Length < 2)
            {
                LoggerHelper.Error("error skill id");
                return;
            }
            int hitActionID = (int)(args[0]);
            uint attackID = (uint)(args[1]);
            EntityParent attacker = null;
            if (MogoWorld.Entities.ContainsKey(attackID))
            {
                attacker = MogoWorld.Entities[attackID];
            }
            if (attackID == MogoWorld.thePlayer.ID)
            {
                attacker = MogoWorld.thePlayer;
            }
            if (theOwner.motor != null)
            {
                theOwner.motor.enableStick = false;
            }
            //if (attacker == null)
            //{//没有受击者
            //    return;
            //}
            List<int> hitAction = SkillAction.dataMap[hitActionID].hitAction;
            if (hitAction == null || hitAction.Count == 0)
            {
                return;
            }
            int action = Utils.Choice<int>(hitAction);
            if (action == ActionConstants.HIT)
            {
                HitActionRule(theOwner, action, hitActionID);
                return;
            }
            if (!(theOwner is EntityPlayer))
            {
                if (((theOwner is EntityMonster) && theOwner.GetIntAttr("notTurn") == 0) || theOwner is EntityDummy)
                {
                    if (theOwner.motor == null)
                    {
                        return;
                    }
                    if (attacker != null && attacker.Transform != null)
                    {
                        theOwner.motor.SetTargetToLookAt(attacker.Transform.position);
                    }
                }
            }
            else
            {
                if (theOwner.Transform == null)
                {
                    return;
                }
                theOwner.preQuaternion = theOwner.Transform.localRotation;
                if (attacker != null && attacker.Transform != null)
                    theOwner.motor.SetTargetToLookAt(attacker.Transform.position);
            }
            HitActionRule(theOwner, action, hitActionID);
        }
Пример #6
0
        //---------------------------------------AI Condition相关begin------------------------------------------------

        public override bool ProcInSkillRange(int skillBagIndex)
        {
            if (m_monsterData.skillIds.Count < skillBagIndex || skillBagIndex <= 0)
            {
                return(false);
            }
            skillBagIndex--;
            if (blackBoard.enemyId == 0)
            {
                return(false);
            }

            int skillId = m_monsterData.skillIds[skillBagIndex];

            if (!SkillData.dataMap.ContainsKey(skillId))
            {
                return(false);
            }


            EntityParent enemy = GetTargetEntity();

            if (enemy == null)
            {
                return(false);
            }

            bool rnt = false;


            if (!SkillData.dataMap.ContainsKey(skillId))
            {
                return(false);
            }

            TargetRangeType targetRangeType = 0;

            SkillData tmpSkillData = SkillData.dataMap[skillId];

            //逐个skillaction来判断是否等于TargetRangeType.WorldRange
            foreach (var tmpSkillActionId in tmpSkillData.skillAction)
            {
                if (SkillAction.dataMap[tmpSkillActionId].targetRangeType == (int)TargetRangeType.WorldRange)
                {
                    targetRangeType = TargetRangeType.WorldRange;
                }
            }

            if (targetRangeType == TargetRangeType.WorldRange)
            {
                rnt = skillManager.IsInSkillRange(skillId, blackBoard.enemyId);
            }
            else
            {
                int skillRange = GetSkillRange(skillId);


                int   distance     = skillRange;
                float entityRadius = enemy.MonsterData.scaleRadius;
                if (entityRadius <= 0.1f)
                {
                    entityRadius = (float)enemy.GetIntAttr("scaleRadius");
                }

                int curdistance = (int)(Vector3.Distance(Transform.position, enemy.Transform.position) * 100 - entityRadius);


                if (distance >= curdistance)
                {
                    rnt = true;
                    //Mogo.Util.LoggerHelper.Debug("IsInSkillRange:true");
                }
                else
                {
                    rnt = false;
                    //Mogo.Util.LoggerHelper.Debug("IsInSkillRange:false");
                }
            }
            return(rnt);
        }