//BONUS EVENTS public void AddFromHealthBonus() { BonusSelect bonus = bonusSelector.GetComponent <BonusSelect>(); if (bonus.healthBonus > 0) { //add either the full amount or just enough to reach 1(full health) HealthDrop(Mathf.Min(.1f, 1f - currHealth)); bonus.healthBonus -= 1; bonus.healthText.text = "" + bonus.healthBonus; } }
public void SlowWall() { BonusSelect bonus = bonusSelector.GetComponent <BonusSelect>(); if (bonus.slowBonus > 0) { Debug.LogWarning("wall slow!"); wallSpeed *= .5f; wall.speed = wallSpeed; currentWallSlows += 1; bonus.slowBonus -= 1; bonus.slowText.text = "" + bonus.slowBonus; } }
public void RemoveRandomVertex() { BonusSelect bonus = bonusSelector.GetComponent <BonusSelect>(); if (bonus.removeBonus > 0) { //get the polygons in a random order int[] randomInts = Shuffle(currentPolys.Count); foreach (int j in randomInts) { //get a random polygon from player polygons TestPolygon p = currentPolys[j]; //if it has more vertices than its corresponding hole, we shall remove one from it if (p.verticesList.Count > p.holeToMatch.verticesList.Count) { bool foundOne = false; int i = 0; Vector3 toCheck = new Vector3(0, 0, 0); while (!foundOne) { //get a random vertex from this player polygon i = Random.Range(0, p.verticesList.Count); toCheck = p.verticesList[i]; //if the target polygon doesn't have it, good to remove it from player polygon if (!(p.holeToMatch.verticesList.Exists(v => v.x == toCheck.x && v.y == toCheck.y))) { RemovePlayerVertex(i, p); foundOne = true; } //if target polygon DOES have that vertex, we don't care, try to find another one to remove } bonus.removeBonus -= 1; bonus.removeText.text = "" + bonus.removeBonus; //we removed one, break from our loop looking for a candidate polygon break; } } } }
// Use this for initialization void Start() { score = 0; failCounter = 0; chainAmt = 0; chainThreshold = 5; levelThreshold = 1; level = 0; currentLevel = levels[0]; numberOfShapes = 1; polyRangeLow = 0; polyRangeHigh = 1; currHealth = 1f; newHealth = 1f; t = 0f; wallSpeed = .05f; audiosource = GameObject.Find("BGM").GetComponent <AudioSource> (); wallPlane = GameObject.Find("Wall").transform.Find("Plane"); animDone = false; smallBeat = false; skyboxOffset = 0f; //screen orientation stuff ScreenWatcher.AddOrientationChangeListener(OnOrientationChanged); //Screen.orientation = ScreenOrientation.LandscapeLeft; wall = GameObject.FindObjectOfType <Wall>(); bs = bonusSelector.GetComponent <BonusSelect>(); cylinderOffsetProperty = "_DownTex"; cylinderOffsetProp2 = "_DownTex2"; twoOffsetProps = false; //PositionForLandscape (); //set up text colors scoreText.color = world1Text; scoreText.GetComponent <UnityEngine.UI.Outline>().effectColor = world1Outline; chainText.color = world1Text; chainText.GetComponent <UnityEngine.UI.Outline>().effectColor = world1Outline; infoText.color = world1Text; infoText.GetComponent <UnityEngine.UI.Outline>().effectColor = world1Outline; if (Screen.orientation == ScreenOrientation.Landscape) { PositionForLandscape(); } else if (Screen.orientation == ScreenOrientation.Portrait) { PositionForPortrait(); } //GameObject.Find ("MainCanvas").GetComponent<CanvasScaler> ().referenceResolution = new Vector2 (Screen.width, Screen.height); polygons = new List <List <Vector3> >(); Vector3[] shape1 = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(1f, 0f, 0f) }; polygons.Add(new List <Vector3>(shape1)); Vector3[] shape2 = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(1f, 2f, 0f), new Vector3(1f, 0f, 0f), new Vector3(0f, -1f, 0f) }; polygons.Add(new List <Vector3>(shape2)); Vector3[] shape3 = new Vector3[] { new Vector3(-1f, -1f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 0f, 0f), new Vector3(0f, -1f, 0f) }; polygons.Add(new List <Vector3>(shape3)); Vector3[] shape4 = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(-.5f, 1f, 0f), new Vector3(.5f, 1f, 0f), new Vector3(1f, 0f, 0f) }; //5 sided polygons.Add(new List <Vector3>(shape4)); Vector3[] shape5 = new Vector3[] { new Vector3(0f, -.5f, 0f), new Vector3(-.5f, 0f, 0f), new Vector3(0f, 1f, 0f), new Vector3(1f, 0f, 0f), new Vector3(.5f, -.5f, 0f) }; polygons.Add(new List <Vector3>(shape5)); Vector3[] shape6 = new Vector3[] { new Vector3(0f, -.5f, 0f), new Vector3(-.5f, 0f, 0f), new Vector3(-.5f, .5f, 0f), new Vector3(0f, 1f, 0f), new Vector3(.5f, 0f, 0f) }; polygons.Add(new List <Vector3>(shape6)); Vector3[] shape7 = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(-.5f, .5f, 0f), new Vector3(.5f, 1f, 0f), new Vector3(1f, .5f, 0f), new Vector3(.5f, 0f, 0f) }; polygons.Add(new List <Vector3>(shape7)); Vector3[] shape8 = new Vector3[] { new Vector3(0f, -.5f, 0f), new Vector3(-.5f, 0f, 0f), new Vector3(0f, .5f, 0f), new Vector3(1f, 0f, 0f), new Vector3(0f, 0f, 0f) }; polygons.Add(new List <Vector3>(shape8)); //6 sided Vector3[] shape9 = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3(-.5f, 0f, 0f), new Vector3(0f, 1f, 0f), new Vector3(1f, .5f, 0f), new Vector3(.5f, .5f, 0f), new Vector3(1f, -.5f, 0f) }; polygons.Add(new List <Vector3>(shape9)); Vector3[] shape10 = new Vector3[] { new Vector3(0f, -.5f, 0f), new Vector3(-.5f, .5f, 0f), new Vector3(0f, 1f, 0f), new Vector3(.5f, 1f, 0f), new Vector3(1f, .5f, 0f), new Vector3(.5f, -.5f, 0f) }; polygons.Add(new List <Vector3>(shape10)); Vector3[] shape11 = new Vector3[] { new Vector3(-.5f, -0f, 0f), new Vector3(0f, .5f, 0f), new Vector3(0f, 1f, 0f), new Vector3(.5f, 1f, 0f), new Vector3(.5f, 0f, 0f), new Vector3(1f, -.5f, 0f) }; polygons.Add(new List <Vector3>(shape11)); Vector3[] shape12 = new Vector3[] { new Vector3(-.5f, 0f, 0f), new Vector3(-.5f, .5f, 0f), new Vector3(0f, 1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(1f, -.5f, 0f), new Vector3(.5f, -.5f, 0f) }; polygons.Add(new List <Vector3>(shape12)); //create custom polygons list if custom game if (gameType == GameType.CasualCustom) { CreateCustomParamsLevel(GameObject.FindObjectOfType <CustomGameParams>()); } //currentPoly.Setup (); currentPolys = new List <TestPolygon>(); CreateNewPlayerPolygons(); numToRemove = 0; foreach (TestPolygon p in currentPolys) { numToRemove += p.numToRemove; } currentHoles = new List <TestPolygon>(); CreateHoles(); }