Example #1
0
 /// <summary>
 /// 恢复副本
 /// </summary>
 public static void ResumeInstance()
 {
     xc.Machine.State curState = Game.GetInstance().GetFSM().GetCurState();
     if (curState is CommonInstanceState)
     {
         var commstate = curState as CommonInstanceState;
         commstate.ResumeInstance();
     }
 }
Example #2
0
    /// <summary>
    /// 当前是否在指定的副本状态
    /// </summary>
    /// <param name="state"></param>
    /// <returns></returns>
    public static bool InstanceIsInState(uint state)
    {
        xc.Machine.State curState = Game.GetInstance().GetFSM().GetCurState();
        if (curState is CommonInstanceState)
        {
            var commstate = curState as CommonInstanceState;
            return(commstate.IsInState(state));
        }

        return(false);
    }
Example #3
0
    public static bool InstanceIsInPlay()
    {
        xc.Machine.State curState = Game.GetInstance().GetFSM().GetCurState();
        //PlayingInstanceState playingState = curState as PlayingInstanceState;
        //if (playingState != null)
        //{
        //    return playingState.IsInPlay();
        //}

        return(true);
    }
Example #4
0
    /// <summary>
    /// 指定uuid的角色是否显示归属
    /// </summary>
    /// <param name="uuid"></param>
    /// <returns></returns>
    public static bool IsAffiliation(uint uuid, uint teamId)
    {
        xc.Machine.State       curState          = Game.GetInstance().GetFSM().GetCurState();
        CommonLuaInstanceState wildInstanceState = curState as CommonLuaInstanceState;

        if (wildInstanceState != null && wildInstanceState.DataBossBehaviour != null)
        {
            return(wildInstanceState.DataBossBehaviour.IsAffiliation(uuid, teamId));
        }

        return(false);
    }
Example #5
0
        /// <summary>
        /// 初始化状态机
        /// </summary>
        void InitMachine()
        {
            m_Machine        = new Machine();
            m_InitState      = new xc.Machine.State((uint)EFSMState.DS_Init, m_Machine);
            m_NormalState    = new xc.Machine.State((uint)EFSMState.DS_Normal, m_Machine);
            m_ReconnectState = new xc.Machine.State((uint)EFSMState.DS_Reconnect, m_Machine);
            m_FailState      = new xc.Machine.State((uint)EFSMState.DS_Fail, m_Machine);

            //// 构建状态图
            m_InitState.AddTransition((uint)EFSMEvent.DE_ReconnectSucc, m_NormalState);       // 进入游戏
            m_InitState.AddTransition((uint)EFSMEvent.DE_NetDisconnnect, m_ReconnectState);   // 进入游戏前,如果附链接断开的话,也需要重连
            m_InitState.AddTransition((uint)EFSMEvent.DE_CannotReconnect, m_FailState);       // 不进行断线重连

            m_NormalState.AddTransition((uint)EFSMEvent.DE_NetDisconnnect, m_ReconnectState); // 网络断开
            m_NormalState.AddTransition((uint)EFSMEvent.DE_CannotReconnect, m_FailState);     // 不进行断线重连
            m_NormalState.AddTransition((uint)EFSMEvent.DE_Reset, m_InitState);               // 重新登录

            m_ReconnectState.AddTransition((uint)EFSMEvent.DE_ReconnectSucc, m_NormalState);  // 断线重连成功
            m_ReconnectState.AddTransition((uint)EFSMEvent.DE_ReconnectFail, m_FailState);    // 断线重连失败
            m_ReconnectState.AddTransition((uint)EFSMEvent.DE_CannotReconnect, m_FailState);  // 不进行断线重连
            m_ReconnectState.AddTransition((uint)EFSMEvent.DE_Reset, m_InitState);            // 重连过程中取消

            m_FailState.AddTransition((uint)EFSMEvent.DE_Retry, m_ReconnectState);
            m_FailState.AddTransition((uint)EFSMEvent.DE_Reset, m_InitState);

            /// 设置Enter/Exit/Update State的函数
            m_NormalState.SetEnterFunction(EnterState_Normal);
            m_NormalState.SetUpdateFunction(UpdateState_Normal);
            m_NormalState.SetExitFunction(ExitState_Normal);
            m_ReconnectState.SetEnterFunction(EnterState_Reconnect);
            m_ReconnectState.SetUpdateFunction(UpdateState_Reconnect);
            m_ReconnectState.SetExitFunction(ExitState_Reconnect);
            m_FailState.SetEnterFunction(EnterState_FailState);
            m_FailState.SetUpdateFunction(UpdateState_FailState);
            m_Machine.SetCurState(m_InitState);
        }
Example #6
0
    /// <summary>
    /// 获取自动战斗下一目标位置
    /// </summary>
    /// <returns>The auto runner target location.</returns>
    public static Vector3 GetAutoRunnerTargetLocation()
    {
        // 野外地图和洞穴
        uint instanceType = InstanceManager.GetInstance().InstanceType;

        if (instanceType == GameConst.WAR_TYPE_WILD)
        {
            xc.Machine.State       curState          = Game.GetInstance().GetFSM().GetCurState();
            CommonLuaInstanceState wildInstanceState = curState as CommonLuaInstanceState;
        }

        // 目标首先是最近的中立NPC和宝箱
        NpcPlayer closestNpc = NpcManager.Instance.GetClosestNpc(Neptune.Relationship.NEUTRAL);

        if (closestNpc != null && CanWalkTo(closestNpc.transform.position))
        {
            return(closestNpc.transform.position);
        }

        // 当前已经生成的boss
        Dictionary <UnitID, Actor> monsterList = ActorManager.Instance.MonsterSet;

        if (monsterList != null && monsterList.Count > 0)
        {
            Actor targetMonster = null;
            foreach (Actor actor in monsterList.Values)
            {
                Monster monster = actor as Monster;

                if (monster is Pet)
                {
                    continue;
                }

                if (actor.IsDead() == false && monster != null)
                {
                    // 目标首先是boss
                    if (monster.IsBoss() == true)
                    {
                        targetMonster = monster;
                        break;
                    }
                }
            }

            if (targetMonster != null && CanWalkTo(targetMonster.transform.position))
            {
                return(targetMonster.transform.position);
            }
        }

        // 还没生成的boss
        //List<MonsterGroupInfo> monsterGroupInfos = MonsterInfoManager.GetInstance().MonsterGroupInfos;
        //if (monsterGroupInfos != null && monsterGroupInfos.Count > 0)
        //{
        //    foreach (MonsterGroupInfo monsterGroupInfo in monsterGroupInfos)
        //    {
        //        if (monsterGroupInfo != null && monsterGroupInfo.HasSpawned == false && monsterGroupInfo.SpawnDirectly == true)
        //        {
        //            MonsterInfo targetMonster = null;
        //            foreach (MonsterInfo monster in monsterGroupInfo.Monsters)
        //            {
        //                DBFixedMonster dbFixedMonster = DBManager.GetInstance().GetDB<DBFixedMonster>();
        //                DBFixedMonster.FixedMonsterInfo fixedMonsterInfo = dbFixedMonster.GetFixedMonsterInfo((uint)monster.ActorId);
        //                if (fixedMonsterInfo != null)
        //                {
        //                    if (fixedMonsterInfo.mIsBoss == true)
        //                    {
        //                        targetMonster = monster;
        //                        break;
        //                    }
        //                }
        //                else
        //                {
        //                    GameDebug.LogError("GetAutoRunnerTargetLocation error, can not find actor id " + monster.ActorId);
        //                }
        //            }

        //            if (targetMonster != null && CanWalkTo(targetMonster.Position))
        //                return targetMonster.Position;
        //        }
        //    }
        //}

        // 已经生成的怪物
        if (monsterList != null && monsterList.Count > 0)
        {
            Actor targetMonster = null;
            int   index         = 0;
            foreach (Actor actor in monsterList.Values)
            {
                Monster monster = actor as Monster;


                if (monster is Pet)
                {
                    continue;
                }

                if (monster.IsDead())
                {
                    continue;
                }

                if (monster != null && monster.BeSummonedType == Monster.BeSummonType.NULL)
                {
                    // 目标有可能是第一个怪物
                    if (index == 0)
                    {
                        targetMonster = monster;
                    }
                }

                ++index;
            }

            if (targetMonster != null && CanWalkTo(targetMonster.transform.position))
            {
                return(targetMonster.transform.position);
            }
        }

        // 触发器
        //Dictionary<int, TriggerCollider> triggers = TriggerManager.Instance.Triggers;
        //if (triggers != null && triggers.Count > 0)
        //{
        //    foreach (TriggerCollider trigger in triggers.Values)
        //    {
        //        if (trigger.TriggerInfo.NeedNavigation == true)
        //        {
        //            bool hasEvent = false;
        //            //foreach (var eventId in trigger.TriggerInfo.EventsId)
        //            //{
        //            //    Destiny.DestinyNode node = Destiny.DestinyManager.Instance.GetRootNode(eventId);
        //            //    if (node != null)
        //            //    {
        //            //        Destiny.DestinyEventNode eventNode = node as Destiny.DestinyEventNode;

        //            //        if(eventNode != null && eventNode.Active)
        //            //        {
        //            //            hasEvent = true;
        //            //        }

        //            //        break;
        //            //    }
        //            //}

        //            if(hasEvent && CanWalkTo(trigger.transform.position))
        //            {
        //                return trigger.transform.position;
        //            }
        //        }

        //        if (trigger.TriggerInfo.Info == TriggerInfo.InfoType.PORTAL && trigger.TriggerInfo.NeedNavigation && CanWalkTo(trigger.transform.position))
        //        {
        //            return trigger.transform.position;
        //        }
        //    }
        //}

        // 还没生成的怪物
        //if (monsterGroupInfos != null && monsterGroupInfos.Count > 0)
        //{
        //    foreach (MonsterGroupInfo monsterGroupInfo in monsterGroupInfos)
        //    {
        //        if (monsterGroupInfo != null && monsterGroupInfo.HasSpawned == false && monsterGroupInfo.SpawnDirectly == true && CanWalkTo(monsterGroupInfo.Position))
        //            return monsterGroupInfo.Position;
        //    }
        //}

        // 传送点
        //        Dictionary<int, TriggerInfo> triggers = TriggerInfoManager.GetInstance().mTriggers;
        //        if (triggers != null && triggers.Count > 0)
        //        {
        //            foreach (TriggerInfo trigger in triggers.Values)
        //            {
        //                if (trigger.Info == TriggerInfo.InfoType.PORTAL)
        //                {
        //                    // 目标是第一个传送点
        //                    return trigger.Position;
        //                }
        //                if (trigger.NeedNavigation == true)
        //                {
        //
        //                }
        //            }
        //        }

        return(Vector3.zero);
    }
Example #7
0
    protected override void SetNameStyle()
    {
        UI3DText.StyleInfo styleInfo = new UI3DText.StyleInfo();
        styleInfo.Offset       = new Vector3(0, 2.8f, 0);
        styleInfo.HeadOffset   = new Vector3(0, this.Height, 0);
        styleInfo.ScreenOffset = UI3DText.NameTextScreenOffset;
        styleInfo.Scale        = Vector3.one;

        bool show_tips = false;

        styleInfo.IsShowBg  = PKModeManagerEx.Instance.IsLocalPlayerCanAttackActor(this, ref show_tips);
        styleInfo.SpritName = "Main@PKCan";
        int labelWidth = 100;//UserName.Length * 20;

        styleInfo.SpriteWidth     = labelWidth + 30;
        show_tips                 = false;
        styleInfo.IsShowBgPreHead = PKModeManagerEx.Instance.IsActorCanAttackLocalPlayer(this, ref show_tips);
        if (styleInfo.IsShowBg)
        {
            styleInfo.BgPreHeadOffset = new Vector3(styleInfo.SpriteWidth / 2 - 145, 2, 0);
        }
        else
        {
            styleInfo.BgPreHeadOffset = new Vector3(labelWidth / 2 - 110, 2, 0);
        }

        Actor local_player = Game.Instance.GetLocalPlayer();

        show_tips = false;
        styleInfo.IsEnemyRelation = !(PKModeManagerEx.Instance.IsFriendRelation(local_player, this));

        //更新归属
        xc.Machine.State       curState          = Game.GetInstance().GetFSM().GetCurState();
        CommonLuaInstanceState wildInstanceState = curState as CommonLuaInstanceState;

        if (wildInstanceState != null && wildInstanceState.DataBossBehaviour != null)
        {
            styleInfo.IsShowAffiliationPanel = wildInstanceState.DataBossBehaviour.IsAffiliation(this);
        }

        if (SceneHelp.Instance.IsInWorldBossExperienceInstance && this.IsLocalPlayer == false && this.IsPlayer() && this.IsDead())
        {
            styleInfo.LayoutIsVisiable = false;
        }
        else
        {
            styleInfo.LayoutIsVisiable = true;
        }

        // 和平模式,不显示血条,破碎死域副本内要总是显示血条
        if (PKModeManagerEx.Instance.CanShowPVPBlood(this) == false && SceneHelp.Instance.ForceShowHpBar == false)
        {
            SetShowBar(styleInfo, false);
        }
        else
        {
            SetShowBar(styleInfo, true);
        }

        TextNameBehavior nameBehavoir = GetBehavior <TextNameBehavior>();

        nameBehavoir.SetStyle(styleInfo);
    }