public static void Main(string[] args) { Board board = new Board(); Game game = new Game(board); CheckWin checkWin = new CheckWin(); UI ui = new UI(); ui.introduction(); while (game.PlaysAgain.Equals("Y")) { board.initializeVariable(); while (checkWin.hasWon(board.currentBoard) == false && game.Counter < 9) { game.askData("X"); if (checkWin.hasWon(board.currentBoard) == true || game.Counter == 9) { break; } game.askData("O"); } if (checkWin.hasWon(board.currentBoard) == true) { ui.playAgainMsg("Congradulation! You won!"); } else { ui.playAgainMsg("Sorry, but this was a tie game!"); } } ui.goodBye(); }
public void BanditRun() { int price = 25; for (int i = 0; i < SettingsBandit.Instance.dataForFormulas.toggles.Length; i++) { if (SettingsBandit.Instance.dataForFormulas.toggles[i].isOn) { price += 25; } } amount -= price; UpdateText(); for (int i = 0; i < slots.Length; i++) { AnimationController.Instance.RotationSlots(slots[i].transform); int index = Random.Range(0, winSprites.Length); slots[i].sprite = winSprites[index]; massIndexSlots[i] = index + 1; } CheckWin.Joker = winSprites.Length; CheckWin.UpdateMatrix(massIndexSlots, slots); CheckWinGame(); }
void Awake() { sr = transform.Find("coloring_tile").GetComponent <SpriteRenderer>(); sr.color = GetColorFromEnum(myColor); CheckWin wincontr = GameObject.FindGameObjectWithTag("WinController").GetComponent <CheckWin>(); wincontr.winConds.Add(this); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "redCage") { Destroy(gameObject); CheckWin.CheckRed(); zombieSprite.SetActive(true); } }
void CheckWinGame() { int prize = CheckWin.GetWinAmount(); AnimationController.Instance.WinGame(prize.ToString()); Debug.Log($"You win : {prize}$"); amount += prize; totalWin += prize; UpdateText(); }
private void Start() { level = FindObjectOfType <CheckWin>(); levelI = FindObjectOfType <CheckWinI>(); if (level != null) { level.addBlock(); } else { levelI.addBlock(); } }
public void Enter() { levelSndInstance = levelSnd.CreateInstance(); //levelSndInstance.Play(); rectangles = state.levelManager.levels[2].rectangles; //gate gateRectangle = new RectangleObjects(336, 24, 96, 72); rectangles.Add(gateRectangle); //reset resetRectangle = new Rectangle(336, 662, 98, 10); collide = new Collision(rectangles, actors, state); grabThrow = new GrabThrow(actors); patrol = new Patroling(rectangles, actors, resetRectangle); rockHit = new RockHit(actors, grabThrow); checkWin = new CheckWin(actors); pursue = new Pursue(actors, state); }
void Start() { sameTypeConnectedBubbles = new List <GameObject>(); manager = GameObject.Find("BubbleManager"); manager.GetComponent <BubbleManager>().inGameBubbleList.Add(this.gameObject); checkLoss = manager.GetComponent <CheckWin>(); if (gameObject.transform.position.y < 6) { preset = false; } else { preset = true; } currentBody = gameObject.GetComponent <Rigidbody2D>(); }
public void Enter() { levelSndInstance = levelSnd.CreateInstance(); levelSndInstance.Play(); rectangles = state.levelManager.levels[1].rectangles; //gate gateRectangle = new RectangleObjects(336, 192, 72, 48); rectangles.Add(gateRectangle); //reset resetRectangle = new Rectangle(336, 662, 98, 10); keyRectangle = new Rectangle(360, 96, 48, 48); collide = new Collision(rectangles, actors, state); IList <Rectangle> winPosition = new List <Rectangle>(); winPosition.Add(new Rectangle(143, 143, 50, 50)); winPosition.Add(new Rectangle(191, 143, 50, 50)); winPosition.Add(new Rectangle(527, 143, 50, 50)); winPosition.Add(new Rectangle(575, 143, 50, 50)); winPosition.Add(new Rectangle(335, 383, 50, 50)); winPosition.Add(new Rectangle(383, 383, 50, 50)); checkWin = new CheckWin(winPosition, actors); }
void OnCollisionEnter2D(Collision2D bubbleCollision) { if (bubbleCollision.gameObject.tag.Equals(gameObject.tag)) { sameTypeConnectedBubbles.Add(bubbleCollision.gameObject); RyanBubble bubbleCheck; bubbleCheck = bubbleCollision.gameObject.GetComponent <RyanBubble>(); if (sameTypeConnectedBubbles.Count >= 2 && hasCollided == true) { CheckWin checkwin = manager.GetComponent <CheckWin>(); checkwin.callCheck(); foreach (GameObject bubble in sameTypeConnectedBubbles) { FindObjectOfType <AudioManager>().Play("Match"); //Play bubble-matched sound StartCoroutine(Delay()); Instantiate(popFX, transform.position, Quaternion.identity); //Instantiate Bubble po VFX particles Destroy(bubble); } Destroy(this.gameObject); } } if (bubbleCollision.gameObject.tag.Equals("Barrier")) { //Play bounce sound if collided with berrier FindObjectOfType <AudioManager>().Play("Bounce"); if (bubbleState == BubbleState.Movement) { bubbleState = BubbleState.Stopped; hasCollided = true; Destroy(currentBody); transform.localRotation = Quaternion.identity; Vector3 thePosition = transform.localPosition; thePosition.x = Mathf.Round(thePosition.x); thePosition.y = Mathf.Floor(thePosition.y); Debug.Log("[OnCollisionEnter] Before Round:" + thePosition); if (thePosition.y % 2 >= 1) { if (thePosition.x + horizontalOffset >= maximunHorizontalValue) { thePosition.x = maximunHorizontalValue; } else { thePosition.x += horizontalOffset; } } else { if (thePosition.x + horizontalOffset >= maximunHorizontalValue) { thePosition.x = maximunHorizontalValue - horizontalOffset; } } Debug.Log("[OnCollisionEnter]Position: " + Mathf.FloorToInt(thePosition.y) + " - " + 1 + " = " + (Mathf.FloorToInt(thePosition.y) - 1)); thePosition.y = verticalValues[(Mathf.FloorToInt(thePosition.y) - 1)]; Debug.Log("[OnCollisionEnter] After Round:" + thePosition); transform.localPosition = Vector3.one * 100; //The offset will be set in the returnCorrectPosition after check where bubble can be place. transform.localPosition = returnCorretPosition(thePosition); } } else if (bubbleCollision.gameObject.tag.Equals("Donut") || bubbleCollision.gameObject.tag.Equals("CupCake") || bubbleCollision.gameObject.tag.Equals("Candy")) { RyanBubble bubbleCheck; bubbleCheck = bubbleCollision.gameObject.GetComponent <RyanBubble>(); if (bubbleCheck.bubbleState == BubbleState.Stopped) { if (bubbleState == BubbleState.Movement) { bubbleState = BubbleState.Stopped; hasCollided = true; Destroy(currentBody); //Play shooting sound FindObjectOfType <AudioManager>().Play("Pop"); transform.localRotation = Quaternion.identity; Vector3 thePosition = transform.localPosition; thePosition.x = Mathf.Round(thePosition.x); thePosition.y = Mathf.Floor(thePosition.y); Debug.Log("[OnCollisionEnter] Before Round:" + thePosition); if (thePosition.y % 2 >= 1) { if (thePosition.x + horizontalOffset >= maximunHorizontalValue) { thePosition.x = maximunHorizontalValue; } else { thePosition.x += horizontalOffset; } } else { if (thePosition.x + horizontalOffset >= maximunHorizontalValue) { thePosition.x = maximunHorizontalValue - horizontalOffset; } } if (thePosition.y < 6) { Debug.Log("[OnCollisionEnter]End Game"); //SceneManager.LoadScene("GameOver"); //Play Lose Sound checkLoss.callLoss(); } Debug.Log("[OnCollisionEnter]Position: " + Mathf.FloorToInt(thePosition.y) + " - " + 1 + " = " + (Mathf.FloorToInt(thePosition.y) - 1)); thePosition.y = verticalValues[(Mathf.FloorToInt(thePosition.y) - 1)]; Debug.Log("[OnCollisionEnter] After Round:" + thePosition); transform.localPosition = Vector3.one * 100; //The offset will be set in the returnCorrectPosition after check where bubble can be place. transform.localPosition = returnCorretPosition(thePosition); } } } if (bubbleCollision.gameObject.tag.Equals("Side")) { //Play bounce sound if collided with berrier FindObjectOfType <AudioManager>().Play("Bounce"); Debug.Log("[OnCollisionEnter]Collision contacts: " + bubbleCollision.contacts[0].normal); currentBody.velocity = Vector3.Reflect(transform.localPosition, bubbleCollision.contacts[0].normal); } }
// 20190621: Changed FixedUPdate to update. private void Update() { FollowSpline(); if (_progress == 1 && currentSpline.name != "EndingSpline") { Collider[] colliders = Physics.OverlapSphere(gameObject.transform.position, checkSphereRadius); bool nextSplineSelected = false; // Switch to the next spline // For chapter 4: Check if a portal is reached. if (GameObject.Find("CheckWinController").GetComponent <CheckWin>().level.Contains("D")) { if (ReachedDiscontinuity(gameObject.transform.position.x)) { currentSpline = FindDestinationSpline(gameObject.transform.position.x); nextSplineSelected = true; } } if (!nextSplineSelected) { foreach (Collider collider in colliders) { if (collider.gameObject.name.Contains("Spline") && collider.gameObject.name != currentSpline.gameObject.name) { GameObject nextSplineObject = collider.gameObject; currentSpline = nextSplineObject.GetComponent <Spline>(); break; } } } _distance = currentSpline.GetTotalDistance(); _progress = 0; } else if (currentSpline.name == "EndingSpline") { // Ask scoreboard to display the end result. if (!endLevel) { GameObject.Find("TrackSound").GetComponent <ClickSound>().StopSound(); // Start displaying results. scoreboardButtons.SetActive(true); GameObject.Find("ScoreBar").GetComponent <Animator>().Play("pullDownScorePanel"); GameObject.Find("AccuracyBar").GetComponent <Animator>().Play("closeAccuracyPanel"); endLevel = true; if (GameObject.Find("CheckWinController").GetComponent <CheckWin>().win) { GameObject.Find("ResultMessage").GetComponent <TextMeshProUGUI>().text = "Cleared!"; // Start Confetti effect. gameObject.transform.GetChild(2).gameObject.SetActive(true); } else { GameObject.Find("ResultMessage").GetComponent <TextMeshProUGUI>().text = "Try again next time."; GameObject.Find("ButtonNextLevel").GetComponent <Button>().interactable = false; } GameObject.Find("DarkProgressBar").GetComponent <Animator>().Play("Idle"); string levelStr = GameObject.Find("CheckWinController").GetComponent <CheckWin>().level; int currentLevel = int.Parse(GameObject.Find("CheckWinController").GetComponent <CheckWin>().level.Substring(1)); int nextLevel = currentLevel + 1; string nextLevelStr = levelStr[0] + nextLevel.ToString(); if (!GameDataManager.currentPlayer.levelProgress.ContainsKey(nextLevelStr)) { GameObject.Find("ButtonNextLevel").GetComponent <Button>().interactable = false; GameObject.Find("FinishedAllLevelsText").GetComponent <TextMeshProUGUI>().text = "You have reached the end of this level. \nPlease return to the menu for more levels."; } CheckWin checkWinController = GameObject.Find("CheckWinController").GetComponent <CheckWin>(); if (checkWinController.win) { int starObtained = checkWinController.starCount; int scoreObtained = checkWinController.sumScore; Player currentPlayer = GameDataManager.currentPlayer; if (starObtained > GameDataManager.currentPlayer.levelStar[GameDataManager.currentLevel]) { // update highest star obtained GameDataManager.currentPlayer.levelStar[GameDataManager.currentLevel] = starObtained; } if (scoreObtained > GameDataManager.currentPlayer.levelHiScore[GameDataManager.currentLevel]) { // update highest score obtained GameDataManager.currentPlayer.levelHiScore[GameDataManager.currentLevel] = scoreObtained; } } GameDataManager.currentPlayer.SavePlayer(); } speed -= 0.5f; if (speed < 0) { speed = 0; } } }
public void InitWinCondition(CheckWin win) { win.Init(map, this); }