/// <summary> /// Prepare a vector line for our use-case. /// </summary> /// <param name="line"> /// The line to set up. /// </param> private void SetupLine(VectorLine line, List <Color32> colors) { line.material = _material; line.drawTransform = transform; line.SetColors(colors); line.Draw3DAuto(); }
void Start () { // Make a bunch of points in a spherical distribution var starPoints = new Vector3[numberOfStars]; for (int i = 0; i < numberOfStars; i++) { starPoints[i] = Random.onUnitSphere * 100.0f; } // Make each star have a size ranging from 1.5 to 2.5 var starSizes = new float[numberOfStars]; for (int i = 0; i < numberOfStars; i++) { starSizes[i] = Random.Range (1.5f, 2.5f); } // Make each star have a random shade of grey var starColors = new Color32[numberOfStars]; for (int i = 0; i < numberOfStars; i++) { var greyValue = Random.value * .75f + .25f; starColors[i] = new Color(greyValue, greyValue, greyValue); } stars = new VectorLine("Stars", new List<Vector3>(starPoints), 1.0f, LineType.Points); stars.SetColors (new List<Color32>(starColors)); stars.SetWidths (new List<float>(starSizes)); stars.Draw(); // We want the stars to be drawn behind 3D objects, like a skybox. So we use SetCanvasCamera, // which makes the canvas draw with RenderMode.OverlayCamera using Camera.main. // Note that SetCanvasCamera should be called after the VectorLine is drawn, // or else the VectorLine won't be drawn correctly. VectorLine.SetCanvasCamera (Camera.main); VectorLine.canvas.planeDistance = Camera.main.farClipPlane-1; }
void update_colors() { if (colors != null && colors.Length > 0) { if (points != null) { var ncolors = colors.Length; var needed = points.Length - 1; if (ncolors > needed) { Array.Resize(ref colors, needed); } else if (ncolors < needed) { Utils.Log("VectorsityLineRenderer[{}] Number of colors should be >= " + "points.Length-1. Expected {} or more got {}", name, points.Length - 1, colors.Length); colors = null; } } //Utils.Log("points {}, colors {}", points.Length, colors.Length);//debug line.SetColors(new List <Color32>(colors)); } else { line.SetColor(color); } }
// Check the selected word private void Check(string word) { if (!correct) { // foreach (KeyValuePair<string, bool> p in placedWords) foreach (string p in placedWords) { // if (word.ToLower() == p.Key.Trim().ToLower()) // if (word.ToLower() == p.ToLower()) if (word == p) { correct = true; // Debug.Log("Word found = " + word + " Count placed ="+ placedWords.Count); //Play correct word sound if (GameData.isMusicON) { MainDriver.Instance.PlayCorrectWordSound(); } } } } if (correct) { gameHud.SendMessage("WordFound", word); placedWords.Remove(word); solved++; if (lineColors != null) { for (var i = 0; i < lineColors.Count; i++) { lineColors[i] = new Color(0, 1, 0, 0.42f); //0.42f aalfa lineColors[i] = new Color(225.0f / 255, 184.0f / 255, 216.0f, 0.38f); } currentSelectionLine.SetColors(lineColors); } selectionLines.Add(currentSelectionLine); currentSelectionLine = null; if ((placedWords.Count == 0) || (solved == totalWords)) { if (GameData.isTimeChallenge) { if (GameData.timeTaken <= GameData.timeLimit) { GameData.isChallengeCompleted = true; } } Application.LoadLevel("GameOver"); } } else { RemoveWrongSelection(); } correct = false; SetSelectionLine(); }
void SetLineColors() { if (lineColors == null) { lineColors = new List <Color32>(new Color32[numberOfPoints - 1]); } for (int i = 0; i < lineColors.Count; i++) { lineColors[i] = Color.Lerp(color1, color2, (float)i / lineColors.Count); } line.SetColors(lineColors); }
IEnumerator CycleColor() { while (true) { for (int i = 0; i < 4; i++) { lineColors[i] = Color.Lerp(Color.yellow, Color.red, Mathf.PingPong((Time.time + i * .25f) * 3.0f, 1.0f)); } selectionLine.SetColors(lineColors); yield return(null); } }
void Update() { DelayChanging(); if (_doChangeColor) { // Pick a random colour for the current line and apply it. var index = Random.Range(0, 7); _colors[_iterator] = _palette[index]; _line.SetColors(_colors); ++_iterator; //next line // 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 0 -> 1 -> 2 -> ... _iterator %= _colors.Count; } Rotate(); }
// Token: 0x06000B43 RID: 2883 RVA: 0x00033550 File Offset: 0x00031950 private void Start() { int num = this.numberOfDots * this.numberOfRings; Vector2[] collection = new Vector2[num]; Color32[] array = new Color32[num]; float b = 1f - 0.75f / (float)num; for (int i = 0; i < array.Length; i++) { array[i] = this.dotColor; this.dotColor *= b; } VectorLine vectorLine = new VectorLine("Dots", new List <Vector2>(collection), this.dotSize, LineType.Points); vectorLine.SetColors(new List <Color32>(array)); for (int j = 0; j < this.numberOfRings; j++) { vectorLine.MakeCircle(new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2)), (float)(Screen.height / (j + 2)), this.numberOfDots, this.numberOfDots * j); } vectorLine.Draw(); }
void Start() { var totalDots = numberOfDots * numberOfRings; var dotPoints = new Vector2[totalDots]; var dotColors = new Color32[totalDots]; var reduceAmount = 1.0f - .75f / totalDots; for (int i = 0; i < dotColors.Length; i++) { dotColors[i] = dotColor; dotColor *= reduceAmount; } var dots = new VectorLine("Dots", new List <Vector2>(dotPoints), dotSize, LineType.Points); dots.SetColors(new List <Color32>(dotColors)); for (int i = 0; i < numberOfRings; i++) { dots.MakeCircle(new Vector2(Screen.width / 2, Screen.height / 2), Screen.height / (i + 2), numberOfDots, numberOfDots * i); } dots.Draw(); }
private void Start() { int length = this.numberOfDots * this.numberOfRings; Vector2[] vector2Array = new Vector2[length]; Color32[] color32Array = new Color32[length]; float num = (float)(1.0 - 0.75 / (double)length); for (int index = 0; index < color32Array.Length; ++index) { color32Array[index] = Color32.op_Implicit(this.dotColor); DrawPoints drawPoints = this; drawPoints.dotColor = Color.op_Multiply(drawPoints.dotColor, num); } VectorLine vectorLine = new VectorLine("Dots", new List <Vector2>((IEnumerable <Vector2>)vector2Array), this.dotSize, (LineType)2); vectorLine.SetColors(new List <Color32>((IEnumerable <Color32>)color32Array)); for (int index = 0; index < this.numberOfRings; ++index) { vectorLine.MakeCircle(Vector2.op_Implicit(new Vector2((float)(Screen.get_width() / 2), (float)(Screen.get_height() / 2))), (float)(Screen.get_height() / (index + 2)), this.numberOfDots, this.numberOfDots * index); } vectorLine.Draw(); }
public void OnChangeDirection() { if (ShipType == eShipType.Enemy)//以下代码给PlayerShip使用 return; if (!FirePoint.activeInHierarchy) return; if (ShotDirX.text == "" || ShotDirY.text == "") return; Vector3 targetPos = new Vector3 (int.Parse(ShotDirX.text),int.Parse(ShotDirY.text),0); //如果是相对瞄准,不进行这步 if (WeaponSystem.getInstance().bAimType_Abs) { targetPos -= transform.position; } targetPos.Normalize (); if (FireLine == null) { Vector3 [] _points = new Vector3[6]; for(int i=0;i<6;++i) { _points[i]=new Vector3(pMain.AimLineScale*0.1f*i,0,0); } Color [] _color = new Color[5]; _color[0] = Color.red; _color[1] = Color.yellow; _color[2] = Color.green; _color[3] = Color.blue; _color[4] = Color.red; FireLine = VectorLine.SetLine(Color.white,_points); FireLine.smoothColor = true; FireLine.SetColors(_color); VectorManager.ObjectSetup(FirePoint,FireLine,Visibility.Always, Brightness.None); } float direct = Mathf.Acos (targetPos.x); direct = direct/Mathf.PI * 180; if (targetPos.y < 0) direct = 360-direct; FirePoint.transform.rotation = Quaternion.Euler(new Vector3(0,0,direct)); //FirePoint.transform.rotation = Quaternion.Euler (0,0,90); }
void ShowMoveTrek() { if (ShipType != eShipType.Enemy)//仅敌人显示轨迹 return; if (Speed.magnitude < float.Epsilon) return; Vector3 targetPos = new Vector3 (Speed.x,Speed.y,0); targetPos.Normalize (); if (FireLine == null) { Vector3 [] _points = new Vector3[6]; for(int i=0;i<6;++i) { _points[i]=new Vector3(pMain.AimLineScale*0.1f*i,0,0); } Color [] _color = new Color[5]; _color[0] = Color.red; _color[1] = Color.yellow; _color[2] = Color.green; _color[3] = Color.blue; _color[4] = Color.red; FireLine = VectorLine.SetLine(Color.white,_points); FireLine.smoothColor = true; FireLine.SetColors(_color); VectorManager.ObjectSetup(FirePoint,FireLine,Visibility.Always, Brightness.None); } float direct = Mathf.Acos (targetPos.x); direct = direct/Mathf.PI * 180; if (targetPos.y < 0) direct = 360-direct; FirePoint.transform.localPosition = new Vector3 (0, 0, 0); FirePoint.transform.rotation = Quaternion.Euler(new Vector3(0,0,direct)); }
public void OnEnemyRespawn() { Vector3 targetPos = new Vector3(Speed.x, Speed.y, 0); //targetPos -= transform.position; targetPos.Normalize(); if (FireLine == null) { Vector3[] _points = new Vector3[6]; for (int i = 0; i < 6; ++i) { _points[i] = new Vector3(pMain.AimLineScale * 0.1f * i, 0, 0); } Color[] _color = new Color[5]; _color[0] = Color.red; _color[1] = Color.yellow; _color[2] = Color.green; _color[3] = Color.blue; _color[4] = Color.red; FireLine = VectorLine.SetLine(Color.white, _points); FireLine.smoothColor = true; FireLine.SetColors(_color); VectorManager.ObjectSetup(FirePoint, FireLine, Visibility.Always, Brightness.None); } float direct = Mathf.Acos(targetPos.x); direct = direct / Mathf.PI * 180; if (targetPos.y < 0) direct = 360 - direct; FirePoint.transform.rotation = Quaternion.Euler(new Vector3(0, 0, direct)); //FirePoint.transform.rotation = Quaternion.Euler (0,0,90); }