示例#1
0
    protected void OnClickSceneItem(SceneItem _sceneItem)
    {
        if (_sceneItem == null || target == null)
        {
            return;
        }
        if (target.CurFSMState == MainPlayer.EventType.AI_FIGHT_CTRL) //应策划要求,自动战斗时的点击,不能直接跳转到普通,而只是临时执行。
        {
            target.BreakAutoFight();
        }
        else
        {
            target.GoNormal();
        }
        target.CancelCommands();
        Command_MoveTo cmdMoveTo = new Command_MoveTo();

        cmdMoveTo.destPos     = _sceneItem.gameObject.transform.position;
        cmdMoveTo.maxDistance = 0f;
        target.commandMng.PushCommand(cmdMoveTo);

        switch (_sceneItem.IsTouchType)
        {
        case TouchType.TOUCH:
            GameCenter.curMainPlayer.CurTarget = _sceneItem;
            CommandTriggerTarget trigCmd = new CommandTriggerTarget();
            trigCmd.target = _sceneItem;
            target.commandMng.PushCommand(trigCmd);
            break;

        default:
            break;
        }
    }
示例#2
0
 protected virtual void UpdateFlowState(fsm.State _curState)
 {
     if (thisPlayer.isDead)
     {
         return;
     }
     if (CheckNeedTeleport())
     {
         return;
     }
     if (thisPlayer != null && !thisPlayer.commandMng.HasCommand())//如果自主命令都已经执行完毕,重新回到战斗
     {
         float sqr = (thisPlayer.transform.position - owner.transform.position).sqrMagnitude;
         if (sqr >= stopFollowRange * stopFollowRange)
         {
             Command_MoveTo movetoCMD = new Command_MoveTo();
             movetoCMD.destPos = Utils.GetRandomPos(owner.transform);
             thisPlayer.commandMng.PushCommand(movetoCMD);
         }
         else
         {
             stateMachine.Send((int)EventType.PVP_FIGHT_TRACE);
         }
     }
 }
示例#3
0
    protected void OnClickNpc(NPC _npc)
    {
        if (_npc == null || target == null)
        {
            return;
        }
        target.CurTarget = _npc;
        target.GoNormal();

        if (isDragingRockerItem)
        {
            return;
        }

        //  target.autoAttak = MainPlayer.AttackType.NONE;
        target.CancelCommands();
        Command_MoveTo cmdMoveTo = new Command_MoveTo();
        Vector3        npcPos    = _npc.gameObject.transform.position;
        Vector3        myPos     = target.transform.position;

        cmdMoveTo.destPos = npcPos - Vector3.Normalize(npcPos - myPos) * 2.0f;

        cmdMoveTo.maxDistance = 0f;
        target.commandMng.PushCommand(cmdMoveTo);

        CommandTriggerTarget cmdMoveToTarget = new CommandTriggerTarget();

        cmdMoveToTarget.minDistance = 3.5f;
        cmdMoveToTarget.target      = _npc;
        target.commandMng.PushCommand(cmdMoveToTarget);
    }
示例#4
0
    protected void OnClickFlyPoint(FlyPoint _flyPoint)
    {
        if (_flyPoint == null || target == null)
        {
            return;
        }
        target.GoNormal();
        target.CurClickFlyPoint = _flyPoint;

        if (isDragingRockerItem)
        {
            return;
        }

        target.CancelCommands();
        Command_MoveTo cmdMoveTo = new Command_MoveTo();

        cmdMoveTo.destPos     = _flyPoint.gameObject.transform.position;
        cmdMoveTo.maxDistance = 0f;
        target.commandMng.PushCommand(cmdMoveTo);

        //Command_FlyPoint cmdFly = new Command_FlyPoint();
        //cmdFly.type = _flyPoint.RefData.id;
        //GameCenter.curMainPlayer.commandMng.PushCommand(cmdFly);
    }
示例#5
0
    public void ChangeTarget()
    {
        float distance = 0;

        thisTarget = GameCenter.curGameStage.GetAnotherSmartActor(thisTarget == null ? -1 : thisTarget.id, thisPlayer.transform.position);       //startFightPos == Vector3.zero ? thisPlayer.transform.position : startFightPos);  //这里需要加
        if (thisTarget == null)
        {
            thisTarget = GameCenter.curGameStage.GetClosestMob(thisPlayer, ref distance);
            if (distance > autoFightDistance)
            {
                thisTarget = null;
            }
            if (thisTarget != null)//自动战斗避开BOSS  BY黄洪兴
            {
                Monster mo = thisTarget as Monster;
                if (mo != null && GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef != null)
                {
                    if (GameCenter.systemSettingMng.IsHideBoss && mo.actorInfo.IsBoss && GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef.sort == SceneType.SCUFFLEFIELD)
                    {
                        thisTarget = null;
                    }
                }
            }
        }
        if (thisTarget != null)
        {
            thisPlayer.CurTarget = thisTarget;
        }
        else
        {
            if (!commandMng.HasCommand())
            {
                List <DropItemInfo> dropItmes = GameCenter.sceneMng.GetDropItemInfoListByLimit(thisPlayer);
                if (dropItmes.Count > 1)
                {
                    thisPlayer.OnDropItem();
                }
                else
                {
                    Vector3 wayPoint = GameCenter.sceneMng.WayPoint;//找不到怪物则寻找路点
                    if ((thisPlayer.transform.position - wayPoint).sqrMagnitude > 2f)
                    {
                        if (wayPoint.x != 0 || wayPoint.z != 0)
                        {
                            Command_MoveTo moveto = new Command_MoveTo();
                            moveto.destPos     = wayPoint;
                            moveto.maxDistance = 0f;
                            GameCenter.curMainPlayer.commandMng.PushCommand(moveto);
                        }
                    }
                }
            }
        }
    }
示例#6
0
 protected virtual void UpdateAutoDartState(fsm.State _curState)
 {
     if (!commandMng.HasCommand() && CurDart != null)
     {
         float sqr = (thisPlayer.transform.position - CurDart.transform.position).sqrMagnitude;
         if (sqr >= followRange * followRange)
         {
             Command_MoveTo movetoCMD = new Command_MoveTo();
             movetoCMD.destPos     = Utils.GetRandomPos(CurDart.transform);
             movetoCMD.maxDistance = 2;
             thisPlayer.commandMng.PushCommand(movetoCMD);
         }
     }
 }
示例#7
0
    public void OnClickTerrain(Vector3 _hitpos)
    {
        if (target.GetMoveFSM().isMoveLocked)
        {
            // GameCenter.messageMng.AddClientMsg(199);//提示玩家,正在晕眩中,不能移动 by吴江
            return;
        }
        if (isDragingRockerItem)
        {
            isDragingRockerItem = false;
            return;
        }
        //target.AttakType = MainPlayer.AttackType.NONE;
        //target.GoNormal();
        if (target.CurFSMState == MainPlayer.EventType.AI_FIGHT_CTRL || target.CurFSMState == MainPlayer.EventType.AI_DART_CTRL)         //应策划要求,自动战斗时的点击地面,不能直接跳转到普通,而只是临时执行。
        {
            target.BreakAutoFight();
        }
        else
        {
            target.GoNormal();
        }
        if (target.CurTarget != null)
        {
            if (GameCenter.curGameStage is CityStage)
            {
                if (target.CurTarget is OtherPlayer || target.CurTarget is NPC)
                {
                    target.CurTarget = null;
                }
            }
            else
            {
                if (target.CurTarget is NPC)
                {
                    target.CurTarget = null;
                }
            }
        }
        Command_MoveTo cmdMoveTo = new Command_MoveTo();

        cmdMoveTo.destPos     = _hitpos;
        cmdMoveTo.maxDistance = 0.5f;
        target.CancelCommands();
        target.commandMng.PushCommand(cmdMoveTo);

        GameCenter.spawner.SpawnIndicator(_hitpos, Quaternion.identity);
        GameCenter.uIMng.OpenFuncShowMenu(false);
    }
示例#8
0
    protected void OnClickOPC(OtherPlayer _opc)
    {
        if (_opc == null || target == null)
        {
            return;
        }
        if (_opc.isDead)
        {
            return;
        }

        target.CurTarget = _opc;
        target.SetAiFightTarget(_opc);
        if (isDragingRockerItem)
        {
            return;
        }

        SceneType curType = GameCenter.curGameStage.SceneType;

        if (curType != SceneType.CITY)
        {
            if (target.CurFSMState == MainPlayer.EventType.AI_FIGHT_CTRL) //应策划要求,自动战斗时的点击,不能直接跳转到普通,而只是临时执行。
            {
                target.BreakAutoFight();
            }
            else
            {
                target.GoNormal();
            }
            target.CancelCommands();
            // target.SetAiFightTarget(_opc);
            // target.autoAttak = MainPlayer.AttackType.FIGHT;
        }
        else
        {
            target.CancelCommands();
            Command_MoveTo cmdMoveTo = new Command_MoveTo();
            Vector3        npcPos    = _opc.gameObject.transform.position;
            Vector3        myPos     = target.transform.position;
            cmdMoveTo.destPos = npcPos - Vector3.Normalize(npcPos - myPos) * 2.0f;

            cmdMoveTo.maxDistance = 0.8f;
            target.commandMng.PushCommand(cmdMoveTo);
        }
    }
示例#9
0
 protected void OnStartAI(bool _awake)
 {
     if (_awake)
     {
         if (this.gameObject == null)
         {
             return;
         }
         id = actorInfo.ServerInstanceID;
         this.gameObject.name = "MainEntourage[" + actorInfo.ServerInstanceID + "]";
         abilityMng.SetEntourage(this, actorInfo);
         Command_MoveTo movetoCMD = new Command_MoveTo();
         movetoCMD.destPos = Utils.GetRandomPos(GameCenter.curMainPlayer.transform);
         commandMng.PushCommand(movetoCMD);
         GoFight();
         if (GameCenter.curGameStage.GetEntourage(actorInfo.ServerInstanceID) == null)
         {
             GameCenter.curGameStage.AddObject(this);
         }
     }
 }
示例#10
0
    protected void OnClickDropItem(DropItem _dropitem)
    {
        if (_dropitem == null || _dropitem == null)
        {
            return;
        }
        target.GoNormal();


        if (isDragingRockerItem)
        {
            return;
        }

        target.CancelCommands();
        Command_MoveTo cmdMoveTo = new Command_MoveTo();

        cmdMoveTo.destPos     = _dropitem.gameObject.transform.position;
        cmdMoveTo.maxDistance = 0f;
        target.commandMng.PushCommand(cmdMoveTo);
    }
示例#11
0
    protected virtual void UpdateCollectState(fsm.State _curState)
    {
        if (!CheckTask())
        {
            thisPlayer.GoNormal();
            return;
        }
        if (curTarSceneItem == null || curTarSceneItem.isDead)
        {
            curTarSceneItem = GetTarSceneItem();
        }
        else if (!thisPlayer.commandMng.HasCommand() && !thisPlayer.IsCollecting && !GameCenter.mainPlayerMng.IsWaitTouchSceneItemMsg)
        {
            thisPlayer.CurTarget = curTarSceneItem;
            Command_MoveTo moveCmd = new Command_MoveTo();
            moveCmd.destPos = curTarSceneItem.transform.position;
            thisPlayer.commandMng.PushCommand(moveCmd);

            CommandTriggerTarget trigCmd = new CommandTriggerTarget();
            trigCmd.target = curTarSceneItem;
            thisPlayer.commandMng.PushCommand(trigCmd);
        }
    }
示例#12
0
    public override bool Exec(Actor _actor)
    {
        if (target == null)
        {
            return(true);
        }

        if (target.isDummy)
        {
            return(false);
        }
        if (GameCenter.curGameStage == null || !GameCenter.sceneMng.EnterSucceed)
        {
            return(false);
        }


        Vector3 targetPos = target.transform.position;
        Vector3 diff      = _actor.transform.position - targetPos;

        if (diff.sqrMagnitude <= minDistance * minDistance)
        {
            target.InteractionSound();
            switch (target.typeID)
            {
            case ObjectType.NPC:
                NPC npc = target as NPC;
                GameCenter.curMainPlayer.CurTarget = npc;
                //if(!GameCenter.taskMng.IsOpenDialog)
                GameCenter.uIMng.SwitchToUI(GUIType.NPCDIALOGUE);
                //GameCenter.taskMng.SetNPCDialogActive(false);
                break;

            case ObjectType.FlyPoint:
                FlyPoint   fly = target as FlyPoint;
                MainPlayer mp  = _actor as MainPlayer;
                if (mp != null && fly != null)
                {
                    mp.CancelCommands();
                    Command_MoveTo cmdMoveTo = new Command_MoveTo();
                    cmdMoveTo.destPos     = fly.gameObject.transform.position;
                    cmdMoveTo.maxDistance = 0f;
                    mp.commandMng.PushCommand(cmdMoveTo);


                    //Command_FlyPoint cmdFly = new Command_FlyPoint();
                    //cmdFly.type = fly.RefData.id;
                    //GameCenter.curMainPlayer.commandMng.PushCommand(cmdFly);
                }
                break;

            case ObjectType.SceneItem:
                SceneItem sceneitem = target as SceneItem;
                if (sceneitem != null && sceneitem.IsTouchType == TouchType.TOUCH)
                {
                    if (GameCenter.mainPlayerMng.MainPlayerInfo.CurMountInfo != null && GameCenter.mainPlayerMng.MainPlayerInfo.CurMountInfo.IsRiding)    //下坐骑
                    {
                        GameCenter.newMountMng.C2S_ReqRideMount(ChangeMount.DOWNRIDE, GameCenter.mainPlayerMng.MainPlayerInfo.CurMountInfo.ConfigID, MountReqRideType.AUTO);
                    }
                }
                break;
            }
            return(true);
        }
        return(false);
    }
示例#13
0
    protected virtual void UpdateAutoFightState(fsm.State _curState)
    {
        if (thisTarget == null || thisTarget.isDead)
        {
            //OnAutoPick();
            TaskStateType curTaskStateType = CheckMainTaskStateType();
            if (GameCenter.curGameStage.SceneType != SceneType.DUNGEONS && curTaskStateType != mainTaskStateType && curTaskStateType == TaskStateType.Finished)
            {
                thisPlayer.GoTraceTask(curTarTaskInfo);
                return;
            }
            else if (!commandMng.HasCommand())
            {
                stateMachine.Send((int)EventType.TARGET);                //怪死了直接进入寻怪状态,去掉回起始点的设定  TARGET状态中有回路点的设定 By邓成
            }
        }
        else
        {
            if (IsUseLoseHitAbility)
            {
                return;
            }
            if (thisTarget != null)
            {
                if (!thisPlayer.isRigidity && !thisPlayer.IsProtecting && !commandMng.HasCommand())
                {
                    if (thisTarget.typeID == ObjectType.SceneItem)
                    {
                        Command_MoveTo cmdMoveTo = new Command_MoveTo();
                        cmdMoveTo.destPos     = thisTarget.transform.position;
                        cmdMoveTo.maxDistance = 0f;
                        commandMng.PushCommand(cmdMoveTo);
                    }
                    if (IsEnemy(thisTarget))
                    {
                        if (thisTarget.typeID == ObjectType.MOB)
                        {
                            Monster mob = thisTarget as Monster;
                            if (mob != null && mob.isDead)
                            {
                                thisTarget = null;
                                return;
                            }
                        }
                        else if (thisTarget.typeID == ObjectType.Player)
                        {
                            OtherPlayer opc = thisTarget as OtherPlayer;
                            if (opc != null && opc.isDead)
                            {
                                thisTarget = null;
                                return;
                            }
                        }
                        switch (thisPlayer.AttakType)
                        {
                        case MainPlayer.AttackType.AUTOFIGHT:
                        case MainPlayer.AttackType.COMPLETE_TASK:
                            AbilityInstance instance = GameCenter.skillMng.GetAbilityRandom();
                            if (instance == null || instance.RestCD > 0)
                            {
                                if (lastAbilityInstance != null && lastAbilityInstance.thisSkillMode == SkillMode.NORMALSKILL && thisPlayer.IsProtecting)
                                {
                                    return;
                                }
                                if (lastNormalAbilityInstance != null && !lastNormalAbilityInstance.HasServerConfirm)
                                {
                                    Debug.LogError(lastNormalAbilityInstance.AbilityName + " Catch: 捕捉到上一次攻击尚未获得后台确认,前台即发动下一次普通攻击!");
                                }
                                instance = thisPlayer.abilityMng.GetNextDefaultAbility(thisTarget);
                                lastNormalAbilityInstance = instance;
                            }
                            else
                            {
                                instance.ResetResult(thisTarget);
                                instance.SetActor(thisPlayer, thisTarget);
                            }
                            if (instance != null)
                            {
                                lastAbilityInstance = instance;
                                thisPlayer.TryUseAbility(instance, true);
                            }
                            break;

                        default:
                            stateMachine.Send((int)EventType.FIGHT);
                            break;
                        }
                    }
                }
            }
        }
    }
示例#14
0
 protected virtual void UpdateFightState(fsm.State _curState)
 {
     if (thisTarget == null || thisTarget.isDead)
     {
         GameCenter.curMainPlayer.GoNormal();
     }
     else
     {
         if (IsUseLoseHitAbility)
         {
             return;
         }
         if (thisTarget != null)
         {
             if (!thisPlayer.isRigidity && !thisPlayer.IsProtecting && !commandMng.HasCommand())
             {
                 if (thisTarget.typeID == ObjectType.SceneItem)
                 {
                     Command_MoveTo cmdMoveTo = new Command_MoveTo();
                     cmdMoveTo.destPos     = thisTarget.transform.position;
                     cmdMoveTo.maxDistance = 0f;
                     commandMng.PushCommand(cmdMoveTo);
                 }
                 if (IsEnemy(thisTarget))
                 {
                     if (thisTarget.typeID == ObjectType.MOB)
                     {
                         Monster mob = thisTarget as Monster;
                         if (mob != null && mob.isDead)
                         {
                             thisTarget = null;
                             return;
                         }
                     }
                     else if (thisTarget.typeID == ObjectType.Player)
                     {
                         OtherPlayer opc = thisTarget as OtherPlayer;
                         if (opc != null && opc.isDead)
                         {
                             thisTarget = null;
                             return;
                         }
                     }
                     if (thisPlayer.AttakType == MainPlayer.AttackType.NORMALFIGHT)
                     {
                         if (lastNormalAbilityInstance != null && !lastNormalAbilityInstance.HasServerConfirm)
                         {
                             Debug.LogError(lastNormalAbilityInstance.AbilityName + " Catch: 捕捉到上一次攻击尚未获得后台确认,前台即发动下一次普通攻击!");
                         }
                         AbilityInstance instance = thisPlayer.abilityMng.GetNextDefaultAbility(thisTarget);
                         thisPlayer.TryUseAbility(instance, true);
                         lastNormalAbilityInstance = instance;
                     }
                     else if (thisPlayer.AttakType == MainPlayer.AttackType.AUTOFIGHT)
                     {
                         stateMachine.Send((int)EventType.AUTOFIGHT);
                     }
                 }
             }
         }
     }
 }