public override void OnEnter() { for (int i = 0; i < keys.Length; i++) { if (!keys[i].IsNone || !keys[i].Value.Equals("")) { string key = keys[i].Value; FsmVar fsmVar = values[i]; string _name = fsmVar.variableName; switch (fsmVar.Type) { case VariableType.Int: this.Fsm.Variables.GetFsmInt(_name).Value = PlayerPrefs.GetInt(key); break; case VariableType.Float: this.Fsm.Variables.GetFsmFloat(_name).Value = PlayerPrefs.GetFloat(key); break; case VariableType.Bool: this.Fsm.Variables.GetFsmBool(_name).Value = PlayerPrefsX.GetBool(key); break; case VariableType.Color: this.Fsm.Variables.GetFsmColor(_name).Value = PlayerPrefsX.GetColor(key); break; case VariableType.Quaternion: this.Fsm.Variables.GetFsmQuaternion(_name).Value = PlayerPrefsX.GetQuaternion(key); break; case VariableType.Rect: this.Fsm.Variables.GetFsmRect(_name).Value = PlayerPrefsX.GetRect(key); break; case VariableType.Vector2: this.Fsm.Variables.GetFsmVector2(_name).Value = PlayerPrefsX.GetVector2(key); break; case VariableType.Vector3: this.Fsm.Variables.GetFsmVector3(_name).Value = PlayerPrefsX.GetVector3(key); break; case VariableType.String: this.Fsm.Variables.GetFsmString(_name).Value = PlayerPrefs.GetString(key); break; default: LogError("PlayerPrefsx does not support saving " + fsmVar.Type); break; } } } Finish(); }
private static Vector2 GetEventCoordination(int flag, Transform eventType) { Vector2 eventCoordination; eventCoordination.x = Random.Range(0, (int)mapSize.x); eventCoordination.y = Random.Range(0, (int)mapSize.y); if (PlayerPrefsX.GetBool(PrefsEntity.SaveFlag)) { return(PlayerPrefsX.GetVector2(eventType.name + flag.ToString(), eventCoordination)); } return(eventCoordination); }
private Vector2 GetExitCoordination() { Vector2 exit; exit.x = Random.Range(0, (int)mapSize.x); exit.y = Random.Range(0, (int)mapSize.y); if (PlayerPrefsX.GetBool(PrefsEntity.SaveFlag)) { return(PlayerPrefsX.GetVector2(PrefsEntity.Exit, exit)); } return(exit); }
private Vector2 GetEntranceCoordination() { Vector2 entrance; entrance.x = Random.Range(0, (int)mapSize.x); entrance.y = Random.Range(0, (int)mapSize.y); if (currentFloor != 100) { entrance.x = PlayerPrefs.GetInt(PrefsEntity.CurrentX); entrance.y = PlayerPrefs.GetInt(PrefsEntity.CurrentY); } if (PlayerPrefsX.GetBool(PrefsEntity.SaveFlag)) { return(PlayerPrefsX.GetVector2(PrefsEntity.Entrance, entrance)); } return(entrance); }
private Vector2 GetBridgeCoordinate(int flag, GameObject[] fieldTileArr) { Vector2 tile; tile.x = (int)Random.Range(0, fieldTileArr.Length - 1); tile.y = -1; int tileFlag = 0; while ((int)tile.y <0 | (int)tile.y> fieldTileArr.Length - 1 | (tile.x % (int)mapSize.y == 0 & tileFlag == 0) | (tile.x % (int)mapSize.y == (int)mapSize.y - 1 & tileFlag == 1)) { tileFlag = Random.Range(0, 3); // 0 = up : -1 // 1 = down : +1 // 2 = left : -y // 3 = right : +y switch (tileFlag) { case 0: tile.y = (int)tile.x - 1; continue; case 1: tile.y = (int)tile.x + 1; continue; case 2: tile.y = (int)tile.x - (int)mapSize.y; continue; case 3: tile.y = (int)tile.x + (int)mapSize.y; continue; } } if (PlayerPrefsX.GetBool(PrefsEntity.SaveFlag)) { return(PlayerPrefsX.GetVector2(PrefsEntity.Bridge + flag.ToString(), tile)); } return(tile); }