當前位置: 首頁>>代碼示例>>C#>>正文


C# StoryInstance.SetVariable方法代碼示例

本文整理匯總了C#中StorySystem.StoryInstance.SetVariable方法的典型用法代碼示例。如果您正苦於以下問題:C# StoryInstance.SetVariable方法的具體用法?C# StoryInstance.SetVariable怎麽用?C# StoryInstance.SetVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在StorySystem.StoryInstance的用法示例。


在下文中一共展示了StoryInstance.SetVariable方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExecCommand

 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     string objPath = m_ObjPath.Value;
     object componentType = m_ComponentType.Value;
     UnityEngine.GameObject obj = UnityEngine.GameObject.Find(objPath);
     if (null != obj) {
         UnityEngine.Component component = null;
         Type t = componentType as Type;
         if (null != t) {
             component = obj.AddComponent(t);
         } else {
             string name = componentType as string;
             if (null != name) {
                 t = Type.GetType(name);
                 component = obj.AddComponent(t);
             }
         }
         if (m_HaveObj) {
             string varName = m_ObjVarName.Value;
             instance.SetVariable(varName, component);
         }
     }
     return false;
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:24,代碼來源:GeneralCommands.cs

示例2: Trigger

 public void Trigger(StoryInstance instance, object[] args)
 {
     Prepare();
     instance.StackVariables = StackVariables;
     m_IsTriggered = true;
     m_Arguments = args;
     if (null != m_ArgumentNames) {
         for(int i=0;i<m_ArgumentNames.Length && i<args.Length;++i) {
             instance.SetVariable(m_ArgumentNames[i], args[i]);
         };
     }
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:12,代碼來源:StoryInstance.cs

示例3: ExecCommand

 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         bool triggered = false;
         Vector3 pos = m_Pos.Value;
         float radius = m_Radius.Value;
         string type = m_Type.Value;
         string eventName = m_EventName.Value;
         if (type == "user") {
             scene.KdTree.Query(pos, radius, (float distSqr, KdTreeObject kdObj) => {
                 if (kdObj.Object.EntityType != (int)EntityTypeEnum.Hero) {
                     scene.StorySystem.SendMessage(eventName, pos, radius, type);
                     triggered = true;
                     return false;
                 }
                 return true;
             });
         } else if (type == "npc") {
             scene.KdTree.Query(pos, radius, (float distSqr, KdTreeObject kdObj) => {
                 if (kdObj.Object.EntityType != (int)EntityTypeEnum.Hero) {
                     scene.StorySystem.SendMessage(eventName, pos, radius, type);
                     triggered = true;
                     return false;
                 }
                 return true;
             });
         }
         string varName = m_SetVar.Value;
         object varVal = m_SetVal.Value;
         object elseVal = m_ElseSetVal.Value;
         if (triggered) {
             instance.SetVariable(varName, varVal);
         } else {
             instance.SetVariable(varName, elseVal);
         }
     }
     return false;
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:39,代碼來源:GameLogicCommands.cs

示例4: ExecCommand

 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     bool triggered = false;
     string name = m_Name.Value;
     float radius = m_Radius.Value;
     string type = m_Type.Value;
     string eventName = m_EventName.Value;
     UnityEngine.GameObject obj = UnityEngine.GameObject.Find(name);
     if (null != obj) {
         UnityEngine.Vector3 pos = obj.transform.position;
         if (type == "myself") {
             EntityViewModel view = EntityController.Instance.GetEntityViewById(ClientModule.Instance.LeaderID);
             if (null != view && null != view.Actor) {
                 if ((view.Actor.transform.position - pos).sqrMagnitude < radius * radius) {
                     GfxStorySystem.Instance.SendMessage(eventName, name, radius, type);
                     triggered = true;
                 }
             }
         } else if (type == "anyenemy" || type == "anyfriend") {
             EntityInfo myself = ClientModule.Instance.GetEntityById(ClientModule.Instance.LeaderID);
             ClientModule.Instance.KdTree.Query(pos.x, pos.y, pos.z, radius, (float distSqr, KdTreeObject kdObj) => {
                 if (type == "anyenemy" && EntityInfo.GetRelation(myself, kdObj.Object) == CharacterRelation.RELATION_ENEMY ||
                     type == "anyfriend" && EntityInfo.GetRelation(myself, kdObj.Object) == CharacterRelation.RELATION_FRIEND) {
                     GfxStorySystem.Instance.SendMessage(eventName, name, radius, type);
                     triggered = true;
                     return false;
                 }
                 return true;
             });
         }
     }
     string varName = m_SetVar.Value;
     object varVal = m_SetVal.Value;
     object elseVal = m_ElseSetVal.Value;
     if (triggered) {
         instance.SetVariable(varName, varVal);
     } else {
         instance.SetVariable(varName, elseVal);
     }
     return false;
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:41,代碼來源:GameLogicCommands.cs

示例5: AddVariable

 private static void AddVariable(StoryInstance instance, string name, UnityEngine.GameObject control)
 {
     instance.SetVariable(name, control);
     UnityEngine.UI.Text text = control.GetComponent<UnityEngine.UI.Text>();
     if (null != text) {
         instance.SetVariable(string.Format("{0}_Text", name), text);
     }
     UnityEngine.UI.Image image = control.GetComponent<UnityEngine.UI.Image>();
     if (null != image) {
         instance.SetVariable(string.Format("{0}_Image", name), image);
     }
     UnityEngine.UI.RawImage rawImage = control.GetComponent<UnityEngine.UI.RawImage>();
     if (null != rawImage) {
         instance.SetVariable(string.Format("{0}_RawImage", name), rawImage);
     }
     UnityEngine.UI.Button button = control.GetComponent<UnityEngine.UI.Button>();
     if (null != button) {
         instance.SetVariable(string.Format("{0}_Button", name), button);
     }
     UnityEngine.UI.Dropdown dropdown = control.GetComponent<UnityEngine.UI.Dropdown>();
     if (null != dropdown) {
         instance.SetVariable(string.Format("{0}_Dropdown", name), dropdown);
     }
     UnityEngine.UI.InputField inputField = control.GetComponent<UnityEngine.UI.InputField>();
     if (null != inputField) {
         instance.SetVariable(string.Format("{0}_Input", name), inputField);
     }
     UnityEngine.UI.Slider slider = control.GetComponent<UnityEngine.UI.Slider>();
     if (null != inputField) {
         instance.SetVariable(string.Format("{0}_Slider", name), slider);
     }
     UnityEngine.UI.Toggle toggle = control.GetComponent<UnityEngine.UI.Toggle>();
     if (null != toggle) {
         instance.SetVariable(string.Format("{0}_Toggle", name), toggle);
     }
     UnityEngine.UI.ToggleGroup toggleGroup = control.GetComponent<UnityEngine.UI.ToggleGroup>();
     if (null != toggleGroup) {
         instance.SetVariable(string.Format("{0}_ToggleGroup", name), toggleGroup);
     }
     UnityEngine.UI.Scrollbar scrollbar = control.GetComponent<UnityEngine.UI.Scrollbar>();
     if (null != scrollbar) {
         instance.SetVariable(string.Format("{0}_Scrollbar", name), scrollbar);
     }
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:44,代碼來源:GameLogicCommands.cs

示例6: ExecCommand

        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            Scene scene = instance.Context as Scene;
            if (null != scene) {
                int objId = 0;
                if (m_ParamNum >= 5) {
                    Vector3 pos = m_Pos.Value;
                    float dir = m_Dir.Value;
                    int camp = m_Camp.Value;
                    int linkId = m_LinkId.Value;
                    objId = scene.CreateEntity(m_UnitId.Value, pos.X, pos.Y, pos.Z, dir, camp, linkId);
                    if (m_ParamNum > 6) {
                        int aiLogic = m_AiLogic.Value;

                        EntityInfo charObj = scene.SceneContext.GetEntityById(objId);
                        if (null != charObj) {
                            charObj.GetAiStateInfo().Reset();
                            charObj.GetAiStateInfo().AiLogic = aiLogic;
                            if (m_ParamNum > 7) {
                                int leaderId = m_LeaderId.Value;
                                charObj.GetAiStateInfo().LeaderID = leaderId;
                            } else {
                                charObj.GetAiStateInfo().LeaderID = 0;
                            }
                            IEnumerable aiParams = m_AiParams.Value;
                            int ix = 0;
                            foreach (string aiParam in aiParams) {
                                if (ix < AiStateInfo.c_MaxAiParamNum) {
                                    charObj.GetAiStateInfo().AiParam[ix] = aiParam;
                                    ++ix;
                                } else {
                                    break;
                                }
                            }
                        }
                    }
                    EntityInfo obj = scene.GetEntityById(objId);
                    if (null != obj) {
                        Msg_RC_CreateNpc msg = DataSyncUtility.BuildCreateNpcMessage(obj);
                        scene.NotifyAllUser(RoomMessageDefine.Msg_RC_CreateNpc, msg);
                    }
                }
                if (m_HaveObjId) {
                    string varName = m_ObjIdVarName.Value;
                    instance.SetVariable(varName, objId);
                }
            }
            return false;
        }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:49,代碼來源:NpcCommands.cs

示例7: ExecCommand

 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     int objId = m_ObjId.Value;
     int impactId = m_ImpactId.Value;
     int seq = 0;
     Dictionary<string, object> locals = new Dictionary<string, object>();
     for (int i = 0; i < m_Args.Count - 1; i += 2) {
         string key = m_Args[i].Value as string;
         object val = m_Args[i + 1].Value;
         if (!string.IsNullOrEmpty(key)) {
             locals.Add(key, val);
         }
     }
     EntityInfo obj = ClientModule.Instance.GetEntityById(objId);
     if (null != obj) {
         ImpactInfo impactInfo = new ImpactInfo(impactId);
         impactInfo.StartTime = TimeUtility.GetLocalMilliseconds();
         impactInfo.ImpactSenderId = objId;
         impactInfo.SkillId = 0;
         if (null != impactInfo.ConfigData) {
             obj.GetSkillStateInfo().AddImpact(impactInfo);
             seq = impactInfo.Seq;
             GfxSkillSystem.Instance.StartSkill(objId, impactInfo.ConfigData, seq, locals);
         }
     }
     if (m_HaveSeq) {
         string varName = m_SeqVarName.Value;
         instance.SetVariable(varName, seq);
     }
     return false;
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:31,代碼來源:ObjectCommands.cs

示例8: ExecCommand

 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     bool ret = false;
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         int ct = 0;
         for (int i = 0; i < m_StoryIds.Count; i++) {
             ct += scene.StorySystem.CountStory(m_StoryIds[i].Value);
         }
         if (ct <= 0) {
             string varName = m_SetVar.Value;
             object varVal = m_SetVal.Value;
             instance.SetVariable(varName, varVal);
         } else {
             int timeout = m_TimeoutVal.Value;
             int curTime = m_CurTime;
             m_CurTime += (int)delta;
             if (timeout <= 0 || curTime <= timeout) {
                 ret = true;
             } else {
                 string varName = m_TimeoutSetVar.Value;
                 object varVal = m_TimeoutSetVal.Value;
                 instance.SetVariable(varName, varVal);
             }
         }
     }
     return ret;
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:28,代碼來源:GeneralCommands.cs

示例9: ExecCommand

 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     bool ret = false;
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         int ct = 0;
         for (int i = 0; i < m_MsgIds.Count; i++) {
             ct += userThread.StorySystem.CountMessage(m_MsgIds[i].Value);
         }
         if (ct <= 0) {
             string varName = m_SetVar.Value;
             object varVal = m_SetVal.Value;
             instance.SetVariable(varName, varVal);
         } else {
             int curTime = m_CurTime;
             m_CurTime += (int)delta;
             if (curTime <= m_TimeoutVal.Value) {
                 ret = true;
             } else {
                 string varName = m_TimeoutSetVar.Value;
                 object varVal = m_TimeoutSetVal.Value;
                 instance.SetVariable(varName, varVal);
             }
         }
     }
     return ret;
 }
開發者ID:dreamanlan,項目名稱:CSharpGameFramework,代碼行數:27,代碼來源:GeneralCommands.cs


注:本文中的StorySystem.StoryInstance.SetVariable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。