public void MixPoints(ref Level level, int steps) { for (int i = 0; i < steps; i++) { ArrayPoint point1 = level.points [Random.Range(0, level.points.Count)]; ArrayPoint point2 = new ArrayPoint(); bool point2NotFount = true; if (level.points.Count > 1) { while (point2NotFount) { point2 = level.points [Random.Range(0, level.points.Count)]; if (point1.ID != point2.ID) { point2NotFount = false; } } } else { point2 = point1; } SerializableVector2 point1Coords = point1.coord; point1.coord = point2.coord; point2.coord = point1Coords; } foreach (ArrayLine line in level.lines) { line.point1 = level.points.Find(p => p.ID == line.point1ID).coord; line.point2 = level.points.Find(p => p.ID == line.point2ID).coord; } }
public WorldSettings(string worldName, int worldBiome, int worldDifficulty, Vector2Int worldSize) { name = worldName; size = (Vector2)worldSize; difficulty = worldDifficulty; biome = worldBiome; }
public override object Deserialize(string stringToDeserialize) { SerializableVector2 serializableVector = (SerializableVector2)base.BaseSerializer.Deserialize(stringToDeserialize, typeof(SerializableVector2)); Vector2 vector = new Vector2(serializableVector.x, serializableVector.y); return(vector); }
internal SerializableCurve(Vector2 leftValue, Vector2 leftTangent, Vector2 rightTangent, Vector2 rightValue) { this.leftValue = new SerializableVector2(leftValue); this.leftTangent = new SerializableVector2(leftTangent); this.rightTangent = new SerializableVector2(rightTangent); this.rightValue = new SerializableVector2(rightValue); }
public override string Serialize(object objectToSerialize) { Vector2 vector = (Vector2)objectToSerialize; SerializableVector2 objectToSerialize2 = new SerializableVector2(vector.x, vector.y); return(base.BaseSerializer.Serialize(objectToSerialize2)); }
void Start() { string typeStr = ""; switch (theType) { case ADD_ON_TYPE.FOOD: GameObject.Find("TownHall").GetComponent <CityManager>().AddFoodProduction(i_IncreaseAmount); typeStr = "_Food"; Debug.Log("Addon Food"); break; case ADD_ON_TYPE.POWER: GameObject.Find("TownHall").GetComponent <CityManager>().AddPowerProduction(i_IncreaseAmount); typeStr = "_Power"; Debug.Log("Addon Power"); break; } SerializableVector2 FindVec2 = new SerializableVector2(this.GetComponentInParent <Residential>().GridPos); for (int i = 0; i < PersistentData.m_Instance.BuildingGridPos.Count; ++i) { if (FindVec2.Equals(PersistentData.m_Instance.BuildingGridPos[i])) { if (!PersistentData.m_Instance.BuildingName[i].Contains("_")) { PersistentData.m_Instance.BuildingName[i] += typeStr; } } } }
public WorldSettings(string worldName, int worldBiome, int worldDifficulty, int worldSize) { name = worldName; size = new Vector2(worldSize, worldSize); difficulty = worldDifficulty; //Sandy Biome biome = worldBiome; }
public static void ScrollView(Rect area, string title, ref SerializableVector2 scrollpos, Action code, int padding = 20, params GUILayoutOption[] options) { Drawing.DrawRect(area, MenuComponent._OutlineBorderBlack); Drawing.DrawRect(MenuUtilities.Inline(area), MenuComponent._OutlineBorderLightGray); Rect inlined = MenuUtilities.Inline(area, 2); Drawing.DrawRect(inlined, MenuComponent._FillLightBlack); Color lastColor = _MenuTabStyle.normal.textColor; int lastFontSize = _MenuTabStyle.fontSize; _MenuTabStyle.normal.textColor = _MenuTabStyle.onNormal.textColor; _MenuTabStyle.fontSize = 15; Drawing.DrawRect(new Rect(inlined.x, inlined.y, inlined.width, _MenuTabStyle.CalcSize(new GUIContent(title)).y + 2), MenuComponent._OutlineBorderLightGray); GUILayout.BeginArea(inlined); { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label(title, _MenuTabStyle); _MenuTabStyle.normal.textColor = lastColor; _MenuTabStyle.fontSize = lastFontSize; GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Space(2); Rect rects; Rect inner; GUILayout.BeginHorizontal(); { scrollpos = GUILayout.BeginScrollView(scrollpos.ToVector2(), false, true); { GUILayout.BeginHorizontal(); { GUILayout.Space(padding); GUILayout.BeginVertical(GUILayout.MinHeight(inlined.height)); { try { code(); } catch (Exception e) { DebugUtilities.Log($"SCROLLVIEW EXCEPTION: {e}"); } } GUILayout.EndVertical(); inner = GUILayoutUtility.GetLastRect(); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); rects = GUILayoutUtility.GetLastRect(); GUILayout.Space(1); } GUILayout.EndHorizontal(); GUILayout.Space(1); Drawing.DrawRect(new Rect(rects.x + rects.width - 16, rects.y, 16, rects.height), MenuComponent._FillLightBlack); if (inner.height - rects.height > 0) { VerticalSlider(new Rect(rects.x + 4, rects.y + 8, 12, rects.height - 14), 0, inner.height - rects.height, ref scrollpos.y); } } GUILayout.EndArea(); }
public static SerializableVector2[] FromVector2Array(Vector2[] rValue) { SerializableVector2[] temp = new SerializableVector2[rValue.Length]; for (int index = 0; index < rValue.Length; ++index) { temp[index] = rValue[index]; } return(temp); }
public override string Serialize(object objectToSerialize) { Vector2 vector = (Vector2)objectToSerialize; SerializableVector2 serializableVector = new SerializableVector2(); serializableVector.x = vector.x; serializableVector.y = vector.y; return(base.BaseSerializer.Serialize(serializableVector)); }
public void Process(SerializableVector2 input) { OnMovementDataProcessed.Invoke(new MovementData { Input = new Vector3(input.x, input.y), CameraTransform = cameraTransform, CharacterTransform = characterTransform }); }
public bool ongoing = false; //defaults to false upon parsed, will be set to true if indicated by questStatus public Quest(int INDEX, string TYPE, string DESCRIPTION, string MSG, string SPECIFICS, string LONG_MSG, Color MSG_COLOR, Vector2 LOCATION) //need not be serializable in params b/c of implicit operator casting { index = INDEX; type = TYPE; description = DESCRIPTION; message = MSG; specifics = SPECIFICS; long_message = LONG_MSG; message_color = MSG_COLOR; location = LOCATION; }
// Token: 0x06000238 RID: 568 RVA: 0x00015B20 File Offset: 0x00013D20 public static void ScrollView(Rect area, string title, ref SerializableVector2 scrollpos, Action code, int padding = 20, params GUILayoutOption[] options) { Drawing.DrawRect(area, MenuComponent._OutlineBorderBlack, null); Drawing.DrawRect(MenuUtilities.Inline(area, 1), MenuComponent._OutlineBorderLightGray, null); Rect rect = MenuUtilities.Inline(area, 2); Drawing.DrawRect(rect, MenuComponent._FillLightBlack, null); Color textColor = Prefab._MenuTabStyle.normal.textColor; int fontSize = Prefab._MenuTabStyle.fontSize; Prefab._MenuTabStyle.normal.textColor = Prefab._MenuTabStyle.onNormal.textColor; Prefab._MenuTabStyle.fontSize = 15; Drawing.DrawRect(new Rect(rect.x, rect.y, rect.width, Prefab._MenuTabStyle.CalcSize(new GUIContent(title)).y + 2f), MenuComponent._OutlineBorderLightGray, null); GUILayout.BeginArea(rect); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label(title, Prefab._MenuTabStyle, Array.Empty <GUILayoutOption>()); Prefab._MenuTabStyle.normal.textColor = textColor; Prefab._MenuTabStyle.fontSize = fontSize; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(2f); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); scrollpos = GUILayout.BeginScrollView(scrollpos.ToVector2(), false, true, Array.Empty <GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Space((float)padding); GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.MinHeight(rect.height) }); try { code(); } catch (Exception ex) { } GUILayout.EndVertical(); Rect lastRect = GUILayoutUtility.GetLastRect(); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); Rect lastRect2 = GUILayoutUtility.GetLastRect(); GUILayout.Space(1f); GUILayout.EndHorizontal(); GUILayout.Space(1f); Drawing.DrawRect(new Rect(lastRect2.x + lastRect2.width - 16f, lastRect2.y, 16f, lastRect2.height), MenuComponent._FillLightBlack, null); bool flag = lastRect.height - lastRect2.height > 0f; bool flag2 = flag; if (flag2) { Prefab.VerticalSlider(new Rect(lastRect2.x + 4f, lastRect2.y + 8f, 12f, lastRect2.height - 14f), 0f, lastRect.height - lastRect2.height, ref scrollpos.y); } GUILayout.EndArea(); }
public void SetPoint(Vector2 point) { points.Add(point); SerializableVector2 serVec2Point = new SerializableVector2(point); saveLine.points.Add(serVec2Point); lineRenderer.positionCount = points.Count; lineRenderer.SetPosition(points.Count - 1, point); }
public override void Convert(string _value) { System.Globalization.CultureInfo _ci = (System.Globalization.CultureInfo)System.Globalization.CultureInfo.CurrentCulture.Clone(); _ci.NumberFormat.CurrencyDecimalSeparator = "."; string[] _chars = _value.Split(char.Parse(",")); Value = new SerializableVector2(float.Parse(_chars[0], System.Globalization.NumberStyles.Any, _ci), float.Parse(_chars[1], System.Globalization.NumberStyles.Any, _ci)); InitValue = Value; }
public void FromVector2() { // Arrange var vector = new Vector2(1, 2); // Act var actual = SerializableVector2.FromVector2(vector); // Assert Assert.That(actual.X, Is.EqualTo(1)); Assert.That(actual.Y, Is.EqualTo(2)); }
public TilemapWrapper(SerializableVector3Int[] tilePositions, string[] textureNames, float[] mXMins, float[] mYMins, float[] mWidths, float[] mHeights, SerializableVector2 pivot, float pixelPerUnit, int layerNumber) { this.tilePositions = tilePositions; this.textureNames = textureNames; m_XMins = mXMins; m_YMins = mYMins; m_Widths = mWidths; m_Heights = mHeights; this.pivot = pivot; this.pixelPerUnit = pixelPerUnit; this.layerNumber = layerNumber; }
public void Move(SerializableVector2 input) { if (movementProcessor == null) { return; } movementProcessor.Process(new MovementData { Input = new Vector3(input.x, input.y), CameraTransform = cameraTransform, CharacterTransform = characterTransform }); }
public SavedData(List<Vector2[]> gestures, int highScore) { storedGestures = new List<SerializableVector2[]>(); HighScore = highScore; foreach (Vector2[] item in gestures) { SerializableVector2[] tempArray = new SerializableVector2[64]; for (int index = 0; index < item.Length; index++) { tempArray[index] = new SerializableVector2(item[index]); } storedGestures.Add(tempArray); } }
public bool IsEqualVector(SerializableVector2 vector) { bool value = true; if (vector.x != x) { value = false; } if (vector.y != y) { value = false; } return(value); }
public Vector2 GetPointCoords(int width, int height, SerializableVector2 arrayCoords) { Vector2 pointCoord = new Vector2(0, 0); float widthPoint = gameArea.rect.width / (float)width; float heightPoint = gameArea.rect.height / (float)height; pointCoord.x = (widthPoint * arrayCoords.x) + (widthPoint / 2); pointCoord.y = (heightPoint * arrayCoords.y) + (heightPoint / 2); pointCoord.x = pointCoord.x - (gameArea.rect.width / 2); pointCoord.y = pointCoord.y - (gameArea.rect.height / 2); return(pointCoord); }
public object LoadAsset(AssetInfo assetInfo, IAssetStore assetStore) { var fileStream = _fileSystem.GetFile(assetInfo.AssetFilePath).OpenRead(); var assetData = AssetData.Load(fileStream); var spriteAssetContent = assetData.ReadJsonContent <SpriteAssetContent>(); var textureAssetId = new AssetId(spriteAssetContent.TextureAssetId); return(new Sprite( sourceTexture: assetStore.GetAsset <ITexture>(textureAssetId), sourceUV: SerializableVector2.ToVector2(spriteAssetContent.SourceUV), sourceDimensions: SerializableVector2.ToVector2(spriteAssetContent.SourceDimensions), pivot: SerializableVector2.ToVector2(spriteAssetContent.Pivot), pixelsPerUnit: spriteAssetContent.PixelsPerUnit)); }
internal SerializableCurve(SerializableCurve serializableCurve) { if (serializableCurve == null) { leftValue = new SerializableVector2(new Vector2(0, 0)); leftTangent = new SerializableVector2(new Vector2(0.25f, 0.25f)); rightValue = new SerializableVector2(new Vector2(1f, 1f)); rightTangent = new SerializableVector2(new Vector2(0.75f, 0.75f)); return; } leftValue = serializableCurve.leftValue; leftTangent = new SerializableVector2(serializableCurve.leftTangent.vector2); rightTangent = new SerializableVector2(serializableCurve.rightTangent.vector2); rightValue = serializableCurve.rightValue; }
public void ToVector2() { // Arrange var serializable = new SerializableVector2 { X = 1, Y = 2 }; // Act var actual = SerializableVector2.ToVector2(serializable); // Assert Assert.That(actual.X, Is.EqualTo(1)); Assert.That(actual.Y, Is.EqualTo(2)); }
public CameraShakeSave(CameraShake cameraShake) : base(cameraShake) { this.isUsingCurve = cameraShake.isUsingCurve; this.isShaking = cameraShake.isShaking; this.appliedOffset = cameraShake.appliedOffset; this.duration = cameraShake.duration; this.startIntensity = cameraShake.startIntensity; this.endIntensity = cameraShake.endIntensity; if (cameraShake.curve != null) { this.curve = cameraShake.curve; } this.intensityMultiplier = cameraShake.intensityMultiplier; this.intensity = cameraShake.intensity; this.timeShaking = cameraShake.timeShaking; this.totalOffsetApplied = cameraShake.totalOffsetApplied; }
public override void DrawEditor() { var _v2 = Value; var _x = _v2.x; var _y = _v2.y; using (new GUILayout.HorizontalScope()) { //GUILayout.Space(130); GUILayout.Label("x:"); _x = GUIFloatField.FloatField(_x); GUILayout.Label("y:"); _y = GUIFloatField.FloatField(_y); } Value = new SerializableVector2(_x, _y); }
public override void DrawInitValueEditor() { var _xInit = InitValue.x; var _yInit = InitValue.y; using (new GUILayout.HorizontalScope()) { GUI.color = Color.yellow; GUILayout.Label("Init Value:", GUILayout.Width(120)); GUI.color = Color.white; GUILayout.Label("x:"); _xInit = GUIFloatField.FloatField(_xInit); GUILayout.Label("y:"); _yInit = GUIFloatField.FloatField(_yInit); } InitValue = new SerializableVector2(_xInit, _yInit); }
public void LoadMeshData() { string meshPath = Application.streamingAssetsPath + "/Saved/" + saveName; if (File.Exists(meshPath)) { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = File.Open(Application.streamingAssetsPath + "/Saved/" + saveName, FileMode.Open); MeshData meshData = bf.Deserialize(fs) as MeshData; this.vertices = SerializableVector3.ToVector3Array(meshData.vertices); this.uvs = SerializableVector2.ToVector2Array(meshData.uvs); this.indices = meshData.indices; this.gameObject.transform.localScale = meshData.scale; this.gameObject.transform.position = meshData.position; fs.Close(); } else { this.InitializeVertices(); } }
public void SaveMeshData() { Mesh refMesh = meshFilter.mesh; MeshData data = new MeshData(); data.vertices = SerializableVector3.FromVector3Array(refMesh.vertices); data.uvs = SerializableVector2.FromVector2Array(refMesh.uv); data.indices = refMesh.triangles; data.scale = this.gameObject.transform.localScale; data.position = this.gameObject.transform.position; BinaryFormatter bf = new BinaryFormatter(); string dirPath = Application.streamingAssetsPath + "/Saved/EPData"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } FileStream fs = new FileStream(dirPath + "/" + saveName, FileMode.Create); bf.Serialize(fs, data); fs.Close(); }
public void DeserializeGameObject(SerializableGameObject serializableObject, Transform parent) { GameObject myObject = Instantiate(new GameObject(), Vector3.zero, Quaternion.identity, parent); myObject.name = serializableObject.name; foreach (SerializableComponent sComp in serializableObject.serializableComponents) { Type compType = sComp.componentType as Type; myObject.AddComponent(compType); for (int i = 0; i < sComp.propertiesNames.Count; i++) { try { string pName = sComp.propertiesNames[i]; object loadPropertyValue = sComp.values[i]; var pValue = loadPropertyValue; if (loadPropertyValue.GetType() == typeof(SerializableVector2)) { SerializableVector2 vector = (SerializableVector2)loadPropertyValue; pValue = new Vector2(vector.x, vector.y); } else if (loadPropertyValue.GetType() == typeof(SerializableVector3)) { SerializableVector3 vector = (SerializableVector3)loadPropertyValue; pValue = new Vector3(vector.x, vector.y, vector.z); } else if (loadPropertyValue.GetType() == typeof(SerializableQuaternion)) { SerializableQuaternion quat = (SerializableQuaternion)loadPropertyValue; pValue = new Quaternion(quat.x, quat.y, quat.z, quat.w); } else if (loadPropertyValue.GetType() == typeof(SerializableSprite)) { SerializableSprite sSprite = (SerializableSprite)loadPropertyValue; foreach (Sprite sprite in allSprites) { myObject.GetComponent <SpriteRenderer>().sortingOrder = 31; if (sprite.name.Equals(sSprite.spriteName)) { myObject.GetComponent <SpriteRenderer>().sprite = sprite; continue; } } } else if (loadPropertyValue.GetType() == typeof(SerializableColor)) { SerializableColor sColor = (SerializableColor)loadPropertyValue; pValue = new Color(sColor.r, sColor.g, sColor.b, sColor.a); } else if (loadPropertyValue.GetType() == typeof(SerializableVector4)) { SerializableVector4 sVector = (SerializableVector4)loadPropertyValue; pValue = new Vector4(sVector.x, sVector.y, sVector.z, sVector.w); } else if (loadPropertyValue.GetType() == typeof(SerializableBounds)) { SerializableBounds sBounds = (SerializableBounds)loadPropertyValue; pValue = new Bounds(new Vector3(sBounds.center[0], sBounds.center[1], sBounds.center[2]) , new Vector3(sBounds.size[0], sBounds.size[1], sBounds.size[2])); } else if (loadPropertyValue.GetType() == typeof(Serializable4x4Matrix)) { Serializable4x4Matrix sMatrix = (Serializable4x4Matrix)loadPropertyValue; Matrix4x4 matrix = new Matrix4x4(); //setting up the matrix values matrix[0, 0] = sMatrix.data[0, 0]; matrix[0, 1] = sMatrix.data[0, 1]; matrix[0, 2] = sMatrix.data[0, 2]; matrix[0, 3] = sMatrix.data[0, 3]; matrix[1, 0] = sMatrix.data[1, 0]; matrix[1, 1] = sMatrix.data[1, 1]; matrix[1, 2] = sMatrix.data[1, 2]; matrix[1, 3] = sMatrix.data[1, 3]; matrix[2, 0] = sMatrix.data[2, 0]; matrix[2, 1] = sMatrix.data[2, 1]; matrix[2, 2] = sMatrix.data[2, 2]; matrix[2, 3] = sMatrix.data[2, 3]; matrix[3, 0] = sMatrix.data[3, 0]; matrix[3, 1] = sMatrix.data[3, 1]; matrix[3, 2] = sMatrix.data[3, 2]; matrix[3, 3] = sMatrix.data[3, 3]; pValue = matrix; } else if (loadPropertyValue.GetType() == typeof(SerializableVector2[])) { SerializableVector2[] data = (SerializableVector2[])loadPropertyValue; Vector2[] vectors = new Vector2[data.Length]; for (int x = 0; x < data.Length; x++) { SerializableVector2 sVector = data[x]; vectors[x] = new Vector2(sVector.x, sVector.y); } pValue = vectors; } else if (loadPropertyValue.GetType() == typeof(SerializableVector3[])) { SerializableVector3[] data = (SerializableVector3[])loadPropertyValue; Vector3[] vectors = new Vector3[data.Length]; for (int x = 0; x < data.Length; x++) { SerializableVector3 sVector = data[x]; vectors[x] = new Vector3(sVector.x, sVector.y); } pValue = vectors; } else if (loadPropertyValue.GetType() == typeof(SerializableAnimatorController)) { SerializableAnimatorController sControlller = (SerializableAnimatorController)loadPropertyValue; foreach (RuntimeAnimatorController controller in allControllers) { if (controller.name.Equals(sControlller.animatorControllerName)) { myObject.GetComponent <Animator>().runtimeAnimatorController = controller; continue; } } } PropertyInfo pInfo = compType.GetProperty(pName); pInfo.SetValue(myObject.GetComponent(compType), pValue); } catch (Exception e) { Debug.LogWarning(e); } } } Vector3 position = new Vector3(); position.x = serializableObject.transformData[0][0]; position.y = serializableObject.transformData[0][1]; position.z = serializableObject.transformData[0][2]; Vector3 rotation = new Vector3(); rotation.x = serializableObject.transformData[1][0]; rotation.y = serializableObject.transformData[1][1]; rotation.z = serializableObject.transformData[1][2]; Vector3 scale = new Vector3(); scale.x = serializableObject.transformData[2][0]; scale.y = serializableObject.transformData[2][1]; scale.z = serializableObject.transformData[2][2]; myObject.transform.position = position; myObject.transform.eulerAngles = rotation; myObject.transform.localScale = scale; foreach (SerializableGameObject child in serializableObject.childs) { DeserializeGameObject(child, myObject.transform); } }
//Object //public HideFlags hideFlags; //public string name; public SerializableMesh(Mesh mesh) { bindposes = mesh.bindposes; boneWeights = mesh.boneWeights; bounds = new SerializableBounds(mesh.bounds); colors = mesh.colors; colors32 = mesh.colors32; SerializableVector3[] a = new SerializableVector3[mesh.vertices.Length]; for (int b = 0; b < a.Length; b++) { a [b] = new SerializableVector3(mesh.vertices [b]); } vertices = a; a = new SerializableVector3[mesh.normals.Length]; for (int b = 0; b < a.Length; b++) { a [b] = new SerializableVector3(mesh.normals [b]); } normals = a; subMeshCount = mesh.subMeshCount; SerializableVector4[] c = new SerializableVector4[mesh.tangents.Length]; for (int b = 0; b < c.Length; b++) { c [b] = new SerializableVector4(mesh.tangents [b]); } tangents = c; triangles = mesh.triangles; SerializableVector2[] d = new SerializableVector2[mesh.uv.Length]; for (int b = 0; b < d.Length; b++) { d [b] = new SerializableVector2(mesh.uv [b]); } uv = d; d = new SerializableVector2[mesh.uv2.Length]; for (int b = 0; b < d.Length; b++) { d [b] = new SerializableVector2(mesh.uv2 [b]); } uv2 = d; d = new SerializableVector2[mesh.uv3.Length]; for (int b = 0; b < d.Length; b++) { d [b] = new SerializableVector2(mesh.uv3 [b]); } uv3 = d; d = new SerializableVector2[mesh.uv4.Length]; for (int b = 0; b < d.Length; b++) { d [b] = new SerializableVector2(mesh.uv4 [b]); } uv4 = d; //hideFlags = mesh.hideFlags; //name = mesh.name; }