void Start() { p1 = (Piece1)FindObjectOfType(typeof(Piece1)); p2 = (Piece2)FindObjectOfType(typeof(Piece2)); p3 = (Piece3)FindObjectOfType(typeof(Piece3)); p4 = (Piece4)FindObjectOfType(typeof(Piece4)); button.SetActive(false); }
void Update() { if (fail == true) { Piece1.GetComponent <SpriteRenderer>().sprite = CrumbleWall; Piece2.GetComponent <SpriteRenderer>().sprite = CrumbleWall; Piece3.GetComponent <SpriteRenderer>().sprite = CrumbleWall; Piece4.GetComponent <SpriteRenderer>().sprite = CrumbleWall; Win = 0; } else if (p1 == true && p2 == true && p3 == true && p4 == true) { Piece1.GetComponent <SpriteRenderer>().sprite = FixWall; Piece2.GetComponent <SpriteRenderer>().sprite = FixWall; Piece3.GetComponent <SpriteRenderer>().sprite = FixWall; Piece4.GetComponent <SpriteRenderer>().sprite = FixWall; Win = 1; } else { if (p1 == true) { Piece1.GetComponent <SpriteRenderer>().sprite = FixWall; } if (p2 == true) { Piece2.GetComponent <SpriteRenderer>().sprite = FixWall; } if (p3 == true) { Piece3.GetComponent <SpriteRenderer>().sprite = FixWall; } if (p4 == true) { Piece4.GetComponent <SpriteRenderer>().sprite = FixWall; } p1 = Piece1.GetComponent <ClickItem>().Clicked; p2 = Piece2.GetComponent <ClickItem>().Clicked; p3 = Piece3.GetComponent <ClickItem>().Clicked; p4 = Piece4.GetComponent <ClickItem>().Clicked; fail = Back.GetComponent <ClickItem>().Clicked; } if (T < 0) { PlayerPrefs.SetInt("Result", Win); Back.GetComponent <PresentResults>().enabled = true; Back.GetComponent <GameWall>().enabled = false; } else { T = T - Time.deltaTime; } }
void Start() { ScoreText.enabled = false; LivesText.enabled = false; RuleText.enabled = false; Progress = 1; Win = 0; T = PlayerPrefs.GetFloat("PTime"); tt = T; p1 = Piece1.GetComponent <ClickItem>().Clicked; p2 = Piece2.GetComponent <ClickItem>().Clicked; p3 = Piece3.GetComponent <ClickItem>().Clicked; p4 = Piece4.GetComponent <ClickItem>().Clicked; fail = Back.GetComponent <ClickItem>().Clicked; }
private void CreateAllPieces() { var player = PlayerType.Player1; Pieces1 = new PieceBase[15]; for (int i = 0; i < 5; i++) { Pieces1[i] = new Piece1(player, i); PiecesObject1[i] = ObjectCreator.CreateInObject(PlayerGameObject[0], piecePrefabs[0]).GetComponent <PieceProvider>(); PiecesObject1[i].SetPieceUIInfo(player, i, PieceType.Piece1); } for (int i = 5; i < 9; i++) { Pieces1[i] = new Piece2(player, i); PiecesObject1[i] = ObjectCreator.CreateInObject(PlayerGameObject[0], piecePrefabs[1]).GetComponent <PieceProvider>(); PiecesObject1[i].SetPieceUIInfo(player, i, PieceType.Piece2); } for (int i = 9; i < 12; i++) { Pieces1[i] = new Piece3(player, i); PiecesObject1[i] = ObjectCreator.CreateInObject(PlayerGameObject[0], piecePrefabs[2]).GetComponent <PieceProvider>(); PiecesObject1[i].SetPieceUIInfo(player, i, PieceType.Piece3); } for (int i = 12; i < 14; i++) { Pieces1[i] = new Piece4(player, i); PiecesObject1[i] = ObjectCreator.CreateInObject(PlayerGameObject[0], piecePrefabs[3]).GetComponent <PieceProvider>(); PiecesObject1[i].SetPieceUIInfo(player, i, PieceType.Piece4); } Pieces1[14] = new Piece5(player, 14); PiecesObject1[14] = ObjectCreator.CreateInObject(PlayerGameObject[0], piecePrefabs[4]).GetComponent <PieceProvider>(); PiecesObject1[14].SetPieceUIInfo(player, 14, PieceType.Piece5); player = PlayerType.Player2; Pieces2 = new PieceBase[15]; for (int i = 0; i < 5; i++) { Pieces2[i] = new Piece1(player, i); PiecesObject2[i] = ObjectCreator.CreateInObject(PlayerGameObject[1], piecePrefabs[5]).GetComponent <PieceProvider>(); PiecesObject2[i].SetPieceUIInfo(player, i, PieceType.Piece1); } for (int i = 5; i < 9; i++) { Pieces2[i] = new Piece2(player, i); PiecesObject2[i] = ObjectCreator.CreateInObject(PlayerGameObject[1], piecePrefabs[6]).GetComponent <PieceProvider>(); PiecesObject2[i].SetPieceUIInfo(player, i, PieceType.Piece2); } for (int i = 9; i < 12; i++) { Pieces2[i] = new Piece3(player, i); PiecesObject2[i] = ObjectCreator.CreateInObject(PlayerGameObject[1], piecePrefabs[7]).GetComponent <PieceProvider>(); PiecesObject2[i].SetPieceUIInfo(player, i, PieceType.Piece3); } for (int i = 12; i < 14; i++) { Pieces2[i] = new Piece4(player, i); PiecesObject2[i] = ObjectCreator.CreateInObject(PlayerGameObject[1], piecePrefabs[8]).GetComponent <PieceProvider>(); PiecesObject2[i].SetPieceUIInfo(player, i, PieceType.Piece4); } Pieces2[14] = new Piece5(player, 14); PiecesObject2[14] = ObjectCreator.CreateInObject(PlayerGameObject[1], piecePrefabs[9]).GetComponent <PieceProvider>(); PiecesObject2[14].SetPieceUIInfo(player, 14, PieceType.Piece5); PutKings(); }