public void SetCircleState(CircleState s) { if (this.currState == s) { return; } this.currState = s; this.circleObject.SetActive(currState != CircleState.None); switch (s) { case CircleState.None: break; case CircleState.Touched: circleImg.color = Color.gray; break; case CircleState.Selected: circleImg.color = Color.yellow; break; case CircleState.Disabled: break; } }
public void CanNotClick() { if (theState == CircleState.canClick) { theState = CircleState.normal; } }
private bool HorizontalTest(int column, CircleState color) { int linedUp = 0; int row = board.GetOpenRow(column); CircleState[] rowList = board.GetRow(row); for (int i = (column + 1); i < GameBoard.NumColumns; ++i) { if (board.GetElement(row, i) == color) { linedUp++; } else { break; } } for (int i = (column - 1); i >= 0; --i) { if (rowList[i] == color) // rowList[i] { linedUp++; } else { break; } } return(linedUp >= 3); }
public void ToolMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.varCircleState = new CircleState(e.X, e.Y); canvas.AddDrawingObject(this.varCircleState); } }
/// <summary> /// Determines whether the AI could win by choosing the given column /// </summary> /// <param name="column">The column the AI is testing.</param> /// <param name="color">The color the AI will test as</param> /// <returns> /// whether the AI could win by choosing the given column /// </returns> private bool WillWin(int column, CircleState color) { if (VerticalTest(column, color) || HorizontalTest(column, color) || DiagonalTest(column, color)) { return(true); } return(false); }
public void SetCutscene(Type myType = Type.BlackBands, Vector3 position = default(Vector3), bool startOn = false, float minimumCircleSize = 0.01f) { type = myType; advCamera.setCutscene(myType == Type.None ? true : false); //Debug.Log("SetCutscene " + myType + " " + position + " " + startOn); switch (type) { case Type.BlackBands: //TODO inventory.SetVisible (false); if (!PersistentEngine.takingVideo) { bandTop.transform.localPosition = startOn ? bandTopPositionShown : bandTopPositionHidden; } if (!PersistentEngine.takingVideo) { bandBottom.transform.localPosition = startOn ? bandBottomPositionShown : bandBottomPositionHidden; } circleState = CircleState.scalingUp; break; case Type.Puzzle: //TODO inventory.SetVisible (false); circleState = CircleState.scalingUp; break; case Type.ZoomIn: circleState = CircleState.scalingUp; minScale = 0.01f; //TODO inventory.SetVisible (false); zoomOutTransform.position = position; zoomoutCircle.transform.localScale = Vector3.one * 0.01f; zoomoutLeft.transform.localPosition = zoomoutLeftDef; zoomoutRight.transform.localPosition = zoomoutRightDef; zoomoutTop.transform.localPosition = zoomoutTopDef; zoomoutBottom.transform.localPosition = zoomoutBotDef; break; case Type.ZoomOut: StartCoroutine(SetZoomOutCoroutine(position)); minScale = minimumCircleSize; break; case Type.FadeOut: SetFadeout(true); //TODO inventory.SetVisible (false); fade.enabled = true; circleState = CircleState.scalingUp; break; default: circleState = CircleState.scalingUp; break; } }
/// <summary> /// Initializes a new instance of the <see cref="AI_Component" /> class. /// </summary> /// <param name="color">The color the AI will test as.</param> /// <param name="board">The game board the AI will be choosing a move for.</param> /// <exception cref="InvalidOperationException">AI circles cannot be represented by the empty state</exception> public AI_Component(CircleState color, GameBoard board) { if (color == CircleState.Empty) { throw new InvalidOperationException("AI circles cannot be represented by the empty state"); } this.color = color; this.board = board; }
void Update() { if (theGM.gameState == GameState.Start) { // if(theState == CircleState.normal || theState == CircleState.canClick) // { // //改变Circle的position、scale 和 透明度 // transform.localScale = Vector3.Lerp(transform.localScale, // new Vector3(this.transform.localScale.x + spreadSpeed, this.transform.localScale .y + spreadSpeed,1f), Time.deltaTime); // transform.Translate(Vector3.down * Time.deltaTime * downSpeed); // theSprReder.color = new Color( theSprReder.color.r, theSprReder.color.g, theSprReder.color.b,theAlpha); // theAlpha -= Time.deltaTime * alphaSpeed; // } //改变Circle的position、scale 和 透明度 transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(this.transform.localScale.x + spreadSpeed, this.transform.localScale.y + spreadSpeed, 1f), Time.deltaTime); transform.Translate(Vector3.down * Time.deltaTime * downSpeed); theSprReder.color = new Color(theSprReder.color.r, theSprReder.color.g, theSprReder.color.b, theAlpha); theAlpha -= Time.deltaTime * alphaSpeed; //判断能否继续下一个圆 if (theState == CircleState.canClick && Input.GetMouseButtonDown(0) && collideredDot != null) { //设置为失效状态 theState = CircleState.disable; GetComponent <CircleCollider2D>().enabled = false; // transform.position = collideredDot.position; // transform.localScale = startScale; //新生成波纹 newCir = Instantiate(preCircle, collideredDot.position, Quaternion.identity); newCir.transform.localScale = startScale; newCir.GetComponent <CircleCollider2D>().enabled = true; //重置透明度 // theAlpha = 1; // theState = CircleState.normal; Destroy(collideredDot.gameObject); //播放音效 clickAudio[UnityEngine.Random.Range(0, 6)].Play(); } else if (theState == CircleState.normal && Input.GetMouseButtonDown(0)) { theGM.ReduceScore(1); } if ((theState == CircleState.normal || theState == CircleState.canClick) && theAlpha <= 0f) { Debug.Log(this.gameObject.name + " Over"); PlayDeath(); } else if (theAlpha <= 0f) { Debug.Log("Destory"); Destroy(this.gameObject); } } }
/// <summary> /// Returns an array of <see cref="CircleState" />s for the requested row. /// </summary> /// <param name="column">The column requested</param> /// <returns> /// an array of <see cref="CircleState" />s for the requested row. /// </returns> /// <exception cref="InvalidOperationException">Invalid column requested</exception> public CircleState[] GetColumn(int column) { CircleState[] toReturn = new CircleState[NumRows]; ValidColumn(column); for (int i = 0; i < NumColumns; ++i) { toReturn[i] = board[i, column]; } return(toReturn); }
public void ChangeState(CircleState newState) { if (circleState == newState) { Debug.LogWarning("The circle state is already " + newState.ToString() + "\n"); return; } currentTime = 0; circleState = newState; }
/// <summary> /// Returns an array of <see cref="CircleState" />s for the requested row. /// </summary> /// <param name="row">The row requested.</param> /// <returns>an array of <see cref="CircleState" />s for the requested row.</returns> /// <exception cref="InvalidOperationException">Invalid row requested</exception> public CircleState[] GetRow(int row) { CircleState[] toReturn = new CircleState[NumRows]; if (row <= 0 || row >= NumRows) { throw new InvalidOperationException("Invalid row requested"); } for (int i = 0; i < NumColumns; ++i) { toReturn[i] = board[row, i]; } return(toReturn); }
/// <summary> /// Adds the specified color to the specified column. /// </summary> /// <param name="column">The column.</param> /// <param name="color">The color.</param> /// <exception cref="InvalidOperationException">Attempted to make an illegal move.</exception> public void Add(int column, CircleState color) { for (int i = 0; i < 6; ++i) { ValidColumn(column); if (board[i, column] == CircleState.Empty) { board[i, column] = color; return; } } throw new InvalidOperationException("Attempted to make an illegal move."); }
IEnumerator SetZoomOutCoroutine(Vector3 position) { yield return(new WaitForSeconds(0.5f)); circleState = CircleState.scalingDown; position.z = 0; zoomOutTransform.position = position; //TODO inventory.SetVisible (false); zoomoutCircle.transform.localScale = Vector3.one * advCamera.cameraSize; zoomoutLeft.transform.localPosition = zoomoutLeftDef + Vector3.left * 30; zoomoutRight.transform.localPosition = zoomoutRightDef + Vector3.right * 30; zoomoutTop.transform.localPosition = zoomoutTopDef + Vector3.up * 30; zoomoutBottom.transform.localPosition = zoomoutBotDef + Vector3.down * 30; }
/// <summary>改变选中数组CircleSet子控件状态 /// </summary> /// <param name="state"></param> public void ChangeCircleInCircleSetWithState(CircleState state) { for (int i = 0; i < CircleSet.Count; i++) { CircleSet[i].State = state; // 如果是错误状态,那就将最后一个按钮特殊处理 if (state == CircleState.CircleStateError) { if (i == CircleSet.Count - 1) { CircleSet[i].State = CircleState.CircleStateLastOneError; } } } SetNeedsDisplay(); }
void Start() { theGM = FindObjectOfType <GameManager>(); theSprReder = GetComponent <SpriteRenderer>(); //修改所有Dot的碰撞对象以及GM绑定的对象 dots = FindObjectsOfType <DotController>(); foreach (DotController dot in dots) { dot.ReplaceCircle(this); } theGM.ReplaceCircle(this); startScale = transform.localScale; theAlpha = 1; theState = CircleState.normal; }
/// <summary> /// Tests whether the AI could win by creating a situation where it has two ways of winning. /// </summary> /// <param name="column">The column the AI is testing.</param> /// <param name="color">The color the AI will test as.</param> /// <param name="choices">The list of choices available to the AI to make.</param> /// <returns> /// whether the AI could win by creating a situation where it has two ways of winning. /// </returns> private bool TwoWayWin(int column, CircleState color, List <int> choices) { int potentialWins = 0; int row = board.GetOpenRow(column); board.Add(column, color); foreach (int i in choices) { if (WillWin(i, color)) { ++potentialWins; } } board.Remove(column); return(potentialWins >= 2); }
private bool VerticalTest(int column, CircleState color) { int linedUp = 0; int row = board.GetOpenRow(column); CircleState[] columnList = board.GetColumn(column); for (int i = (row - 1); i >= 0; --i) { if (columnList[i] == color) { linedUp++; } else { break; } } return(linedUp >= 3); }
private void SetCircleState(CircleState state) { switch (state) { case CircleState.Paused: circleButton.renderer.material = buttonPause; break; case CircleState.Playing: circleButton.renderer.material = buttonPlay; break; case CircleState.Rewinding: circleButton.renderer.material = buttonRewind; break; } }
private void SwitchState(CircleState newState) { circleState = newState; UpdateVisualState(); }
/// <summary>对数组中最后一个对象的处理 /// </summary> /// <param name="state"></param> public void CircleSetLastObjectWithState(CircleState state) { CircleSet.Last().State = state; }
private bool DiagonalTest(int column, CircleState color) { int linedUp1 = 0; int linedUp2 = 0; int row = board.GetOpenRow(column); int i = row + 1, j = column + 1; for ( ; i < GameBoard.NumRows && j < GameBoard.NumColumns; ++i, ++j) { if (board.GetElement(i, j) == color) { linedUp1++; } else { break; } } i = row - 1; j = column - 1; for ( ; i >= 0 && j >= 0; --i, --j) { if (board.GetElement(i, j) == color) { linedUp1++; } else { break; } } i = row + 1; j = column - 1; for ( ; i < GameBoard.NumRows && j >= 0; ++i, --j) { if (board.GetElement(i, j) == color) { linedUp2++; } else { break; } } i = row - 1; j = column + 1; for ( ; i >= 0 && j < GameBoard.NumColumns; --i, ++j) { if (board.GetElement(i, j) == color) { linedUp2++; } else { break; } } return(linedUp1 >= 3 || linedUp2 >= 3); }
// // public void ResetCircle() // { // this.currentState = CircleState.Red; // this.IsActivated = false; // this.GetComponent<SpriteRenderer>().material.color = Color.white; // this.ring.gameObject.SetActive(false); // } public void ActivateCircle() { if (GameController.IsHardMode) { shadow.GetComponent<SpriteRenderer> ().enabled = true; bool overlap; do { UnityEngine.Random.seed = (int)System.DateTime.Now.Ticks; float scale = UnityEngine.Random.Range (origScale/2f, origScale); this.transform.localScale = new Vector3(scale, scale, 1f); CircleCol.enabled = true; UnityEngine.Random.seed = (int)System.DateTime.Now.Ticks; //float x = UnityEngine.Random.Range (GameController.llCorner.x, GameController.trCorner.x); float x = UnityEngine.Random.Range (quadLLCor.x, quadTRCor.x); UnityEngine.Random.seed = (int)System.DateTime.Now.Ticks; //float y = UnityEngine.Random.Range (GameController.llCorner.y, GameController.trCorner.y); float y = UnityEngine.Random.Range (quadLLCor.y, quadTRCor.y); transform.position = new Vector3 (x, y, -5f); if(CircleCol.bounds.min.x > GameController.llCorner.x && CircleCol.bounds.min.y > GameController.llCorner.y && CircleCol.bounds.max.x < GameController.trCorner.x && CircleCol.bounds.max.y < GameController.trCorner.y) { overlap = false; foreach (Circle circ in GameController.temporaryUnavailable.circles) { Bounds circBounds = circ.GetComponent<CircleCollider2D>().bounds; Vector3 min = circBounds.min; Vector3 max = circBounds.max; min.x -= (0.02f * GameController.boardWidth); max.x += (0.02f * GameController.boardWidth); min.y -= (0.02f * GameController.boardHeight); max.y += (0.02f * GameController.boardHeight); circBounds.SetMinMax(min, max); if (CircleCol.bounds.Intersects (circBounds)) { overlap = true; break; } } } else { overlap = true; } } while (overlap); GetComponent<SpriteRenderer> ().enabled = true; } spawnedAt = DateTime.Now; this.RequiredColor = new Color(0.0f, 1.0f, 0.4f); this.currentState = CircleState.White; this.IsActivated = true; this.StartCoroutine("ActivateCircleCorountine"); }
public void SetToWhiteAndDisable() { currentRenderer.material.color = Color.white; this.currentState = CircleState.White; this.StopAllCoroutines(); }
public void DeactivateCircle() { tappedAt = DateTime.Now; this.IsActivated = false; this.StopAllCoroutines(); var args = new CircleDeactivatedEventArgs(); args.GainedPoints = (int)currentState; if (args.GainedPoints >= 1) { this.ring.gameObject.SetActive(true); this.ring.circle = this; this.ring.ResetRing(); this.floatingText.gameObject.SetActive(true); this.floatingText.Score = args.GainedPoints; this.floatingText.ResetScore(BlockedDirectionID); } if (this.OnCircleDeactivated != null) { this.OnCircleDeactivated(this, args); } this.currentState = CircleState.Red; currentRenderer.material.color = Color.white; if (GameController.IsHardMode) { GetComponent<SpriteRenderer> ().enabled = false; shadow.GetComponent<SpriteRenderer>().enabled = false; transform.localPosition = new Vector3 (transform.localPosition.x, transform.localPosition.y, -1f); } }
private void SwitchCircleState() { if (this.IsActivated) { switch (currentState) { case CircleState.White: { RequiredColor = Color.yellow; currentState = CircleState.Green; break; } case CircleState.Green: { RequiredColor = new Color(0.8f, 0.4f, 0.1f); currentState = CircleState.Yellow; break; } case CircleState.Yellow: { RequiredColor = Color.red; currentState = CircleState.AlmostRed; break; } case CircleState.AlmostRed: { currentState = CircleState.Red; DeactivateCircle(); Debug.Log("Switched."); break; } } } }
//玩家此时可以点击屏幕来继续下一个圆 public void CanClick(Transform theDot) { theState = CircleState.canClick; collideredDot = theDot; Invoke("CanNotClick", timeForClick); }