SetVariable() public method

public SetVariable ( string varName, object varValue ) : void
varName string
varValue object
return void
コード例 #1
0
 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)
         {
             if (i < args.Length)
             {
                 instance.SetVariable(m_ArgumentNames[i], args[i]);
             }
             else
             {
                 instance.SetVariable(m_ArgumentNames[i], null);
             }
         }
         ;
     }
 }
コード例 #2
0
 static public int SetVariable(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.String             a1;
         checkType(l, 2, out a1);
         System.Object a2;
         checkType(l, 3, out a2);
         self.SetVariable(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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]);
         };
     }
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
        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;
        }
コード例 #9
0
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         int unitId = m_UnitId.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 = scene.SceneContext.GetEntityByUnitId(unitId);
         if (null != obj) {
             ImpactInfo impactInfo = new ImpactInfo(impactId);
             impactInfo.StartTime = TimeUtility.GetLocalMilliseconds();
             impactInfo.ImpactSenderId = obj.GetId();
             impactInfo.SkillId = 0;
             if (null != impactInfo.ConfigData) {
                 obj.GetSkillStateInfo().AddImpact(impactInfo);
                 seq = impactInfo.Seq;
                 if (scene.SkillSystem.StartSkill(obj.GetId(), impactInfo.ConfigData, seq, locals)) {
                     Msg_RC_AddImpact addImpactBuilder = new Msg_RC_AddImpact();
                     addImpactBuilder.sender_id = obj.GetId();
                     addImpactBuilder.target_id = obj.GetId();
                     addImpactBuilder.impact_id = impactId;
                     addImpactBuilder.skill_id = -1;
                     addImpactBuilder.duration = impactInfo.DurationTime;
                     scene.NotifyAllUser(RoomMessageDefine.Msg_RC_AddImpact, addImpactBuilder);
                 }
             }
         }
         if (m_HaveSeq) {
             string varName = m_SeqVarName.Value;
             instance.SetVariable(varName, seq);
         }
     }
     return false;
 }
コード例 #10
0
 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;
 }
コード例 #11
0
 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;
 }
コード例 #12
0
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     bool ret = false;
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         if (m_StartTime <= 0) {
             long startTime = GameFramework.TimeUtility.GetLocalMilliseconds();
             m_StartTime = startTime;
         }
         bool triggered = false;
         for (int i = 0; i < m_MsgIds.Count; i++) {
             long time = instance.GetMessageTriggerTime(m_MsgIds[i].Value);
             if (time > m_StartTime) {
                 triggered = true;
                 break;
             }
         }
         if (triggered) {
             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;
 }
コード例 #13
0
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     int ct = 0;
     for (int i = 0; i < m_MsgIds.Count; i++) {
         ct += GfxStorySystem.Instance.CountMessage(m_MsgIds[i].Value);
     }
     bool ret = false;
     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;
 }
コード例 #14
0
 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;
 }