static bool Execute_Func_Pointer_Variable(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { o = null; if (e.isFUNCTION()) { if (xmlScriptExecFunc.ExecuteFunction(e, scrObj, stack, out o)) { return(true); } throw new SystemException("ERROR EXECUTE FUNCTION " + e.raw); } else if (e.isPOINTER()) { if (xmlScriptExecPointer.ExecutePointer(e, scrObj, stack, out o)) { return(true); } throw new SystemException("ERROR EXECUTE POINTER" + e.raw); } else if (e.isVARIABLE()) { if (xmlScriptExecVar.ExecuteVariable(e, scrObj, stack, out o)) { return(true); } throw new SystemException("ERROR EXECUTE VARIABLE" + e.raw); } return(false); }
public bool IsStrongAgainst(ELEMENT atk, ELEMENT def) { if (atk == ELEMENT.FIRE && def == ELEMENT.GRASS) { return(true); } if (atk == ELEMENT.WATER && def == ELEMENT.FIRE) { return(true); } if (atk == ELEMENT.GRASS && def == ELEMENT.WATER) { return(true); } if (atk == ELEMENT.PLASMA && def == ELEMENT.ICE) { return(true); } if (atk == ELEMENT.ICE && def == ELEMENT.ELECTRC) { return(true); } if (atk == ELEMENT.ELECTRC && def == ELEMENT.PLASMA) { return(true); } return(false); }
public Disease(ELEMENT color) { Color = color; TotalCubes = 24; CubesInSupply = 24; Cured = false; }
public void SetUpdate(string i_updateFuncName, GameObject obj) { var updateFuncName = i_updateFuncName.Replace("()", ""); var scrObj = GetScriptObj(obj); ELEMENT updatefunc; ELEMENT pgmelement; var b = ELEMENT.FindFunctionFromRoot(m_rootElement, updateFuncName, out updatefunc, out pgmelement); Debug.Log(m_rootElement); if (!b) { throw new SystemException("CANNOT FIND FUNCTION : " + i_updateFuncName); } Debug.Log("updatefunc = " + updatefunc); scrObj.m_update.function = updatefunc; scrObj.m_update.stack = m_stackval.FindStack(pgmelement.decname); { var parentScrObj = (xmlScriptObj)hgca.FindAscendantComponent(scrObj.gameObject, typeof(xmlScriptObj)); if (parentScrObj != null) { scrObj.m_valid = parentScrObj.m_valid; } } }
public static object CreateNewObject(ELEMENT e, object[] args, xmlScriptObj scrObj, STACKVAL stack) { ELEMENT last = e.GetPointerLast(); string pointerstr = e.GetPointerString(); string name = string.IsNullOrEmpty(pointerstr) ? last.raw : pointerstr + "." + last.raw; object o = null; var t = GetTypeOf(name); if (hglEtc.check_head(t.ToString(), "xmlScriptJS.")) { if (args != null) { var jsargs = new xmlScriptJS.ARGS(); jsargs.m_args = args; o = System.Activator.CreateInstance(t, jsargs); } else { o = System.Activator.CreateInstance(t); } return(o); } var nargs = xmlScriptGetMethod.CreateArgsForCreateInstance(t, args); o = System.Activator.CreateInstance(t, nargs); return(o); }
public static bool InvokeFunc(ELEMENT ie, object[] args, xmlScriptObj baseObj, STACKVAL stack, out object o) { // ref : http://dobon.net/vb/dotnet/programing/typegetmember.html o = null; ELEMENT e = ie; ELEMENT last = e.GetPointerLast(); string func = last.raw; object p = null; Type t = null; p = GetPropaty(e, baseObj, stack); if (p != null) { t = xmlScriptGetMethod.ObjectGetType(p); } else //if (xmlEtc.CountCharInString(pointerstr,'.') == 1) // **.**. { string pointerstr = e.GetPointerString(); t = GetTypeOf(pointerstr); } if (t == null) { throw new SystemException("ERROR CAN'T SOLVE TYPE :" + e.GetPointerString()); } if (string.IsNullOrEmpty(func) || t == null) { throw new SystemException("ERROR NOT DEFINED FUNC NAME"); } return(__InvokeFunc(last, args, ref o, func, p, t)); }
private static bool __InvokeFunc(ELEMENT e, object[] iargs, ref object o, string func, object p, Type t) { object[] args = iargs; System.Reflection.MethodInfo mi = null; if (CACHEDATA.enable && e.cache != null) { if (e.cache.info != null && xmlScriptGetMethod.ObjectGetType(e.cache.info) == typeof(System.Reflection.MethodInfo)) { mi = (System.Reflection.MethodInfo)e.cache.info; } } if (mi == null) { mi = xmlScriptGetMethod.GetMethod2(t, func, iargs); } if (mi == null) { throw new SystemException("ERROR CAN'T FIND METHOD:" + func); } o = xmlScriptGetMethod.MethodInfoInvoke(mi, p, args); if (CACHEDATA.enable && e.cache == null) { e.cache = new CACHEDATA() { info = mi }; } return(true); }
public ELEMENT SetAllExceptEnum(ELEMENT oriEnum, params ELEMENT[] addenums) { oriEnum = ELEMENT.All; for (int i = 0; i < addenums.Length; i++) { oriEnum = RemoveEnum(oriEnum, addenums[i]); } return(oriEnum); }
public City(string name, ELEMENT color, REGION region, Point coords) { Name = name; Color = color; TrueColor = color; Region = region; Coords = coords; X = coords.X - 24; Y = coords.Y - 24; Status = STATUS.NORMAL; }
public static ELEMENT ChoseElement(bool useElement, ELEMENT currentElement) { int newIndex = new Random().Next(0, ELEMENT_COUNT - 1); if (useElement) { while (newIndex == (int)currentElement) { newIndex = new Random().Next(0, ELEMENT_COUNT - 1); } } return((ELEMENT)newIndex); }
public static object GetArrayIndex(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack) { if (!e.isBLOCK_L()) { return(null); } var p = e.GetListElement(0); if (!p.isNONE()) { return(xmlScriptFunc.Execute(p, scrObj, stack)); } return(null); }
public object RunFunction(string funcname, object args, xmlScriptObj scrObj) { ELEMENT funcElement; ELEMENT pgmElement; var b = ELEMENT.FindFunctionFromRoot(m_rootElement, funcname, out funcElement, out pgmElement); if (!b) { return(false); } var stack = m_stackval.FindStack(pgmElement.decname); return(xmlScriptFunc.ExecuteDEC_FUNC(funcElement, scrObj, stack, args)); }
public static object[] GetArgs(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack) { if (!e.isBLOCK_C()) { return(null); } var arglist = new object[e.GetListCount()]; for (int i = 0; i < e.GetListCount(); i++) { arglist[i] = xmlScriptFunc.Execute(e.GetListElement(i), scrObj, stack); } return(arglist); }
void MovePage(PAGE page) { switch (page) { case PAGE.TITLE: DisablePage(); prevePage = PAGE.TITLE; title.gameObject.SetActive(true); break; case PAGE.MAIN: DisablePage(); prevePage = PAGE.TITLE; main.gameObject.SetActive(true); SetButton(); //topUi.gameObject.SetActive(true); break; case PAGE.GUIDE: DisablePage(); guide.gameObject.SetActive(true); //topUi.gameObject.SetActive(true); SetButton(); break; case PAGE.MODE: DisablePage(); prevePage = PAGE.MAIN; mode.gameObject.SetActive(true); break; case PAGE.LEARNING: DisablePage(); prevePage = PAGE.MODE; element = ELEMENT.None; learning.gameObject.SetActive(true); ToggleItemManager.Instance.SetTogglePannelList(); break; case PAGE.TEST: DisablePage(); prevePage = PAGE.MODE; element = ELEMENT.None; test.gameObject.SetActive(true); break; default: break; } }
//static int pgm_num = 0; public static void ExecutePROGRAM(ELEMENT i_e, xmlScriptObj scrObj, STACKVAL stack) { ELEMENT e = i_e; if (e.list != null) { foreach (var sentence in e.list) { if (sentence.isSENTENCE()) { Execute(sentence, scrObj, stack); } } } }
static object Execute_OP(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack) { if (!e.isOP()) { return(null); } object[] args = null; Type[] types = null; object o = null; var p0 = Execute(e.GetListElement(0), scrObj, stack); var p1 = Execute(e.GetListElement(1), scrObj, stack); if (e.GetOP_ARGC() == 2) { args = new object[] { p0, p1 }; types = new Type[] { xmlScriptGetMethod.ObjectGetType(p0), xmlScriptGetMethod.ObjectGetType(p1) }; } else if (e.GetOP_ARGC() == 1) { args = new object[] { p0 }; types = new Type[] { xmlScriptGetMethod.ObjectGetType(p0) }; } o = xmlScriptOP._Execute_OP_INTFLOATDOUBLE(e, e.GetOP_ARGC(), p0, p1, scrObj, stack); if (o != null) { return(o); } o = xmlScriptOP._Execute_OP_STRING(e, p0, p1, scrObj, stack); if (o != null) { return(o); } { var t = xmlScriptGetMethod.ObjectGetType(p0); if (t == null) { throw new System.Exception(e + " Unexcted Operation, nonetype"); } object[] iparam = new object[] { p0, p1 }; var mi = xmlScriptGetMethod.GetMethod2(t, e.group.ToString(), iparam); return(xmlScriptGetMethod.MethodInfoInvoke(mi, null, iparam)); } throw new System.Exception(e + " Unexcted Operation"); }
public static bool ExecutePointer(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { ELEMENT last = e.GetPointerLast(); var pointerstr = e.GetPointerString(); if (xmlScriptExecFunc.ExecuteFunction(e, scrObj, stack, out o)) { return(true); } if (xmlScriptExecVar.ExecuteVariable(e, scrObj, stack, out o)) { return(true); } throw new SystemException("ERROR EXECUTE POINTER" + e.raw); }
public static bool _ObjectInvokeFunc(object ip, ELEMENT e, xmlScriptObj baseObj, STACKVAL stack, out object o) { o = null; if (ip == null) { throw new SystemException("ERROR THE PARENT OF THE FUNCTION IS NULL :" + e.ToString()); } if (!e.isFUNCTION()) { throw new SystemException("ERROR STATEMENT IS NOT FUNCTION :" + e.ToString()); } var t = xmlScriptGetMethod.ObjectGetType(ip); object[] arglist = xmlScriptExecFunc.GetArgs(e, baseObj, stack); return(__InvokeFunc(e, arglist, ref o, e.raw, ip, t)); }
public void RunFunctionFromHTML(string i_funcName, object args, GameObject obj = null) { var funcname = i_funcName.Substring(0, i_funcName.IndexOf('(')); var scrObj = GetScriptObj(obj); ELEMENT funcElement; ELEMENT pgmElement; var b = ELEMENT.FindFunctionFromRoot(m_rootElement, funcname, out funcElement, out pgmElement); if (!b) { throw new SystemException("CANNOT FIND FUNCTION: " + i_funcName); } var stack = m_stackval.FindStack(pgmElement.decname); xmlScriptFunc.ExecuteDEC_FUNC(funcElement, scrObj, stack, args); }
public static bool ExecuteSetPointer(ELEMENT e, object val, xmlScriptObj scrObj, STACKVAL stack) { if (!e.isPOINTER()) { return(false); } ELEMENT last = e.GetPointerLast(); var pointerstr = e.GetPointerString(); // GetPointerToString(e,out last ); var o = xmlScriptReflection.SetPropaty(e, new object[] { val }, scrObj, stack); if (o != null) { return(true); } return(false); }
public static bool CallScriptFunction(string funcname, xmlScriptObj scrObj, STACKVAL stack, object args, out object o) { o = null; ELEMENT funcElement; ELEMENT pgmElement; var b = ELEMENT.FindFunction(stack, funcname, out funcElement, out pgmElement); if (!b) { b = ELEMENT.FindFunctionFromRoot(scrObj.m_rootElement, funcname, out funcElement, out pgmElement); } if (!b) { return(false); } o = xmlScriptFunc.ExecuteDEC_FUNC(funcElement, scrObj, stack, args); return(true); }
public static bool ExecuteValiable_GetFromStack(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { o = null; if (!e.isVARIABLE()) { return(false); } if (e.isVARIABLE_NOTARRAY()) { o = stack.GetVal(e.raw); return(true); } if (e.GetListCount() == 1) { var index = xmlScriptArray.GetArrayIndex(e.GetListElement(0), scrObj, stack);// Debug.LogError("index = " + index); var array = stack.GetVal(e.raw); if (array == null) { Debug.LogError("ExecuteValiable_GetFromStack #3x ERROR "); return(false); } if (xmlScriptGetMethod.ObjectGetType(array) == typeof(xmlScriptJS.Array)) { o = ((xmlScriptJS.Array)array).Get(index); } } else { object[] indexList = new object[e.GetListCount()]; for (int i = 0; i < e.GetListCount(); i++) { indexList[i] = xmlScriptArray.GetArrayIndex(e.GetListElement(i), scrObj, stack); } var array = stack.GetVal(e.raw); if (array == null) { return(false); } if (array != null && xmlScriptGetMethod.ObjectGetType(array) == typeof(xmlScriptJS.Array)) { o = xmlScriptJS.Array.GetMultidimension(array, indexList); } } return(true); }
public static object CreateArray(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack) { if (!e.isBLOCK_L()) { return(null); } if (e.GetListCount() == 0) { return(null); } var array = new xmlScriptJS.Array(); for (int i = 0; i < e.GetListCount(); i++) { array.Set(i, xmlScriptFunc.Execute(e.GetListElement(i), scrObj, stack)); } return(array); }
public static bool ExecuteVariable(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { string pointerstr = e.GetPointerString(); ELEMENT last = e.GetPointerLast(); if (e.isVARIABLE()) { if (ExecuteValiable_GetFromStack(e, scrObj, stack, out o)) { return(true); } } o = xmlScriptReflection.GetPropaty(e, scrObj, stack); if (o != null) { return(true); } return(false); }
public static object _Execute_OP_STRING(ELEMENT e, object p0, object p1, xmlScriptObj scrObj, STACKVAL stack) { if (p0 == null || p1 == null) { return(null); } if (xmlScriptGetMethod.ObjectGetType(p0) == typeof(string)) { string a = p0.ToString(); string b = p1.ToString(); switch (e.group) { case GROUP.op_Addition: return(a + b); case GROUP.op_Equality: return((bool)(a == b)); case GROUP.op_Inequality: return((bool)(a != b)); } throw new SystemException(e + "Unexpected Operation"); } return(null); }
public IEnumerator Init() { CACHEDATA.enable = m_enableCACHE; m_rootElement = new ELEMENT() { group = GROUP.ROOT }; m_rootElement.list = new List <ELEMENT>(); m_stackval = new STACKVAL(); { var scrObj = gameObject.GetComponent <xmlScriptObj>(); if (scrObj != null) { Destroy(scrObj); yield return(null); scrObj = gameObject.AddComponent <xmlScriptObj>(); } } }
public bool AddCubes(int count, ELEMENT color) { // Add cubes and return true if outbreak occurs ItemQuantity cubes = Items.FirstOrDefault(i => i.Element == color); if (cubes == null) { cubes = new ItemQuantity(color, count); Items.Add(cubes); } else { cubes.Add(count); } if (cubes.Count > 3) { cubes.Count = 3; return(true); } else { return(false); } }
public static object ExecuteDEC_FUNC(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, object args) { if (e == null || !e.isDEC_FUNC()) { return(null); } var newstack = stack.CreateStack(e.decname, e); var block_c = e.GetListElement(0); for (int i = 0; i < block_c.GetListCount(); i++) { var vname = block_c.GetListElement(i).raw; var val = ((object[])args)[i]; newstack.DeclareLocalVal(vname); newstack.SetVal(vname, val); } var o = Execute(e.GetListElement(1), scrObj, newstack); stack.DestroyStack(newstack); return(o); }
static object _ObjectGetPropaty(object obj, ELEMENT ie, xmlScriptObj scrObj, STACKVAL stack) { object o = null; if (obj == null) { throw new SystemException("ERRPOR POINTERS HAS NULL:" + ie); } ELEMENT e = ie; if (ie.isPOINTER()) { e = ie.GetPointerInside(); } switch (e.group) { case GROUP.VARIABLE: if (e.isVARIABLE_ARRAY()) { throw new SystemException("ERROR THE ARRAY IN THE MIDDLE OF POINTER ISN'T SUPPORTED."); } return(__ObjectGetPropaty(e, obj, e.raw)); case GROUP.FUNCTION: if (_ObjectInvokeFunc(obj, e, scrObj, stack, out o)) { return(o); } throw new SystemException("ERROR FUNCTION :" + e.ToString()); default: throw new SystemException("ERROR NOT SUPPORTED :" + e.ToString()); } }
public bool IsWeakAgainst(ELEMENT atk, ELEMENT def) { return(this.IsStrongAgainst(def, atk)); }