コード例 #1
0
        public virtual void Initializa(long local_player_pstid, CombatStartInfo combat_start_info)
        {
            //真正的local_player_pstid在局外,传进来就好;combat_start_info是给所有玩家、观战者、以及录像回放时,都一致的消息
            m_local_player_pstid = local_player_pstid;
            m_level_data         = GetConfigProvider().GetLevelData(combat_start_info.m_level_id);
            m_state            = CombatClientState.Loading;
            m_state_frame_cnt  = 0;
            m_state_start_time = -1;
            m_last_update_time = -1;
            m_waiting_cnt      = 0;
#if UNITY_EDITOR
            m_is_first_frame = true;
#endif

            AttributeSystem.Instance.InitializeAllDefinition(m_combat_factory.GetConfigProvider());
            ComponentTypeRegistry.RegisterDefaultComponents();
            BehaviorTreeNodeTypeRegistry.RegisterDefaultNodes();
            DamageModifier.RegisterDefaultModifiers();
            m_combat_factory.RegisterCommands();

            BehaviorTreeFactory.Instance.SetConfigProvider(m_combat_factory.GetConfigProvider());

            m_logic_world = m_combat_factory.CreateLogicWorld();
            m_logic_world.Initialize(this, combat_start_info.m_world_seed, true);
            m_render_world = m_combat_factory.CreateRenderWorld();
            m_render_world.Initialize(this, m_logic_world);
            m_logic_world.SetIRenderWorld(m_render_world);
            m_sync_client = m_combat_factory.CreateSyncClient();
            m_sync_client.Init(m_logic_world);

            BuildLogicWorld(combat_start_info);
            BuildRenderWorld(m_level_data);
        }
コード例 #2
0
        BTNode CreateBTNode(BehaviorTreeNodeData node_data)
        {
            BTNode btnode = BehaviorTreeNodeTypeRegistry.CreateBTNode(node_data.m_node_type);

            if (btnode == null)
            {
                return(null);
            }
            if (node_data.m_node_variables != null)
            {
                btnode.InitializeVariable(node_data.m_node_variables);
            }
            if (node_data.m_sub_nodes != null)
            {
                for (int i = 0; i < node_data.m_sub_nodes.Count; ++i)
                {
                    BTNode sub_btnode = CreateBTNode(node_data.m_sub_nodes[i]);
                    if (sub_btnode != null)
                    {
                        btnode.AddChild(sub_btnode);
                    }
                }
            }
            return(btnode);
        }