コード例 #1
0
 public void Destruct()
 {
     m_custom_data = null;
     m_type_data   = null;
     m_proto_data  = null;
     m_logic_world = null;
 }
コード例 #2
0
        Skill CreateSkill(int skill_index, int skill_cfgid)
        {
            LogicWorld      logic_world   = GetLogicWorld();
            SkillManager    skill_manager = logic_world.GetSkillManager();
            IConfigProvider config        = logic_world.GetConfigProvider();
            ObjectTypeData  skill_data    = config.GetSkillData(skill_cfgid);

            if (skill_data == null)
            {
                m_index2id[skill_index] = -1;
                return(null);
            }
            ObjectCreationContext object_context = new ObjectCreationContext();

            object_context.m_object_type_id = skill_cfgid;
            object_context.m_type_data      = skill_data;
            object_context.m_logic_world    = logic_world;
            object_context.m_owner_id       = ParentObject.ID;
            Skill skill = skill_manager.CreateObject(object_context);

            m_index2id[skill_index] = skill.ID;
            if (skill_index == DEFAULT_SKILL_INDEX)
            {
                m_default_skill_id = skill.ID;
            }
            if (skill.GetDefinitionComponent().StartsActive)
            {
                skill.Activate(GetCurrentTime());
            }
            return(skill);
        }
コード例 #3
0
        public ObjectTypeData GetObjectTypeData(int id)
        {
            ObjectTypeData type_data = null;

            if (!m_object_type_data.TryGetValue(id, out type_data))
            {
                return(null);
            }
            return(type_data);
        }
コード例 #4
0
        public ObjectTypeData GetEffectData(int id)
        {
            ObjectTypeData effect_data = null;

            if (!m_effect_data.TryGetValue(id, out effect_data))
            {
                return(null);
            }
            return(effect_data);
        }
コード例 #5
0
        public ObjectTypeData GetSkillData(int id)
        {
            ObjectTypeData skill_data = null;

            if (!m_skill_data.TryGetValue(id, out skill_data))
            {
                return(null);
            }
            return(skill_data);
        }
コード例 #6
0
        void InitSkillData()
        {
            //普攻技能
            ObjectTypeData skill_data = new ObjectTypeData();

            skill_data.m_name = "近战";

            ComponentData cd = new ComponentData();

            cd.m_component_type_id   = (int)CRC.Calculate("SkillDefinitionComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["max_range"]      = "1";
            cd.m_component_variables["cooldown_time"]  = "1";
            cd.m_component_variables["inflict_time"]   = "0.5";
            cd.m_component_variables["gathering_type"] = "Default";
            cd.m_component_variables["main_animation"] = "attack";
            skill_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("DirectDamageSkillComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["damage_amount"] = "100";
            skill_data.m_components_data.Add(cd);

            m_skill_data[1001] = skill_data;

            //弹道发射物
            skill_data        = new ObjectTypeData();
            skill_data.m_name = "弹道发射物";

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("SkillDefinitionComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["cooldown_time"]  = "1";
            cd.m_component_variables["inflict_time"]   = "0.5";
            cd.m_component_variables["gathering_type"] = "Default";
            cd.m_component_variables["main_animation"] = "attack";
            skill_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("CreateObjectSkillComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["object_type_id"]  = "103";
            cd.m_component_variables["object_proto_id"] = "103001";
            cd.m_component_variables["offset_x"]        = "0";
            cd.m_component_variables["offset_y"]        = "1";
            cd.m_component_variables["offset_z"]        = "1";
            cd.m_component_variables["generator_id"]    = "1";
            skill_data.m_components_data.Add(cd);

            m_skill_data[1011] = skill_data;
        }
コード例 #7
0
        Effect CreateEffect(int target_entity_id)
        {
            LogicWorld      logic_world    = m_generator.GetLogicWorld();
            EffectManager   effect_manager = logic_world.GetEffectManager();
            IConfigProvider config         = logic_world.GetConfigProvider();
            ObjectTypeData  effect_data    = config.GetEffectData(m_data.m_effect_id);

            if (effect_data == null)
            {
                return(null);
            }
            ObjectCreationContext object_context = new ObjectCreationContext();

            //m_object_proxy_id
            object_context.m_object_type_id = m_data.m_effect_id;
            object_context.m_type_data      = effect_data;
            object_context.m_logic_world    = logic_world;
            object_context.m_owner_id       = target_entity_id;
            Effect effect = effect_manager.CreateObject(object_context);

            return(effect);
        }
コード例 #8
0
ファイル: Object.cs プロジェクト: mengflyQ/GameFrameWork
        void InitializeComponentVariables(ObjectTypeData type_data)
        {
            if (type_data == null)
            {
                return;
            }
            List <ComponentData> components_data = type_data.m_components_data;

            for (int i = 0; i < components_data.Count; ++i)
            {
                Dictionary <string, string> variables = components_data[i].m_component_variables;
                if (variables == null || variables.Count == 0)
                {
                    continue;
                }
                Component component = GetComponent(components_data[i].m_component_type_id);
                if (component == null)
                {
                    continue;
                }
                component.InitializeVariable(variables);
            }
        }
コード例 #9
0
        public static Entity CreateEntityForSkillAndEffect(Component caller_component, Entity owner_entity, Target projectile_target, Vector3FP position_offset, FixPoint angle_offset, int object_type_id, int object_proto_id, FixPoint object_life_time, EffectGenerator attached_generator)
        {
            LogicWorld      logic_world = owner_entity.GetLogicWorld();
            IConfigProvider config      = logic_world.GetConfigProvider();
            ObjectTypeData  type_data   = config.GetObjectTypeData(object_type_id);

            if (type_data == null)
            {
                return(null);
            }

            PositionComponent owner_position_cmp = owner_entity.GetComponent(PositionComponent.ID) as PositionComponent;
            Vector3FP         source_pos         = owner_position_cmp.CurrentPosition;

            Vector2FP xz_facing;
            FixPoint  angle;
            Vector3FP facing;

            if (projectile_target == null)
            {
                xz_facing = owner_position_cmp.Facing2D;
                angle     = owner_position_cmp.FacingAngle;
                facing.x  = xz_facing.x;
                facing.y  = FixPoint.Zero;
                facing.z  = xz_facing.z;
            }
            else
            {
                Vector3FP target_pos = projectile_target.GetPosition(logic_world);
                xz_facing.x = target_pos.x - source_pos.x;
                xz_facing.z = target_pos.z - source_pos.z;
                xz_facing.Normalize();
                angle  = xz_facing.ToDegree();
                facing = target_pos - source_pos;
                facing.Normalize();
            }
            Vector2FP side      = xz_facing.Perpendicular();
            Vector2FP xz_offset = xz_facing * position_offset.z + side * position_offset.x;

            if (angle_offset != FixPoint.Zero)
            {
                angle += angle_offset;
                FixPoint radian = FixPoint.Degree2Radian(-angle);
                facing.x = FixPoint.Cos(radian);
                facing.z = FixPoint.Sin(radian);
            }

            Vector3FP         birth_position = new Vector3FP(source_pos.x + xz_offset.x, source_pos.y + position_offset.y, source_pos.z + xz_offset.z);
            BirthPositionInfo birth_info     = new BirthPositionInfo(birth_position.x, birth_position.y, birth_position.z, angle, owner_position_cmp.GetCurrentSceneSpace());

            ProjectileComponent owner_entity_projectile_component = owner_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent;

            if (owner_entity_projectile_component != null)
            {
                Entity original_owner = logic_world.GetEntityManager().GetObject(owner_entity_projectile_component.SourceEntityID);
                if (original_owner != null)
                {
                    owner_entity = original_owner;
                }
            }

            Player owner_player = owner_entity.GetOwnerPlayer();
            ObjectCreationContext object_context = new ObjectCreationContext();

            object_context.m_object_proxy_id = owner_player.ProxyID;
            object_context.m_object_type_id  = object_type_id;
            object_context.m_object_proto_id = object_proto_id;
            object_context.m_birth_info      = birth_info;
            object_context.m_type_data       = type_data;
            object_context.m_proto_data      = config.GetObjectProtoData(object_proto_id);
            object_context.m_logic_world     = logic_world;
            object_context.m_owner_id        = owner_player.ID;
            object_context.m_is_ai           = true;
            object_context.m_is_local        = owner_player.IsLocal;

            Entity created_entity = logic_world.GetEntityManager().CreateObject(object_context);

            DeathComponent death_component = created_entity.GetComponent(DeathComponent.ID) as DeathComponent;

            if (death_component != null && object_life_time > FixPoint.Zero)
            {
                death_component.SetLifeTime(object_life_time);
            }

            SummonedEntityComponent summoned_component = created_entity.GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent;

            if (summoned_component != null)
            {
                summoned_component.SetMaster(owner_entity);
            }

            ProjectileComponent projectile_component = created_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent;

            if (projectile_component != null)
            {
                ProjectileParameters param = RecyclableObject.Create <ProjectileParameters>();
                param.m_start_time       = logic_world.GetCurrentTime();
                param.m_life_time        = object_life_time;
                param.m_source_entity_id = owner_entity.ID;
                param.m_start_position   = birth_position;
                param.m_fixed_facing     = facing;
                if (projectile_target != null)
                {
                    param.m_target_entity_id = projectile_target.GetEntityID();
                    param.m_target_position  = projectile_target.GetPosition(logic_world);
                }
                else
                {
                    Skill          owner_skill     = null;
                    SkillComponent skill_componnet = caller_component as SkillComponent;
                    if (skill_componnet != null)
                    {
                        owner_skill = skill_componnet.GetOwnerSkill();
                    }
                    if (owner_skill != null && owner_skill.GetDefinitionComponent().ExternalDataType == SkillDefinitionComponent.NeedExternalTarget)
                    {
                        param.m_target_entity_id = 0;
                        FixPoint range = owner_skill.GetDefinitionComponent().MaxRange;
                        if (range <= 0)
                        {
                            range = FixPoint.Ten;  //ZZWTODO
                        }
                        if (projectile_component.Speed > FixPoint.Zero)
                        {
                            param.m_life_time = range / projectile_component.Speed;
                        }
                        param.m_target_position = param.m_start_position + param.m_fixed_facing * range;
                    }
                }
                param.m_generator_id = attached_generator == null ? 0 : attached_generator.ID;
                projectile_component.InitParam(param);
            }
            else if (attached_generator != null)
            {
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = owner_entity.ID;
                app_data.m_source_entity_id   = owner_entity.ID;
                attached_generator.Activate(app_data, created_entity);
                RecyclableObject.Recycle(app_data);
            }
            return(created_entity);
        }
コード例 #10
0
        void InitObjectTypeData()
        {
            //一些Player
            ObjectTypeData type_data = new ObjectTypeData();

            type_data.m_name      = "EnvironmentPlayer";
            m_object_type_data[1] = type_data;

            type_data             = new ObjectTypeData();
            type_data.m_name      = "AIEnemyPlayer";
            m_object_type_data[2] = type_data;

            type_data             = new ObjectTypeData();
            type_data.m_name      = "LocalPlayer";
            m_object_type_data[3] = type_data;

            type_data             = new ObjectTypeData();
            type_data.m_name      = "RealPlayer";
            m_object_type_data[4] = type_data;

            //虚拟的环境角色
            type_data               = new ObjectTypeData();
            type_data.m_name        = "EnvironmentEntity";
            m_object_type_data[100] = type_data;

            //可破坏的障碍物
            type_data        = new ObjectTypeData();
            type_data.m_name = "DamagableObstruct";

            ComponentData cd = new ComponentData();

            cd.m_component_type_id              = (int)CRC.Calculate("PositionComponent");
            cd.m_component_variables            = new Dictionary <string, string>();
            cd.m_component_variables["radius"]  = "0.5";
            cd.m_component_variables["height"]  = "1";
            cd.m_component_variables["visible"] = "True";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id            = (int)CRC.Calculate("ObstacleComponent");
            cd.m_component_variables          = new Dictionary <string, string>();
            cd.m_component_variables["ext_x"] = "0.5";
            cd.m_component_variables["ext_y"] = "0.5";
            cd.m_component_variables["ext_z"] = "0.5";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("DamagableComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["max_health"]     = "1000";
            cd.m_component_variables["current_health"] = "900";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("DeathComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["hide_delay"]   = "1";
            cd.m_component_variables["delete_delay"] = "2";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("ModelComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["bodyctrl_path"] = "bodyctrl";
            type_data.m_components_data.Add(cd);

            m_object_type_data[101] = type_data;

            //不可破坏的障碍物
            type_data        = new ObjectTypeData();
            type_data.m_name = "UndamagableObstruct";

            cd = new ComponentData();
            cd.m_component_type_id                      = (int)CRC.Calculate("PositionComponent");
            cd.m_component_variables                    = new Dictionary <string, string>();
            cd.m_component_variables["radius"]          = "0.5";
            cd.m_component_variables["height"]          = "1";
            cd.m_component_variables["collision_sende"] = "False";
            cd.m_component_variables["visible"]         = "True";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id            = (int)CRC.Calculate("ObstacleComponent");
            cd.m_component_variables          = new Dictionary <string, string>();
            cd.m_component_variables["ext_x"] = "0.5";
            cd.m_component_variables["ext_y"] = "0.5";
            cd.m_component_variables["ext_z"] = "0.5";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("ModelComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["bodyctrl_path"] = "bodyctrl";
            type_data.m_components_data.Add(cd);

            m_object_type_data[102] = type_data;

            //发射物
            type_data        = new ObjectTypeData();
            type_data.m_name = "Missile";

            cd = new ComponentData();
            cd.m_component_type_id                      = (int)CRC.Calculate("PositionComponent");
            cd.m_component_variables                    = new Dictionary <string, string>();
            cd.m_component_variables["radius"]          = "0";
            cd.m_component_variables["height"]          = "0";
            cd.m_component_variables["collision_sende"] = "False";
            cd.m_component_variables["visible"]         = "True";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("ProjectileComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("ModelComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["bodyctrl_path"] = "bodyctrl";
            type_data.m_components_data.Add(cd);

            m_object_type_data[103] = type_data;

            //Legacy英雄
            type_data        = new ObjectTypeData();
            type_data.m_name = "LegacyHero";

            cd = new ComponentData();
            cd.m_component_type_id            = (int)CRC.Calculate("LevelComponent");
            cd.m_component_variables          = new Dictionary <string, string>();
            cd.m_component_variables["level"] = "1";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("AttributeManagerComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id              = (int)CRC.Calculate("PositionComponent");
            cd.m_component_variables            = new Dictionary <string, string>();
            cd.m_component_variables["radius"]  = "0.5";
            cd.m_component_variables["height"]  = "1";
            cd.m_component_variables["visible"] = "True";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("LocomotorComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["max_speed"] = "5.0";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("PathFindingComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("EffectManagerComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("DamagableComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("DeathComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["hide_delay"]   = "1";
            cd.m_component_variables["delete_delay"] = "2";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("SkillManagerComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("StateComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("TargetingComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("ModelComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["bodyctrl_path"] = "bodyctrl";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("AnimationComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["animation_path"] = "bodyctrl/animationctrl";
            type_data.m_components_data.Add(cd);

            m_object_type_data[111] = type_data;

            //Mecanim英雄
            type_data        = new ObjectTypeData();
            type_data.m_name = "MecanimHero";

            cd = new ComponentData();
            cd.m_component_type_id            = (int)CRC.Calculate("LevelComponent");
            cd.m_component_variables          = new Dictionary <string, string>();
            cd.m_component_variables["level"] = "1";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("AttributeManagerComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id              = (int)CRC.Calculate("PositionComponent");
            cd.m_component_variables            = new Dictionary <string, string>();
            cd.m_component_variables["radius"]  = "0.5";
            cd.m_component_variables["height"]  = "1";
            cd.m_component_variables["visible"] = "True";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("LocomotorComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["max_speed"] = "5.0";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("PathFindingComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("EffectManagerComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("DamagableComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("DeathComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["hide_delay"]   = "1";
            cd.m_component_variables["delete_delay"] = "2";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("SkillManagerComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("StateComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id = (int)CRC.Calculate("TargetingComponent");
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("ModelComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["bodyctrl_path"] = "bodyctrl";
            type_data.m_components_data.Add(cd);

            cd = new ComponentData();
            cd.m_component_type_id   = (int)CRC.Calculate("AnimatorComponent");
            cd.m_component_variables = new Dictionary <string, string>();
            cd.m_component_variables["animator_path"] = "bodyctrl/animationctrl";
            type_data.m_components_data.Add(cd);

            m_object_type_data[112] = type_data;
        }