private void DoGetRandomValue() { if (storeValue.IsNone) { return; } if (Repeat.Value) { randomIndex = Random.Range(0, array.Length); index.Value = randomIndex; storeValue.SetValue(array.Get(index.Value)); } else { do { randomIndex = Random.Range(0, array.Length); } while (randomIndex == lastIndex); lastIndex = randomIndex; } if (randomIndex != -1) { index.Value = randomIndex; storeValue.SetValue(array.Get(index.Value)); } }
private void DoGetNextItem() { if (nextItemIndex >= array.Length) { nextItemIndex = 0; currentIndex.Value = array.Length - 1; base.Fsm.Event(finishedEvent); return; } result.SetValue(array.Get(nextItemIndex)); if (nextItemIndex >= array.Length) { nextItemIndex = 0; currentIndex.Value = array.Length - 1; base.Fsm.Event(finishedEvent); return; } if (endIndex.Value > 0 && nextItemIndex >= endIndex.Value) { nextItemIndex = 0; currentIndex.Value = endIndex.Value; base.Fsm.Event(finishedEvent); return; } nextItemIndex++; currentIndex.Value = nextItemIndex - 1; if (loopEvent != null) { base.Fsm.Event(loopEvent); } }
private void DoGetFsmArray() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(gameObject); if (!UpdateCache(ownerDefaultTarget, fsmName.Value)) { return; } FsmArray fsmArray = fsm.FsmVariables.GetFsmArray(variableName.Value); if (fsmArray != null) { if (index.Value < 0 || index.Value >= fsmArray.Length) { base.Fsm.Event(indexOutOfRange); Finish(); } else if (fsmArray.ElementType == storeValue.NamedVar.VariableType) { storeValue.SetValue(fsmArray.Get(index.Value)); } else { LogWarning("Incompatible variable type: " + variableName.Value); } } else { DoVariableNotFound(variableName.Value); } }
void DoGetPreviousItem() { // no more children? // check first to avoid errors. if (index < 0) { Fsm.Event(finishedEvent); return; } if (!endIndex.IsNone && index < endIndex.Value) { Fsm.Event(finishedEvent); return; } // get item result.SetValue(array.Get(index)); currentIndex.Value = index; // iterate the previous child index--; if (loopEvent != null) { Fsm.Event(loopEvent); } }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go != null) { // cache the AudioSource component audio = go.GetComponent <AudioSource>(); if (audio != null) { index = Random.Range(0, audioArray.Length); while (index == lastIndex.Value) { index = Random.Range(0, audioArray.Length); } lastIndex.Value = index; AudioClip audioClip = (AudioClip)audioArray.Get(index); audio.clip = audioClip; audio.volume = volume.Value; audio.pitch = Random.Range(randomPitchLow.Value, randomPitchHigh.Value); audio.Play(); } } else { // Finish if failed to play sound Finish(); } }
private void DoGetRandomValue() { if (storeValue.IsNone) { return; } int currItem = GetRandomWeightedIndex(_weights); if (!repeat.Value) { int _repeat = 0; while (currItem == prevItem) { currItem = Mathf.Max(0, GetRandomWeightedIndex(_weights)); _repeat++; if (_repeat > 20) { prevItem = -1; } } } storeIndex.Value = currItem; storeValue.SetValue(array.Get(currItem)); prevItem = currItem; }
private void DoGetRandomValue() { if (!storeValue.IsNone) { storeValue.SetValue(array.Get(Random.Range(0, array.Length))); } }
public override void OnEnter() { base.OnEnter(); var ui = UIManagerComponent.Instance.OpenInstanceUIWindow <Testimony_Window>(); if (ui != null)//没有UI { List <int> ls_ay = new List <int>(); for (int i = 0; i < m_ay.Length; ++i) { ls_ay.Add((int)m_ay.Get(i)); } ui.HandleMsg(null, ls_ay); /* * if (IsShow.Value) * { * ui.SetActive(IsShow.Value); * } * else * { * UIManagerComponent.Instance.CloseUIWindow(ui); * }*/ } }
private void InitButtons() { //Debug.Log(buttonArray.ElementType); buttons = new UnityEngine.UI.Button[buttonArray.Length]; cachedGameObjects = new GameObject[buttonArray.Length]; actions = new UnityAction[buttonArray.Length]; for (var i = 0; i < buttonArray.Length; i++) { GameObject go = buttonArray.Get(i) as GameObject; if (go != null) { if (cachedGameObjects[i] != go) { buttons[i] = go.GetComponent <UnityEngine.UI.Button>(); cachedGameObjects[i] = go; } } } }
void Sort() { FsmArray scores = FsmVariables.GlobalVariables.GetFsmArray("PlayerScores"); int[] new_scores = new int[9]; GameObject[] new_avatars = new GameObject[9]; string[] new_names = new string[9]; // loops until array is sorted for (int i = 0; i < scores.Length; i++) { int max = -1; int max_index = -1; // loops over old array to find min for (int j = 0; j < scores.Length; j++) { if (int.Parse(scores.Get(j).ToString()) > max) // compares current value to min { max = int.Parse(scores.Get(j).ToString()); // sets min max_index = j; } } new_scores[i] = max; new_names[i] = FsmVariables.GlobalVariables.FindFsmArray("PlayerNames").Get(max_index).ToString(); new_avatars[i] = (GameObject)FsmVariables.GlobalVariables.FindFsmArray("PlayerAvatars").Get(max_index); scores.Set(max_index, -1); } // sets scores to new score array for (int i = 0; i <= 8; i++) { FsmVariables.GlobalVariables.GetFsmArray("PlayerNames").Set(i, new_names[i]); FsmVariables.GlobalVariables.GetFsmArray("PlayerScores").Set(i, new_scores[i]); FsmVariables.GlobalVariables.GetFsmArray("PlayerAvatars").Set(i, new_avatars[i]); } }
private void DoGetValue() { if (!array.IsNone && !storeValue.IsNone) { if (index.Value >= 0 && index.Value < array.Length) { storeValue.SetValue(array.Get(index.Value)); } else { base.Fsm.Event(indexOutOfRange); } } }
public override void OnEnter() { Debug.Log(appIDs.Length); theAppIDList = new AppId_t[appIDs.Length]; for (int i = 0; i < theAppIDList.Length; i++) { theAppIDList[1] = (AppId_t)Convert.ToUInt32(appIDs.Get(i)); } uint theList = SteamAppList.GetInstalledApps(theAppIDList, (uint)MaxAppIDs.VariableType); Debug.Log(theList); Finish(); }
void DoGetNextItem() { // no more children? // check first to avoid errors. if (nextItemIndex >= array.Length) { nextItemIndex = 0; currentIndex.Value = array.Length - 1; Fsm.Event(finishedEvent); return; } // get next item result.SetValue(array.Get(nextItemIndex)); // no more items? // check a second time to avoid process lock and possible infinite loop if the action is called again. // Practically, this enabled calling again this state and it will start again iterating from the first child. if (nextItemIndex >= array.Length) { nextItemIndex = 0; currentIndex.Value = array.Length - 1; Fsm.Event(finishedEvent); return; } if (endIndex.Value > 0 && nextItemIndex >= endIndex.Value) { nextItemIndex = 0; currentIndex.Value = endIndex.Value; Fsm.Event(finishedEvent); return; } // iterate the next child nextItemIndex++; currentIndex.Value = nextItemIndex - 1; if (loopEvent != null) { Fsm.Event(loopEvent); } }
void doCheck() { if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) { return; } if (!ignoreList.IsNone) { var length = ignoreList.Length; sensor.IgnoreList.Clear(); for (var i = 0; i < length; i++) { sensor.IgnoreList.Add(ignoreList.Get(i) as UnityEngine.GameObject); } } }
private void ExecuteAction() { if (array.IsNone) { return; } if (!storeValue.IsNone) { storeValue.SetValue(array.Get(array.Length - 1)); } if (!storeIndex.IsNone) { storeIndex.Value = array.Length - 1; } }
private void DoGetValue() { if (array.IsNone || storeValue.IsNone) { return; } if (index.Value >= 0 && index.Value < array.Length) { storeValue.SetValue(array.Get(index.Value)); } else { //LogError("Index out of Range: " + index.Value); Fsm.Event(indexOutOfRange); } }
private void DoGetRandomValue() { if (storeValue.IsNone) { return; } int currItem = Random.Range(0, array.Length); if (!repeat.Value) { while (currItem == prevItem) { currItem = Random.Range(0, array.Length); } } storeValue.SetValue(array.Get(currItem)); prevItem = currItem; }
void doCheck() { if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) { return; } if (!ignoreList.IsNone) { var length = ignoreList.Length; if (sensor.IgnoreList.Length != length) { sensor.IgnoreList = new UnityEngine.GameObject[length]; } for (var i = 0; i < length; i++) { sensor.IgnoreList[i] = ignoreList.Get(i) as UnityEngine.GameObject; } } }
void OnEnable() { now = System.DateTime.Now; //Debug.Log(now); if (!PlayerPrefs.HasKey("DateTimeRanking")) // First time booting game { if (PlayerPrefs.HasKey("Username")) // Only reset if username has been set { PlayerPrefs.SetString("DateTimeRanking", now.ToBinary().ToString()); // first time player boots up game, the timer begins Reset(); Debug.Log("Resetting because player prefs not established"); } } else { long temp = System.Convert.ToInt64(PlayerPrefs.GetString("DateTimeRanking")); // grabs saved date time from player prefs System.DateTime oldDate = System.DateTime.FromBinary(temp); //Debug.Log("oldDate :" + oldDate); System.TimeSpan difference = now.Subtract(oldDate); // gets difference between saved time and current time double hours = difference.TotalHours; //print("Difference: " + difference); //print("hours: " + hours); if (hours > 168) // over 1 week since reset { PlayerPrefs.SetString("DateTimeRanking", now.ToBinary().ToString()); Reset(); Debug.Log("Reset because time out"); } else { PullFromPrefs(); Debug.Log("Pulling from Prefs"); } } // grabs past data by either reseting or pulling from player prefs /*if (!PlayerPrefs.HasKey("PlayerName0")) * { * Reset(); * } * else * { * PullFromPrefs(); * }*/ int player_index = -1; // copies player name array so the index of the player can be found for (int i = 0; i <= 8; i++) { // if the name is the players username, then the player's score will go here if (FsmVariables.GlobalVariables.GetFsmArray("PlayerNames").Get(i).ToString() == PlayerPrefs.GetString("Username")) { player_index = i; } else { FsmArray score = FsmVariables.GlobalVariables.GetFsmArray("PlayerScores"); int new_score = int.Parse(score.Get(i).ToString()) + Random.Range(0, 2); score.Set(i, new_score); } } FsmVariables.GlobalVariables.FindFsmArray("PlayerScores").Set(player_index, PlayerPrefs.GetInt("Level")); FsmVariables.GlobalVariables.FindFsmArray("PlayerAvatars").Set(player_index, FsmVariables.GlobalVariables.FindFsmArray("AvatarsList").Get(FsmVariables.GlobalVariables.FindFsmInt("CurrentAvatar").Value)); // sort lists Sort(); // save player prefs for names, avatars, and scores based on sorted list. sets correct animation for (int i = 0; i <= 8; i++) { // sets animation based on where player is ranked if (FsmVariables.GlobalVariables.GetFsmArray("PlayerNames").Get(i).ToString() == PlayerPrefs.GetString("Username")) { transform.parent.GetComponent <Animator>().SetInteger("ranking", i + 1); } PlayerPrefs.SetString("PlayerName" + i, FsmVariables.GlobalVariables.GetFsmArray("PlayerNames").Get(i).ToString()); PlayerPrefs.SetInt("PlayerScore" + i, int.Parse(FsmVariables.GlobalVariables.GetFsmArray("PlayerScores").Get(i).ToString())); GameObject avatar = (GameObject)FsmVariables.GlobalVariables.FindFsmArray("PlayerAvatars").Get(i); PlayerPrefs.SetInt("PlayerAvatar" + i, int.Parse(Regex.Match(avatar.name, @"\d+").Value) - 1); } }