public ISkillTriger CreateTriger(Dsl.ISyntaxComponent trigerConfig, SkillInstance instance)
 {
     ISkillTriger triger = null;
     string type = trigerConfig.GetId();
     ISkillTrigerFactory factory = GetFactory(type);
     if (null != factory) {
         try {
             triger = factory.Create();
             triger.Init(trigerConfig, instance);
         } catch (Exception ex) {
             GameFramework.LogSystem.Error("triger:{0} line:{1} failed.", trigerConfig.ToScriptString(), trigerConfig.GetLine());
             throw ex;
         }
     } else {
     #if !DEBUG
         GameFramework.LogSystem.Error("CreateTriger failed, type:{0}", type);
     #endif
     }
     if (null != triger) {
         GameFramework.LogSystem.Debug("CreateTriger, type:{0} triger:{1}", type, triger.GetType().Name);
     } else {
     #if !DEBUG
         GameFramework.LogSystem.Error("CreateTriger failed, type:{0}", type);
     #endif
     }
     return triger;
 }
 public static void FirstParse(Dsl.DslInfo dslInfo)
 {
     string id = dslInfo.GetId();
     if (id == "command") {
         if (dslInfo.Functions.Count == 2) {
             StorySystem.CommonCommands.CompositeCommand cmd = new CommonCommands.CompositeCommand();
             cmd.InitSharedData();
             Dsl.FunctionData first = dslInfo.First;
             cmd.Name = first.Call.GetParamId(0);
             Dsl.FunctionData second = dslInfo.Second;
             for (int ix = 0; ix < second.Call.GetParamNum(); ++ix) {
                 cmd.ArgNames.Add(second.Call.GetParamId(ix));
             }
             //注册
             StoryCommandManager.Instance.RegisterCommandFactory(cmd.Name, new CommonCommands.CompositeCommandFactory(cmd), true);
         }
     } else if (id == "value") {
         if (dslInfo.Functions.Count == 3) {
             StorySystem.CommonValues.CompositeValue val = new CommonValues.CompositeValue();
             val.InitSharedData();
             Dsl.FunctionData first = dslInfo.First;
             val.Name = first.Call.GetParamId(0);
             Dsl.FunctionData second = dslInfo.Second;
             for (int ix = 0; ix < second.Call.GetParamNum(); ++ix) {
                 val.ArgNames.Add(second.Call.GetParamId(ix));
             }
             Dsl.FunctionData third = dslInfo.Functions[2];
             val.ReturnName = third.Call.GetParamId(0);
             //注册
             StoryValueManager.Instance.RegisterValueFactory(val.Name, new CommonValues.CompositeValueFactory(val), true);
         }
     }
 }
Пример #3
0
 private void LoadCondition(Dsl.CallData callData)
 {
     int num = callData.GetParamNum();
     if (num > 0 && callData.GetId() == "if") {
         m_HaveCondition = true;
         m_Condition.InitFromDsl(callData.GetParam(0));
     }
 }
Пример #4
0
 public static Vector2 CalcVector2(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "vector2")
     return Vector2.zero;
       int num = callData.GetParamNum();
       if (2 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     return new Vector2(x, y);
       } else {
     return Vector2.zero;
       }
 }
Пример #5
0
 internal static Vector3 CalcVector3(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "vector3")
     return Vector3.Zero;
       int num = callData.GetParamNum();
       if (3 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     float z = float.Parse(callData.GetParamId(2));
     return new Vector3(x, y, z);
       } else {
     return Vector3.Zero;
       }
 }
Пример #6
0
 internal static Quaternion CalcEularRotation(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "eular")
     return Quaternion.Identity;
       int num = callData.GetParamNum();
       if (3 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     float z = float.Parse(callData.GetParamId(2));
     return Quaternion.CreateFromYawPitchRoll(x, y, z);
       } else {
     return Quaternion.Identity;
       }
 }
Пример #7
0
 public static Vector3 CalcEularAngles(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "eular")
     return Vector3.Zero;
       int num = callData.GetParamNum();
       if (3 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     float z = float.Parse(callData.GetParamId(2));
     return new Vector3(x, y, z) * 59.29578f;
       } else {
     return Vector3.Zero;
       }
 }
Пример #8
0
 public static Quaternion CalcQuaternion(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "quaternion")
     return Quaternion.identity;
       int num = callData.GetParamNum();
       if (4 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     float z = float.Parse(callData.GetParamId(2));
     float w = float.Parse(callData.GetParamId(3));
     return new Quaternion(x, y, z, w);
       } else {
     return Quaternion.identity;
       }
 }
Пример #9
0
 public static Color CalcColor(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "color")
     return Color.white;
       int num = callData.GetParamNum();
       if (4 == num) {
     float r = float.Parse(callData.GetParamId(0));
     float g = float.Parse(callData.GetParamId(1));
     float b = float.Parse(callData.GetParamId(2));
     float a = float.Parse(callData.GetParamId(3));
     return new Color(r, g, b, a);
       } else {
     return Color.white;
       }
 }
Пример #10
0
 public static Quaternion CalcEularRotation(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "eular")
     return Quaternion.identity;
       int num = callData.GetParamNum();
       if (3 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     float z = float.Parse(callData.GetParamId(2));
     try {
       return Quaternion.Euler(x, y, z);
     } catch {
       return Quaternion.identity;
     }
       } else {
     return Quaternion.identity;
       }
 }
        public static void FinalParse(Dsl.DslInfo dslInfo)
        {
            string id = dslInfo.GetId();
            if (id == "command") {
                if (dslInfo.Functions.Count == 2) {

                    Dsl.FunctionData first = dslInfo.First;
                    string name = first.Call.GetParamId(0);
                    IStoryCommandFactory factory = StoryCommandManager.Instance.FindFactory(name);
                    if (null != factory) {
                        StorySystem.CommonCommands.CompositeCommand cmd = factory.Create() as StorySystem.CommonCommands.CompositeCommand;
                        Dsl.FunctionData second = dslInfo.Second;
                        cmd.InitialCommands.Clear();
                        for (int ix = 0; ix < second.GetStatementNum(); ++ix) {
                            Dsl.ISyntaxComponent syntaxComp = second.GetStatement(ix);
                            IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp);
                            cmd.InitialCommands.Add(sub);
                        }
                    } else {
                        LogSystem.Error("Can't find command factory '{0}'", name);
                    }
                }
            } else if (id == "value") {
                if (dslInfo.Functions.Count == 3) {
                    Dsl.FunctionData first = dslInfo.First;
                    string name = first.Call.GetParamId(0);
                    IStoryValueFactory factory = StoryValueManager.Instance.FindFactory(name);
                    if (null != factory) {
                        StorySystem.CommonValues.CompositeValue val = factory.Build() as StorySystem.CommonValues.CompositeValue;
                        Dsl.FunctionData second = dslInfo.Second;
                        Dsl.FunctionData third = dslInfo.Functions[2];
                        val.InitialCommands.Clear();
                        for (int ix = 0; ix < third.GetStatementNum(); ++ix) {
                            Dsl.ISyntaxComponent syntaxComp = third.GetStatement(ix);
                            IStoryCommand sub = StoryCommandManager.Instance.CreateCommand(syntaxComp);
                            val.InitialCommands.Add(sub);
                        }
                    } else {
                        LogSystem.Error("Can't find value factory '{0}'", name);
                    }
                }
            }
        }
Пример #12
0
 public static Vector4 CalcVector4(Dsl.CallData callData)
 {
     if (null == callData || callData.GetId() != "vector4")
     return Vector4.zero;
       int num = callData.GetParamNum();
       if (4 == num) {
     float x = float.Parse(callData.GetParamId(0));
     float y = float.Parse(callData.GetParamId(1));
     float z = float.Parse(callData.GetParamId(2));
     float w = float.Parse(callData.GetParamId(3));
     return new Vector4(x, y, z, w);
       } else {
     return Vector4.zero;
       }
 }
 private void LoadUserId(Dsl.CallData callData)
 {
     if (callData.GetId() == "touser" && callData.GetParamNum() == 1) {
         m_UserId.InitFromDsl(callData.GetParam(0));
         m_HaveUserId = true;
     }
 }
Пример #14
0
 private void LoadVarName(Dsl.CallData callData)
 {
     if (callData.GetId() == "objid" && callData.GetParamNum() == 1) {
         m_ObjIdVarName.InitFromDsl(callData.GetParam(0));
         m_HaveObjId = true;
     }
 }
        private bool Init(Dsl.FunctionData skill)
        {
            bool ret = false;
            m_UseImpactsForInit = new List<SkillSectionOrMessageTriggers>();
            m_ImpactsForInit = new List<SkillSectionOrMessageTriggers>();
            m_DamagesForInit = new List<SkillSectionOrMessageTriggers>();
            if (null != skill && (skill.GetId() == "skill" || skill.GetId() == "emitskill" || skill.GetId() == "hitskill")) {
                ret = true;
                Dsl.CallData callData = skill.Call;
                if (null != callData && callData.HaveParam()) {
                    m_OuterDslSkillId = int.Parse(callData.GetParamId(0));
                    m_DslSkillId = m_OuterDslSkillId;
                }

                for (int i = 0; i < skill.Statements.Count; i++) {
                    if (skill.Statements[i].GetId() == "section") {
                        m_UseImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.Section));
                        m_ImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.Section));
                        m_DamagesForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.Section));
                        Dsl.FunctionData sectionData = skill.Statements[i] as Dsl.FunctionData;
                        if (null != sectionData) {
                            SkillSection section = new SkillSection();
                            section.Load(sectionData, this);
                            m_Sections.Add(section);
                        } else {
            #if DEBUG
                            string err = string.Format("Skill {0} DSL, section must be a function ! line:{1} section:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                            throw new Exception(err);
            #else
              LogSystem.Error("Skill {0} DSL, section must be a function !", m_DslSkillId);
            #endif
                        }
                    } else if (skill.Statements[i].GetId() == "onmessage") {
                        m_UseImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.Message));
                        m_ImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.Message));
                        m_DamagesForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.Message));
                        Dsl.FunctionData sectionData = skill.Statements[i] as Dsl.FunctionData;
                        if (null != sectionData) {
                            SkillMessageHandler handler = new SkillMessageHandler();
                            handler.Load(sectionData, this);
                            m_MessageHandlers.Add(handler);
                        } else {
            #if DEBUG
                            string err = string.Format("Skill {0} DSL, onmessage must be a function ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                            throw new Exception(err);
            #else
              LogSystem.Error("Skill {0} DSL, onmessage must be a function !", m_DslSkillId);
            #endif
                        }
                    } else if (skill.Statements[i].GetId() == "onstop") {
                        m_UseImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.OnStop));
                        m_ImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.OnStop));
                        m_DamagesForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.OnStop));
                        Dsl.FunctionData sectionData = skill.Statements[i] as Dsl.FunctionData;
                        if (null != sectionData) {
                            m_StopSection = new SkillMessageHandler();
                            m_StopSection.Load(sectionData, this);
                        } else {
            #if DEBUG
                            string err = string.Format("Skill {0} DSL, onstop must be a function ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                            throw new Exception(err);
            #else
              LogSystem.Error("Skill {0} DSL, onstop must be a function !", m_DslSkillId);
            #endif
                        }
                    } else if (skill.Statements[i].GetId() == "oninterrupt") {
                        m_UseImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.OnInterrupt));
                        m_ImpactsForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.OnInterrupt));
                        m_DamagesForInit.Add(new SkillSectionOrMessageTriggers(SectionOrMessageType.OnInterrupt));
                        Dsl.FunctionData sectionData = skill.Statements[i] as Dsl.FunctionData;
                        if (null != sectionData) {
                            m_InterruptSection = new SkillMessageHandler();
                            m_InterruptSection.Load(sectionData, this);
                        } else {
            #if DEBUG
                            string err = string.Format("Skill {0} DSL, oninterrupt must be a function ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                            throw new Exception(err);
            #else
              LogSystem.Error("Skill {0} DSL, oninterrupt must be a function !", m_DslSkillId);
            #endif
                        }
                    } else if (skill.Statements[i].GetId() == "emitskill") {
                        Dsl.FunctionData sectionData = skill.Statements[i] as Dsl.FunctionData;
                        if (null != sectionData) {
                            PrepareInnerEmitSkillInstances();
                            SkillInstance inst = new SkillInstance();
                            inst.Init(sectionData);
                            Dsl.CallData header = sectionData.Call;
                            int innerId = 0;
                            if (header.GetParamNum() > 0) {
                                innerId = int.Parse(header.GetParamId(0));
                            }
                            inst.m_InnerDslSkillId = GenInnerEmitSkillId(innerId);
                            inst.m_OuterDslSkillId = m_DslSkillId;
                            inst.m_DslSkillId = m_DslSkillId;
                            if (!m_EmitSkillInstances.ContainsKey(inst.InnerDslSkillId)) {
                                m_EmitSkillInstances.Add(inst.InnerDslSkillId, inst);
                            } else {
            #if DEBUG
                                string err = string.Format("Skill {0} DSL, emitskill id duplicate ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                                throw new Exception(err);
            #else
                                LogSystem.Error("Skill {0} DSL, emitskill id duplicate !", m_DslSkillId);
            #endif
                            }
                        } else {
            #if DEBUG
                            string err = string.Format("Skill {0} DSL, emitskill must be a function ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                            throw new Exception(err);
            #else
              LogSystem.Error("Skill {0} DSL, oninterrupt must be a function !", m_DslSkillId);
            #endif
                        }
                    } else if (skill.Statements[i].GetId() == "hitskill") {
                        Dsl.FunctionData sectionData = skill.Statements[i] as Dsl.FunctionData;
                        if (null != sectionData) {
                            PrepareInnerHitSkillInstances();
                            SkillInstance inst = new SkillInstance();
                            inst.Init(sectionData);
                            Dsl.CallData header = sectionData.Call;
                            int innerId = 0;
                            if (header.GetParamNum() > 0) {
                                innerId = int.Parse(header.GetParamId(0));
                            }
                            inst.m_InnerDslSkillId = GenInnerHitSkillId(innerId);
                            inst.m_OuterDslSkillId = m_DslSkillId;
                            inst.m_DslSkillId = m_DslSkillId;
                            if (!m_HitSkillInstances.ContainsKey(inst.InnerDslSkillId)) {
                                m_HitSkillInstances.Add(inst.InnerDslSkillId, inst);
                            } else {
            #if DEBUG
                                string err = string.Format("Skill {0} DSL, hitskill id duplicate ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                                throw new Exception(err);
            #else
                                LogSystem.Error("Skill {0} DSL, hitskill id duplicate !", m_DslSkillId);
            #endif
                            }
                        } else {
            #if DEBUG
                            string err = string.Format("Skill {0} DSL, hitskill must be a function ! line:{1} onmessage:{2}", m_DslSkillId, skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                            throw new Exception(err);
            #else
              LogSystem.Error("Skill {0} DSL, oninterrupt must be a function !", m_DslSkillId);
            #endif
                        }
                    } else {
            #if DEBUG
                        string err = string.Format("SkillInstance::Init, Skill {0} unknown part {1}, line:{2} section:{3}", m_DslSkillId, skill.Statements[i].GetId(), skill.Statements[i].GetLine(), skill.Statements[i].ToScriptString());
                        throw new Exception(err);
            #else
            LogSystem.Error("SkillInstance::Init, Skill {0} unknown part {1}", m_DslSkillId, skill.Statements[i].GetId());
            #endif
                    }
                }
            } else {
            #if DEBUG
                string err = string.Format("SkillInstance::Init, isn't skill DSL, line:{0} skill:{1}", skill.GetLine(), skill.ToScriptString());
                throw new Exception(err);
            #else
            LogSystem.Error("SkillInstance::Init, isn't skill DSL");
            #endif
            }
            BuildImpactAndDamageInfo();
            LogSystem.Debug("SkillInstance.Init section num:{0} {1} skill {2}", m_Sections.Count, ret, m_DslSkillId);
            return ret;
        }
 public IStoryCommand CreateCommand(Dsl.ISyntaxComponent commandConfig)
 {
     lock (m_Lock) {
         Dsl.CallData callData = commandConfig as Dsl.CallData;
         if (null != callData) {
             if (callData.IsHighOrder) {
                 Dsl.CallData innerCall = callData.Call;
                 if (innerCall.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PERIOD ||
                   innerCall.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_BRACKET ||
                   innerCall.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PERIOD_BRACE ||
                   innerCall.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PERIOD_BRACKET ||
                   innerCall.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PERIOD_PARENTHESIS) {
                     if (callData.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PARENTHESIS) {
                         //obj.member(a,b,...) or obj[member](a,b,...) or obj.(member)(a,b,...) or obj.[member](a,b,...) or obj.{member}(a,b,...) -> execinstance(obj,member,a,b,...)
                         Dsl.CallData newCall = new Dsl.CallData();
                         newCall.Name = new Dsl.ValueData("dotnetexec", Dsl.ValueData.ID_TOKEN);
                         newCall.SetParamClass((int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PARENTHESIS);
                         if (innerCall.IsHighOrder) {
                             newCall.Params.Add(innerCall.Call);
                             newCall.Params.Add(innerCall.GetParam(0));
                             for (int i = 0; i < callData.GetParamNum(); ++i) {
                                 Dsl.ISyntaxComponent p = callData.Params[i];
                                 newCall.Params.Add(p);
                             }
                         } else {
                             newCall.Params.Add(innerCall.Name);
                             newCall.Params.Add(innerCall.GetParam(0));
                             for (int i = 0; i < callData.GetParamNum(); ++i) {
                                 Dsl.ISyntaxComponent p = callData.Params[i];
                                 newCall.Params.Add(p);
                             }
                         }
                         return CreateCommand(newCall);
                     }
                 }
             } else if (callData.GetParamClass() == (int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_OPERATOR && callData.GetId() == "=") {
                 Dsl.CallData innerCall = callData.GetParam(0) as Dsl.CallData;
                 if (null != innerCall) {
                     //obj.property = val -> setinstance(obj,property,val)
                     Dsl.CallData newCall = new Dsl.CallData();
                     newCall.Name = new Dsl.ValueData("dotnetset", Dsl.ValueData.ID_TOKEN);
                     newCall.SetParamClass((int)Dsl.CallData.ParamClassEnum.PARAM_CLASS_PARENTHESIS);
                     if (innerCall.IsHighOrder) {
                         newCall.Params.Add(innerCall.Call);
                         newCall.Params.Add(innerCall.GetParam(0));
                         newCall.Params.Add(callData.GetParam(1));
                     } else {
                         newCall.Params.Add(innerCall.Name);
                         newCall.Params.Add(innerCall.GetParam(0));
                         newCall.Params.Add(callData.GetParam(1));
                     }
                     return CreateCommand(newCall);
                 }
             }
         }
         IStoryCommand command = null;
         string type = commandConfig.GetId();
         IStoryCommandFactory factory = GetFactory(type);
         if (null != factory) {
             try {
                 command = factory.Create();
                 command.Init(commandConfig);
             } catch (Exception ex) {
                 GameFramework.LogSystem.Error("command:{0} line:{1} failed.", commandConfig.ToScriptString(), commandConfig.GetLine());
                 throw ex;
             }
         } else {
     #if DEBUG
             string err = string.Format("CreateCommand failed, line:{0} command:{1}", commandConfig.GetLine(), commandConfig.ToScriptString());
             throw new Exception(err);
     #else
         GameFramework.LogSystem.Error("CreateCommand failed, type:{0} line:{1}", type, commandConfig.GetLine());
     #endif
         }
         if (null != command) {
             GameFramework.LogSystem.Debug("CreateCommand, type:{0} command:{1}", type, command.GetType().Name);
         } else {
     #if DEBUG
             string err = string.Format("CreateCommand failed, line:{0} command:{1}", commandConfig.GetLine(), commandConfig.ToScriptString());
             throw new Exception(err);
     #else
         GameFramework.LogSystem.Error("CreateCommand failed, type:{0} line:{1}", type, commandConfig.GetLine());
     #endif
         }
         return command;
     }
 }
 private void LoadIf(Dsl.CallData callData, SkillInstance instance)
 {
     int num = callData.GetParamNum();
     if (num > 0) {
         m_Type = callData.GetParamId(0);
     }
     m_HaveIsContinue = callData.GetId() != "if";
 }
Пример #18
0
 private void LoadVarName(Dsl.CallData callData)
 {
     if (callData.GetId() == "seq" && callData.GetParamNum() == 1) {
         m_SeqVarName.InitFromDsl(callData.GetParam(0));
         m_HaveSeq = true;
     }
 }