private IEnumerator EndGame(ColourState aColour) { yield return(new WaitForSeconds(2f)); if (aColour == ColourState.Red) { m_GM.RedScore += 1; if (m_GM.Player1IsRed) { m_GM.LastGameWinner = m_GM.Player1Name; } else { m_GM.LastGameWinner = m_GM.Player2Name; } } else if (aColour == ColourState.Blue) { m_GM.BlueScore += 1; if (m_GM.Player1IsRed) { m_GM.LastGameWinner = m_GM.Player2Name; } else { m_GM.LastGameWinner = m_GM.Player1Name; } } LevelManager.Instance.ChangeLevel("WinnerScreen"); }
private IEnumerator DropPiece(Slot aSlot, ColourState aColour) { Slot previousSlot = null; Slot actualSlot = null; int row = m_GM.Grid[0].Count - 1; int col = aSlot.Col; while (actualSlot != aSlot) { previousSlot = actualSlot; actualSlot = m_GM.Grid[col][row].GetComponent <Slot>(); if (previousSlot != null) { previousSlot.StateOfSlot = ColourState.Empty; previousSlot.UpdateSlot(); } actualSlot.StateOfSlot = aColour; actualSlot.UpdateSlot(); row -= 1; if (actualSlot == aSlot) { EndTurn(); AudioManager.Instance.PlaySFX(m_InPlaceSFX, aSlot.gameObject.transform.position); } else { AudioManager.Instance.PlaySFX(m_DescendingSFX, aSlot.gameObject.transform.position); } yield return(new WaitForSeconds(m_DropSpeed)); } }
private void Start() { if (m_GM.Player1IsRed) { m_MyColour = ColourState.Blue; } else { m_MyColour = ColourState.Red; } }
public List <RotationValueState> RotationValues; //Rotation values are tooltip values tied to rotations public bool EqualsObject(object obj) { if (obj == null) { return(false); } ObjectState os = obj as ObjectState; if (os == null) { return(false); } TransformState ThisTransform = this.Transform; TransformState OtherTransform = os.Transform; ColourState ThisColor = this.ColorDiffuse; ColourState OtherColor = os.ColorDiffuse; /* * if (ThisColor != null && OtherColor != null && ThisColor.ToColour() != OtherColor.ToColour()) * { * return false; * } */ string ThisGUID = this.GUID; string OtherGUID = os.GUID; bool ThisLocked = this.Locked; bool ThisGrid = this.Grid; bool ThisSnap = this.Snap; bool ThisAutoraise = this.Autoraise; bool ThisSticky = this.Sticky; bool ThisTooltip = this.Tooltip; bool ThisGridProjection = this.GridProjection; bool?ThisHideWhenFaceDown = this.HideWhenFaceDown; bool?ThisHands = this.Hands; bool OtherLocked = os.Locked; bool OtherGrid = os.Grid; bool OtherSnap = os.Snap; bool OtherAutoraise = os.Autoraise; bool OtherSticky = os.Sticky; bool OtherTooltip = os.Tooltip; bool OtherGridProjection = os.GridProjection; bool?OtherHideWhenFaceDown = os.HideWhenFaceDown; bool?OtherHands = os.Hands; this.Transform = null; os.Transform = null; this.ColorDiffuse = null; os.ColorDiffuse = null; this.GUID = null; os.GUID = null; this.Locked = false; this.Grid = false; this.Snap = false; this.Autoraise = false; this.Sticky = false; this.Tooltip = false; this.GridProjection = false; this.HideWhenFaceDown = false; this.Hands = null; os.Locked = false; os.Grid = false; os.Snap = false; os.Autoraise = false; os.Sticky = false; os.Tooltip = false; os.GridProjection = false; os.HideWhenFaceDown = false; os.Hands = null; string ThisJson = this.ToJson(); // Json.GetJson(this, false); string NewJson = this.ToJson(); // Json.GetJson(os, false); this.Transform = ThisTransform; os.Transform = OtherTransform; this.ColorDiffuse = ThisColor; os.ColorDiffuse = OtherColor; this.GUID = ThisGUID; os.GUID = OtherGUID; this.Locked = ThisLocked; this.Grid = ThisGrid; this.Snap = ThisSnap; this.Autoraise = ThisAutoraise; this.Sticky = ThisSticky; this.Tooltip = ThisTooltip; this.GridProjection = ThisGridProjection; this.HideWhenFaceDown = ThisHideWhenFaceDown; this.Hands = ThisHands; os.Locked = OtherLocked; os.Grid = OtherGrid; os.Snap = OtherSnap; os.Autoraise = OtherAutoraise; os.Sticky = OtherSticky; os.Tooltip = OtherTooltip; os.GridProjection = OtherGridProjection; os.HideWhenFaceDown = OtherHideWhenFaceDown; os.Hands = OtherHands; return(ThisJson == NewJson); }
private bool CheckWin(ColourState aSlotState) { List <List <GameObject> > grid = GameManager.Instance.Grid; int checkCount = 0; //CheckColumn for (int i = 0; i < grid.Count; i++) { checkCount = 0; for (int j = 0; j < grid[i].Count; j++) { if (grid[i][j].GetComponent <Slot>().StateOfSlot == aSlotState) { checkCount += 1; if (checkCount == 4) { return(true); } } else { checkCount = 0; } } } //CheckRow for (int i = 0; i < grid[i].Count; i++) { checkCount = 0; for (int j = 0; j < grid.Count; j++) { if (grid[j][i].GetComponent <Slot>().StateOfSlot == aSlotState) { checkCount += 1; if (checkCount == 4) { return(true); } } else { checkCount = 0; } } } //CheckRightDiagonals for (int i = 0; i < grid.Count; i++) { checkCount = 0; for (int j = 0; j < grid[i].Count - 1; j++) { checkCount = 0; if (grid[i][j].GetComponent <Slot>().StateOfSlot == aSlotState) { checkCount += 1; for (int k = 1; k < grid[i].Count; k++) { if (i + k < grid.Count && j + k < grid[i].Count) { if (grid[i + k][j + k].GetComponent <Slot>().StateOfSlot == aSlotState) { checkCount += 1; if (checkCount == 4) { return(true); } } } else { continue; } } } } } //CheckLeftDiagonals for (int i = 0; i < grid.Count; i++) { checkCount = 0; for (int j = 0; j < grid[i].Count - 1; j++) { checkCount = 0; if (grid[i][j].GetComponent <Slot>().StateOfSlot == aSlotState) { checkCount += 1; for (int k = 1; k < grid[i].Count; k++) { if (i - k >= 0 && j + k < grid[i].Count) { if (grid[i - k][j + k].GetComponent <Slot>().StateOfSlot == aSlotState) { checkCount += 1; if (checkCount == 4) { return(true); } } } else { continue; } } } } } return(false); }