public void TapPoints(float points) { GameObject text = textsPool.Enqueue(); if (text) { text.transform.position = new Vector3(Random.Range(-3.0f, 1.0f), Random.Range(1.0f, 4.0f), 0); text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); TextMesh tMesh = text.GetComponent <TextMesh> (); tMesh.color = Color.white; double value = (double)points; string unit = ""; UnitsConverter.Convert(ref value, ref unit); tMesh.text = "+" + value.ToString("f1") + unit; tMesh.characterSize = 0.08f; ClickPoints cp = text.GetComponent <ClickPoints> (); cp.floatUpSpeed = 1f; cp.fadeTime = 0.5f; text.GetComponent <ClickPoints> ().Animate(); } }
public void Update(Camera cam) { camera = cam; // Clear all lists touchPoints.Clear(); PressPoints.Clear(); ClickPoints.Clear(); // Update touch state TouchCollection touchCollection = TouchPanel.GetState(); // Add touches to list foreach (TouchLocation touch in touchCollection) { touchPoints.Add(touch); } if (touchPoints.Count == 0) { // See if any release states were missed foreach (TouchLocation touch in prevTouchPoints) { if (touch.State == TouchLocationState.Pressed) { ClickPoints.Add(touch.Position); } else if (touch.State == TouchLocationState.Moved) { TouchLocation prevTouch; if (touch.TryGetPreviousLocation(out prevTouch)) { var delta = touch.Position - prevTouch.Position; // Allow some errors if (delta.LengthSquared() < 2) { ClickPoints.Add(touch.Position); } } } } swipeDirection = Vector2.Zero; } else if (touchPoints.Count == 1) { TouchLocation touch = touchPoints[0]; if ((touch.State == TouchLocationState.Moved) || (touch.State == TouchLocationState.Pressed)) { TouchLocation prevTouch; // Sometimes TryGetPreviousLocation can fail if (touch.TryGetPreviousLocation(out prevTouch)) { // Get swiping direction swipeDirection = touch.Position - prevTouch.Position; } else { PressPoints.Add(touch.Position); } } else if (touch.State == TouchLocationState.Released) { TouchLocation prevTouch; if (touch.TryGetPreviousLocation(out prevTouch)) { var delta = touch.Position - prevTouch.Position; // Allow some errors if (delta.LengthSquared() < 2) { ClickPoints.Add(touch.Position); } } else { ClickPoints.Add(touch.Position); } } } else if (touchCollection.Count == 2) { // TODO } else { // TODO } // Update previous state prevTouchPoints.Clear(); prevTouchPoints.AddRange(touchPoints); }
void SpawnText(GameObject menuItem, Upgrade upgrade) { GameObject text = instance.textsPool.Enqueue(); if (text) { text.transform.position = menuItem.transform.position; text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); text.transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f)); text.transform.Translate(new Vector3(0.0f, 0.0f, -0.1f)); TextMesh tMesh = text.GetComponent <TextMesh> (); double value = upgrade.GetCost(); string unit = ""; UnitsConverter.Convert(ref value, ref unit); tMesh.text = "-" + value.ToString("f" + priceDecimals) + unit; tMesh.color = Color.magenta; tMesh.characterSize = 0.003f; ClickPoints cp = text.GetComponent <ClickPoints>(); cp.floatUpSpeed = -0.06f; cp.fadeTime = 0.8f; cp.Animate(); } text = instance.textsPool.Enqueue(); if (text) { text.transform.position = menuItem.transform.position; text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); text.transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f)); text.transform.Translate(new Vector3(-0.05f, -0.02f, -0.1f)); TextMesh tMesh = text.GetComponent <TextMesh> (); double valueDifference = upgrade.GetNextLevelValue() - upgrade.GetCurrentLevelValue(); string unit = ""; UnitsConverter.Convert(ref valueDifference, ref unit); tMesh.text = "+" + valueDifference.ToString("f" + speedDecimals) + unit; tMesh.characterSize = 0.003f; tMesh.color = Color.cyan; ClickPoints cp = text.GetComponent <ClickPoints> (); cp.floatUpSpeed = 0.06f; cp.fadeTime = 0.8f; cp.Animate(); } text = instance.textsPool.Enqueue(); if (text) { text.transform.position = menuItem.transform.position; text.transform.rotation = new Quaternion(0f, 0f, 0f, 0f); text.transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f)); text.transform.Translate(new Vector3(-0.05f, 0.0f, -0.1f)); TextMesh tMesh = text.GetComponent <TextMesh> (); double healthDifference = (double)upgrade.GetNextLevelHealth() - upgrade.GetCurrentLevelHealth(); string unit = ""; UnitsConverter.Convert(ref healthDifference, ref unit); tMesh.text = "+" + healthDifference.ToString("f" + RepairsMenuManager.Instance.healthDecimals) + unit; tMesh.characterSize = 0.003f; tMesh.color = Color.green; ClickPoints cp = text.GetComponent <ClickPoints> (); cp.floatUpSpeed = 0.06f; cp.fadeTime = 0.8f; cp.Animate(); } }