예제 #1
0
        public virtual bool ProcAOI(int searchChance)
        {
            EntityParent littleGuy = GetMercenaryEntity();

            //检测是否需要清除仇恨,例如entity不存在或者死亡

            //此方法只提供给怪物用,雇佣兵用ProcMercenaryAOI

            //把距离满足条件的活物对手加入仇恨列表
            if (!blackBoard.HasHatred(MogoWorld.thePlayer.ID) && !MogoWorld.thePlayer.IsDeath())
            {
                int tmpDis = (int)(Vector3.Distance(Transform.position, MogoWorld.thePlayer.Transform.position) * 100);
                //LoggerHelper.Error("m_currentSee:" + m_currentSee);
                if (tmpDis < m_currentSee)
                { //发现新目标,在距离内,加入仇恨列表
                    blackBoard.EditHatred(MogoWorld.thePlayer.ID, 1);
                    //通知其他同出生点的伙伴们也把新目标加入仇恨列表
                    EventDispatcher.TriggerEvent(Events.AIEvent.WarnOtherSpawnPointEntities, ID, (byte)Mogo.Game.AIWarnEvent.DiscoverSomeOne, MogoWorld.thePlayer.ID, spawnPointCfgId);
                    //LoggerHelper.Error("thePlayer closed!!!!!!!!!!!!");
                }
            }

            if (littleGuy != null && !blackBoard.HasHatred(littleGuy.ID) && !littleGuy.IsDeath())
            {
                int tmpDis = (int)(Vector3.Distance(Transform.position, littleGuy.Transform.position) * 100);
                if (tmpDis < m_currentSee)
                { //发现新目标,在距离内,加入仇恨列表
                    blackBoard.EditHatred(littleGuy.ID, 1);
                    EventDispatcher.TriggerEvent(Events.AIEvent.WarnOtherSpawnPointEntities, ID, Mogo.Game.AIWarnEvent.DiscoverSomeOne, littleGuy.ID, spawnPointCfgId);
                }
            }

            //取一个作为目标,暂时没随机
            if (blackBoard.mHatred.Count > 0)
            {
                foreach (KeyValuePair <uint, int> v in blackBoard.mHatred)
                {
                    if (v.Value <= 0)
                    {
                        continue;
                    }

                    blackBoard.enemyId = v.Key;

                    if (v.Key == MogoWorld.thePlayer.ID)
                    {
                        //LoggerHelper.Error("                                           see thePlayer !!!!!!!!!!!!");
                        if (!NotTurn())
                        {
                            motor.SetTargetToLookAt(MogoWorld.thePlayer.Transform);
                        }
                    }
                    else if (littleGuy != null && v.Key == littleGuy.ID)
                    {
                        if (!NotTurn())
                        {
                            motor.SetTargetToLookAt(littleGuy.Transform);
                        }
                    }

                    break;
                }
            }

            if (blackBoard.enemyId == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #2
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);
        }