コード例 #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
ファイル: Object.cs プロジェクト: mengflyQ/GameFrameWork
        public T AddComponent <T>() where T : Component
        {
            int       component_type_id = ComponentTypeRegistry.ComponentType2ID(typeof(T));
            Component component         = AddComponent(component_type_id);

            return(component as T);
        }
コード例 #3
0
 static PositionComponent()
 {
     ComponentTypeRegistry.RegisterVariable(VID_X, ID);
     ComponentTypeRegistry.RegisterVariable(VID_Y, ID);
     ComponentTypeRegistry.RegisterVariable(VID_Z, ID);
     ComponentTypeRegistry.RegisterVariable(VID_BaseAngle, ID);
     ComponentTypeRegistry.RegisterVariable(VID_Radius, ID);
     ComponentTypeRegistry.RegisterVariable(VID_Height, ID);
 }
コード例 #4
0
ファイル: Object.cs プロジェクト: mengflyQ/GameFrameWork
        public Component GetComponent(System.Type type)
        {
            // PositionComponent cmp = object.GetComponent(typeof(PositionComponent)) as PositionComponent;
            int       component_type_id = ComponentTypeRegistry.ComponentType2ID(type);
            Component component;

            m_components.TryGetValue(component_type_id, out component);
            return(component);
        }
コード例 #5
0
ファイル: Object.cs プロジェクト: mengflyQ/GameFrameWork
        public T GetComponent <T>() where T : Component
        {
            // PositionComponent cmp = object.GetComponent<PositionComponent>();
            int       component_type_id = ComponentTypeRegistry.ComponentType2ID(typeof(T));
            Component component;

            if (!m_components.TryGetValue(component_type_id, out component))
            {
                return(null);
            }
            return(component as T);
        }
コード例 #6
0
        public void Reflect(Object obj, Attribute attribute, bool initialize = false)
        {
            int vid = m_config.m_reflection_property;

            if (vid != 0)
            {
                int component_type_id = ComponentTypeRegistry.GetVariableOwnerComponentID(vid);
                if (component_type_id != 0)
                {
                    Component component = obj.GetComponent(component_type_id);
                    if (component != null)
                    {
                        FixPoint old_value = component.GetVariable(vid);
                        FixPoint new_value = attribute.Value;
                        if (old_value != new_value)
                        {
                            component.SetVariable(vid, attribute.Value);
                        }
                    }
                }
            }
            vid = m_config.m_clamp_property;
            if (vid != 0)
            {
                int component_type_id = ComponentTypeRegistry.GetVariableOwnerComponentID(vid);
                if (component_type_id != 0)
                {
                    Component component = obj.GetComponent(component_type_id);
                    if (component != null)
                    {
                        FixPoint old_value = component.GetVariable(vid);
                        if (initialize)
                        {
                            if (old_value < m_config.m_clamp_min_value)  //ZZWTODO tricky
                            {
                                component.SetVariable(vid, attribute.Value);
                            }
                        }
                        else
                        {
                            FixPoint new_value = FixPoint.Clamp(old_value, m_config.m_clamp_min_value, attribute.Value);
                            if (old_value != new_value)
                            {
                                component.SetVariable(vid, new_value);
                            }
                        }
                    }
                }
            }
            //END
        }
コード例 #7
0
ファイル: Object.cs プロジェクト: mengflyQ/GameFrameWork
        public Component AddComponent(ComponentData component_data)
        {
            int component_type_id = component_data.m_component_type_id;

            if (!IsSuitableComponent(component_type_id))
            {
                return(null);
            }
            Component component = ComponentTypeRegistry.CreateComponent(component_type_id);

            if (component == null)
            {
                return(null);
            }
            component.ParentObject          = this;
            component.ComponentTypeID       = component_type_id;
            m_components[component_type_id] = component;
            if (component_data.m_component_variables != null)
            {
                component.InitializeVariable(component_data.m_component_variables);
            }
            return(component);
        }
コード例 #8
0
        public static FixPoint GetVariable(Object obj, int vid)
        {
            int component_type_id = ComponentTypeRegistry.GetVariableOwnerComponentID(vid);

            if (component_type_id == 0)
            {
                return(FixPoint.Zero);
            }
            while (obj != null)
            {
                Component component = obj.GetComponent(component_type_id);
                if (component != null)
                {
                    FixPoint value;
                    if (component.GetVariable(vid, out value))
                    {
                        return(value);
                    }
                }
                obj = obj.GetOwnerObject();
            }
            return(FixPoint.Zero);
        }
コード例 #9
0
 static LevelComponent()
 {
     ComponentTypeRegistry.RegisterVariable(VID_CurrentLevel, ID);
 }
コード例 #10
0
 static SkillManagerComponent()
 {
     ComponentTypeRegistry.RegisterVariable(VID_AttackSpeedRate, ID);
     ComponentTypeRegistry.RegisterVariable(VID_CooldownReduceRate, ID);
 }
コード例 #11
0
 static LocomotorComponent()
 {
     ComponentTypeRegistry.RegisterVariable(VID_MaxSpeed, ID);
 }
コード例 #12
0
 static DamagableComponent()
 {
     ComponentTypeRegistry.RegisterVariable(VID_MaxHealth, ID);
     ComponentTypeRegistry.RegisterVariable(VID_CurrentHealth, ID);
 }
コード例 #13
0
ファイル: Object.cs プロジェクト: mengflyQ/GameFrameWork
 protected virtual bool IsSuitableComponent(int component_type_id)
 {
     return(ComponentTypeRegistry.IsLogicComponent(component_type_id));
 }
コード例 #14
0
 protected override bool IsSuitableComponent(int component_type_id)
 {
     return(ComponentTypeRegistry.IsRenderComponent(component_type_id));
 }