public void initalize(string id) { this.ID = id; ObjectGameData skillData = ReadDatabase.Instance.ObjectInfo[ID.ToUpper()]; foreach (string key in skillData.States.Keys) { EObjectState state = (EObjectState)Extensions.GetEnum(EObjectState.RUN.GetType(), key.ToUpper()); listState.Add(state, getClassObject(state)); } //first element var enumerator = listState.Keys.GetEnumerator(); enumerator.MoveNext(); FSM.Configure(this, listState[enumerator.Current]); stateAction = enumerator.Current; runResources(); }
void readObject() { ObjectInfo = new Dictionary <string, ObjectGameData>(); TextAsset textAsset = (TextAsset)Resources.Load(GameConfig.DatabasePathObject); string[] temp = textAsset.text.Split('\n'); int lenght = temp.Length; for (int i = 1; i <= lenght - 1; i++) { if (temp[i].Equals("")) { break; } ObjectGameData data = new ObjectGameData(); string[] s = temp[i].Split(';'); #region STATE string[] tempState = s[2].Split('-'); string[] tempEvent = null; s[4] = s[4].Trim(); for (int k1 = 0; k1 < tempState.Length; k1++) { AnimationEventState animationState = new AnimationEventState(); if (!s[4].Equals("none")) { tempEvent = s[4].Split(','); for (int k2 = 0; k2 < tempEvent.Length; k2++) { if (tempEvent[k2] != "") { string[] ss = tempEvent[k2].Split('-'); if (tempState[k1].Equals(ss[0])) { for (int k3 = 1; k3 < ss.Length; k3++) { animationState.listKeyEventFrame.Add(ss[k3]); } break; } } } } data.States.Add(tempState[k1].ToUpper(), animationState); } #endregion #region TIME FRAME s[3] = s[3].Trim(); if (!s[3].Equals("none")) { string[] tempTimeFrame = s[3].Split(','); for (int t = 0; t < tempTimeFrame.Length; t++) { tempTimeFrame[t] = tempTimeFrame[t].Trim(); int index = tempTimeFrame[t].IndexOf('('); if (index != -1) { string state = tempTimeFrame[t].Substring(0, index); foreach (KeyValuePair <string, AnimationEventState> iterator in data.States) { if (state.ToUpper().Equals(iterator.Key)) { string value = tempTimeFrame[t].Substring(index, tempTimeFrame[t].Length - index); value = value.Substring(1, value.Length - 2); // substring '(' & ')' iterator.Value.TimeFrame = float.Parse(value); } } } } } #endregion #region SPECIFIC LOOP s[5] = s[5].Trim(); string[] tempPath = s[5].Split(','); for (int t = 0; t < tempPath.Length; t++) { tempPath[t] = tempPath[t].Trim(); int index = tempPath[t].IndexOf('('); if (index != -1) { string state = tempPath[t].Substring(0, index); foreach (KeyValuePair <string, AnimationEventState> iterator in data.States) { if (state.ToUpper().Equals(iterator.Key)) { tempPath[t] = tempPath[t].Substring(index, tempPath[t].Length - index); tempPath[t] = tempPath[t].Substring(1, tempPath[t].Length - 2).Trim(); // substring '(' & ')' int iSpecial = tempPath[t].IndexOf('('); if (iSpecial != -1) { iterator.Value.isSpecificLoop = true; string strSpecial = tempPath[t].Substring(iSpecial, tempPath[t].Length - iSpecial); strSpecial = strSpecial.Substring(1, strSpecial.Length - 2); // substring '(' & ')' string[] arr = strSpecial.Split('-'); iterator.Value.SpecificLoopIndex = new int[arr.Length]; for (int m = 0; m < arr.Length; m++) { iterator.Value.SpecificLoopIndex[m] = int.Parse(arr[m]); } tempPath[t] = tempPath[t].Substring(0, iSpecial).Trim(); } iterator.Value.ResourcePath = tempPath[t]; } } } } #endregion ObjectInfo.Add(s[1].ToUpper(), data); } }
void readObject() { ObjectInfo = new Dictionary<string, ObjectGameData>(); TextAsset textAsset = (TextAsset)Resources.Load(GameConfig.DatabasePathObject); string[] temp = textAsset.text.Split('\n'); int lenght = temp.Length; for (int i = 1; i <= lenght - 1; i++) { if (temp[i].Equals("")) break; ObjectGameData data = new ObjectGameData(); string[] s = temp[i].Split(';'); #region STATE string[] tempState = s[2].Split('-'); string[] tempEvent = null; s[4] = s[4].Trim(); for (int k1 = 0; k1 < tempState.Length; k1++) { AnimationEventState animationState = new AnimationEventState(); if (!s[4].Equals("none")) { tempEvent = s[4].Split(','); for (int k2 = 0; k2 < tempEvent.Length; k2++) { if (tempEvent[k2] != "") { string[] ss = tempEvent[k2].Split('-'); if (tempState[k1].Equals(ss[0])) { for (int k3 = 1; k3 < ss.Length; k3++) animationState.listKeyEventFrame.Add(ss[k3]); break; } } } } data.States.Add(tempState[k1].ToUpper(), animationState); } #endregion #region TIME FRAME s[3] = s[3].Trim(); if (!s[3].Equals("none")) { string[] tempTimeFrame = s[3].Split(','); for (int t = 0; t < tempTimeFrame.Length; t++) { tempTimeFrame[t] = tempTimeFrame[t].Trim(); int index = tempTimeFrame[t].IndexOf('('); if (index != -1) { string state = tempTimeFrame[t].Substring(0, index); foreach (KeyValuePair<string, AnimationEventState> iterator in data.States) { if (state.ToUpper().Equals(iterator.Key)) { string value = tempTimeFrame[t].Substring(index, tempTimeFrame[t].Length - index); value = value.Substring(1, value.Length - 2); // substring '(' & ')' iterator.Value.TimeFrame = float.Parse(value); } } } } } #endregion #region SPECIFIC LOOP s[5] = s[5].Trim(); string[] tempPath = s[5].Split(','); for (int t = 0; t < tempPath.Length; t++) { tempPath[t] = tempPath[t].Trim(); int index = tempPath[t].IndexOf('('); if (index != -1) { string state = tempPath[t].Substring(0, index); foreach (KeyValuePair<string, AnimationEventState> iterator in data.States) { if (state.ToUpper().Equals(iterator.Key)) { tempPath[t] = tempPath[t].Substring(index, tempPath[t].Length - index); tempPath[t] = tempPath[t].Substring(1, tempPath[t].Length - 2).Trim(); // substring '(' & ')' int iSpecial = tempPath[t].IndexOf('('); if (iSpecial != -1) { iterator.Value.isSpecificLoop = true; string strSpecial = tempPath[t].Substring(iSpecial, tempPath[t].Length - iSpecial); strSpecial = strSpecial.Substring(1, strSpecial.Length - 2); // substring '(' & ')' string[] arr = strSpecial.Split('-'); iterator.Value.SpecificLoopIndex = new int[arr.Length]; for (int m = 0; m < arr.Length; m++) { iterator.Value.SpecificLoopIndex[m] = int.Parse(arr[m]); } tempPath[t] = tempPath[t].Substring(0, iSpecial).Trim(); } iterator.Value.ResourcePath = tempPath[t]; } } } } #endregion ObjectInfo.Add(s[1].ToUpper(), data); } }