void Start() { text = GetComponent<Text> (); originalColor = text.color; collisionDetection.OnHit += triggerChangeColor; state = idle; }
public void changeColor(Color col, bool rand = false, float transition = 0.1f) { state = decreasing; transOut = transition; if (rand) transOut += Random.Range(-transition* (2f/3f), transition * 2); trans = 1; }
void stopping() { counter -= Time.deltaTime; if (counter <= 0) { main.animation.Stop (); state = idle; } }
void decreasing() { trans -= transOut; Color transColor = Color.Lerp (originalColor, ColorManager.instance.hitCol, trans); image.color = transColor; if (trans <= 0) state = idle; }
void decreasing() { trans -= transOut; Color transColor = Color.Lerp (originalColor, currentColor, trans); renderer.material.color = transColor; if (trans <= 0) state = idle; }
public void changeColor(Color col, float transition, bool rand) { state = decreasing; currentColor = col; transOut = transition; if (rand) transOut += Random.Range(-transition* (2f/3f), transition * 2); trans = 1; }
void decreasing() { trans -= transOut; Color transColor = Color.Lerp (originalColor, hitColor, trans); text.color = transColor; if (trans <= 0) state = idle; }
void moving() { if (Input.GetAxis("Mouse X") == 0) { state = decelerating; decelerating (); return; } speed = Input.GetAxis ("Mouse X") * sensitivityX; transform.Rotate(0, speed, 0); }
void fire() { GameObject barInst = GameObject.Instantiate (bar, currentTile.transform.position, currentTile.transform.rotation) as GameObject; currentBarComp = barInst.GetComponent<Bar> (); float magnitude = getScale (scaleCoords [currentWall, stateIndex]); currentBarComp.maxDist = magnitude * tileLen; barInst.transform.localScale = new Vector3 (tileLen, tileLen * magnitude, tileLen); barInst.transform.Translate (new Vector3 (0, -magnitude/2f * tileLen, 0)); currentBarComp.onDone += switchBackToMoving; movementState = idle; }
void decelerating() { if (Input.GetAxis("Mouse X") != 0) { state = moving; moving (); return; } speed *= deceleration; speed = Mathf.Clamp (speed, 0, speed); transform.Rotate(0, speed, 0); Debug.Log (speed); if (speed == 0) state = moving; }
public void activate() { counter = 0f; float minValint = (float.Parse(minVal)); if (minValint <= 0 || minValint == null) { state = idle; return; } float minsInDay = 60 * 24; increment = minsInDay / minValint; goal = minsInDay; on = true; state = running; }
void show() { hideCounter = whenToHide; if (state == hidden || state == null) { toEnable.SetActive (true); state = shown; if (timedHiders.Count + 1 > maxAmount) { //the ui lags a lot so it has to be limited TimedHider timedHider = timedHiders[0]; if (timedHider != null) timedHider.hide(); timedHiders.Remove(timedHider); } timedHiders.Add(this); } }
void firing() { float move = speed * Time.deltaTime; transform.Translate (new Vector3 (0, move, 0)); distTraveled += move; speed *= acceleration; damage = Point.instance.value; if (distTraveled >= maxDist) { Vector3 movementToEnd = new Vector3(0, maxDist-distTraveled,0); transform.Translate(movementToEnd); speed = initSpeed; distTraveled = 0; state = pause; damage = Point.instance.value; } }
void OnEnable() { WallManager.instance.onNewDimensions += updateDim; WallBuilder.instance.OnNewWall += updateWallParams; tileLen = WallManager.instance.tileLen; normalColor = WallManager.instance.normalColor; activeColor = WallManager.instance.activeColor; delay = delayVal; counter = counterLimit; fireCounter = fireCounterLimit; xAmt = WallManager.instance.xAmt; yAmt = WallManager.instance.yAmt; zAmt = WallManager.instance.zAmt; directions = new Vector3[4,3] {{new Vector3 (0,1,0), new Vector3 (1,0,0), new Vector3 (1,0,0)}, {new Vector3 (0,0,1), new Vector3 (0,0,1), new Vector3 (0,-1,0)}, {new Vector3 (0,-1,0), new Vector3 (-1,0,0), new Vector3 (-1,0,0)}, {new Vector3 (0,0,-1), new Vector3 (0,0,-1), new Vector3 (0,1,0)}}; scaleCoords = new int[4,3] {{2,2,1}, {1,0,0}, {2,2,1}, {1,0,0}}; position = new Vector3 (0, 0, 0); currentWall = 0; setConversionValues (currentWall); stateHandler path = randomizePath (YPath, XPath); path (); movementState = moving; }
// Use this for initialization void Start() { originalColor = renderer.material.color; WallManager.instance.OnNewColor += changeColor; state = idle; }
public void stop() { on = false; state = idle; }
void Start() { state = idle; }
void moving() { counter -= Time.deltaTime; fireCounter -= Time.deltaTime; delay -= Time.deltaTime; if (delay >= 0) return; delay = delayVal; move (); if (counter <= 0) { counter = counterLimit; switchDirection(currentWall); } if (fireCounter <= 0) { fireCounter = fireCounterLimit; movementState = fire; } lastTile = currentTile; //=====color code===== currentTile = currentPath [currentWall] [(int)(position2D.x), (int)(position2D.y)]; //currentTile.renderer.material.color = activeColor; if (currentTile != lastTile) currentTileComp = currentTile.GetComponent<StaticTile>(); currentTileComp.changeColor (activeColor, 0.012f, false); }
void ZPath() { pathState = ZPath; stateIndex = 2; direction = directions [currentWall, stateIndex]; currentPath = WallManager.instance.pathAroundZ; }
void YPath() { pathState = YPath; stateIndex = 1; direction = directions [currentWall, stateIndex]; currentPath = WallManager.instance.pathAroundY; }
void XPath() { //path around x axis pathState= XPath; stateIndex = 0; direction = directions [currentWall, stateIndex]; currentPath = WallManager.instance.pathAroundX; }
void pause() { counter -= Time.deltaTime; if (counter <= 0) state = moveBack; }
void Start() { speed = 10; initSpeed = speed; acceleration = 1.1f; counter = 2; //seconds renderer.material.color = WallManager.instance.activeColor; state = firing; }
void OnEnable() { collisionDetection.OnHit += triggerChangeColor; state = idle; }
// Use this for initialization void Start() { counter = counterVal; state = idle; }
stateHandler randomizePath(stateHandler firstState, stateHandler secondState) { if (Random.Range(0,100) < 50) return firstState; else return secondState; }
void switchBackToMoving() { movementState = moving; currentBarComp.onDone -= switchBackToMoving; }
void Start() { // Make the rigid body not change rotation if (GetComponent<Rigidbody>()) GetComponent<Rigidbody>().freezeRotation = true; Screen.lockCursor = true; state = moving; }
public void hide() { toEnable.SetActive (false); state = hidden; }