private void destroingCard(GameObject go) { CardBihevior ACard = go.GetComponent <CardBihevior>(); ACard.SetState(CardState.death); float[] fc = ACard.getPosition(); GameObject Splash1 = Instantiate(PartSys, new Vector3(fc[0], fc[1], 0), Quaternion.identity) as GameObject; Destroy(Splash1, 3.5f); Destroy(go, 1.6f); }
//private functions private void score4cards(GameObject bufCard1, GameObject bufCard2) { CardBihevior ACard = BufCard1.GetComponent <CardBihevior>(); CardBihevior BCard = BufCard2.GetComponent <CardBihevior>(); int fCardClick = ACard.GetCliks(); int sCardClick = BCard.GetCliks(); int c = (fCardClick * 5) + (sCardClick * 5) - 10; c = 30 - c; if (c <= 0) { c = 0; } lightAdd(BufCard1.name, ACard.getELight()); Score += c; }
//private void LockAllCards(bool b) //{ // ///Locking or Unlocking all cards by putting bool charakter // // for (int j = 0; j < 25; j++) // { // if (SetOfCard[j] != null) // { // CardBihevior Card = SetOfCard[j].GetComponent<CardBihevior>(); // Card.SetBlock(b); // } // // } //} private void CheckOfArkan(GameObject go) { CardBihevior bihevCard = go.GetComponent <CardBihevior>(); float[] position = bihevCard.getPosition(); int chanseOption = UnityEngine.Random.Range(0, 100); chanseOption = (chanseOption % 2 == 0) ? chanseOption = 0 : chanseOption = 1; byte number = 0; int addScore = 0; byte arcan = 0; switch (go.name) { case "moon(Clone)": //количество открытых карт break; case "sun(Clone)": GameObject[] cardSunOpen = new GameObject[5]; foreach (GameObject cO in SetOfCard) { if (cO != null) //find cards in the line { if (chanseOption == 0) { if (go.transform.position.x == cO.transform.position.x & cO.GetInstanceID() != go.GetInstanceID() & cO != null) { cardSunOpen[number] = cO; number++; //& cO.GetInstanceID() != go.GetInstanceID() & number >= cardSunOpen.Length } } else { if (go.transform.position.y == cO.transform.position.y & cO.GetInstanceID() != go.GetInstanceID() & cO != null) { //& cO.GetInstanceID() != go.GetInstanceID() & number >= cardSunOpen.Length cardSunOpen[number] = cO; number++; } } } } if (BufCard1 != null) { if (BufCard1.GetInstanceID() != go.GetInstanceID()) { int co = 0; foreach (GameObject soc in cardSunOpen) { if (soc == null) { break; } else { co++; } if (soc.GetInstanceID() == BufCard1.GetInstanceID()) { co = 0; break; } } if (co > 0) { cardSunOpen[co] = BufCard1; } foreach (GameObject cso in cardSunOpen) { if (cso != null) { //if (cso.GetInstanceID() != BufCard1.GetInstanceID() & cso.name == BufCard1.name) //{ // destroingCard(BufCard1); // BufCard1 = null; // destroingCard(cso); // scoreArcan4cards(20); // break; //} } } } } //samecards in line destroy for (int i = 0; i < cardSunOpen.Length; i++) { for (int j = 0; j < cardSunOpen.Length; j++) { if (cardSunOpen[i] != null & cardSunOpen[j] != null) { if (cardSunOpen[i].GetInstanceID() != cardSunOpen[j].GetInstanceID() & cardSunOpen[i].name == cardSunOpen[j].name) { destroingCard(cardSunOpen[i]); destroingCard(cardSunOpen[j]); cardSunOpen[j] = null; cardSunOpen[i] = null; scoreArcan4cards(20); } } } } //othercard for para foreach (GameObject cso in cardSunOpen) { foreach (GameObject co in SetOfCard) { if (co != null & cso != null) { if (co.name == cso.name & co.GetInstanceID() != cso.GetInstanceID()) { destroingCard(cso); destroingCard(co); scoreArcan4cards(20); break; } } } } destroingCard(go); BufCard1 = null; BufCard2 = null; LockAllCards(false); break; case "star(Clone)": //количество открытых карт break; case "tower(Clone)": //количество открытых карт break; } switch (deletedCards) { case 0: addScore = arcan * 10; break; case 24: addScore = arcan * 10; break; default: if (arcan > 0) { addScore = deletedCards * 10; } break; } Score += addScore; }
private void publishCards() { byte[,] MapOfCards = makeMapOfCards(progress.getCardData());//Map of cards and emount of it that will be playing //Set patron Arcan as 25th card SetOfCard[24] = HighArcCard[UnityEngine.Random.Range(0, HighArcCard.Length)]; //Kreation map array for (int i = 0; i < 12; i++) { switch (MapOfCards[i, 1]) { case 0: SetOfCard[i] = CupArcCard[MapOfCards[i, 0]]; SetOfCard[i + 12] = CupArcCard[MapOfCards[i, 0]]; break; case 1: SetOfCard[i] = PentArcCard[MapOfCards[i, 0]]; SetOfCard[i + 12] = PentArcCard[MapOfCards[i, 0]]; break; case 2: SetOfCard[i] = SwordArcCard[MapOfCards[i, 0]]; SetOfCard[i + 12] = SwordArcCard[MapOfCards[i, 0]]; break; case 3: SetOfCard[i] = WandArcCard[MapOfCards[i, 0]]; SetOfCard[i + 12] = WandArcCard[MapOfCards[i, 0]]; break; } } //Перемешивание карт for (int i = 0; i < 25; i++) { GameObject tmp = SetOfCard[i]; int r = UnityEngine.Random.Range(i, SetOfCard.Length); SetOfCard[i] = SetOfCard[r]; SetOfCard[r] = tmp; } float xpos = cardSizeX * -2; //3f; float ypos = cardSizeY * -2; //-4.4f; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { float[] posit = new float[2] { xpos + (cardSizeX * i), ypos + (cardSizeY * j) }; int num = i * 5 + j; SetOfCard[num] = Instantiate(SetOfCard[num], new Vector3(posit[0], posit[1], 0), Quaternion.identity) as GameObject; CardBihevior CardBH = SetOfCard[num].GetComponent <CardBihevior>(); CardBH.StartPosition(posit); CardBH.SetLinkToCard(SetOfCard[num]); cbs.rost(SetOfCard[num].transform); } } setX = cardSizeX / 2 * (1 - 0.61f); wcard = cardSizeX * 5 + 6 * setX; hcard = cardSizeY * 5 + 6 * setX; }
void LateUpdate() { //Updating data of game updateSave(); setDisplayParam(); float[] a = { setX, setY }; //Set card position whith steps cards deletedCards = 0; foreach (GameObject child in SetOfCard) { if (child != null) { CardBihevior ChildBihevior = child.GetComponent(typeof(CardBihevior)) as CardBihevior; float[] cardPos = ChildBihevior.getPosition(); a[0] = (cardPos[0] / cardSizeX) * setX; a[1] = (cardPos[1] / cardSizeY) * setY; ChildBihevior.SetPosition(a); } else { deletedCards++; } } if (BufCard1 != null) { CardBihevior FirstChosenCard = BufCard1.GetComponent <CardBihevior>(); CheckOfArkan(BufCard1); //print("allo0"); //if (FirstChosenCard.Openstate()) //{ // // LockAllCards(false); // // print("allo"); //} //else //{ // //print("allo1"); // LockAllCards(true); //} } if (BufCard2 != null) { CardBihevior SecondChosenCard = BufCard2.GetComponent <CardBihevior>(); CheckOfArkan(BufCard2); //if (SecondChosenCard.Openstate()) //{ // LockAllCards(false); // //} //else //{ // // LockAllCards(true); //} } //sravnenie of cards if (BufCard1 != null & BufCard2 != null) { LockAllCards(true); CardBihevior ACard = BufCard1.GetComponent <CardBihevior>(); CardBihevior BCard = BufCard2.GetComponent <CardBihevior>(); if ((ACard.currentState == CardState.block & BCard.currentState == CardState.block) | (ACard.currentState == CardState.open & BCard.currentState == CardState.open)) { if (BufCard1.name == BufCard2.name) //Если две карты одинаковые. { //destruction score4cards(BufCard1, BufCard2); // make own procedure for single card //get light only once destroingCard(BufCard1); destroingCard(BufCard2); tries++; } if (BufCard1.name != BufCard2.name) { ACard.SetState(CardState.close); BCard.SetState(CardState.close); tries--; } BufCard1 = null; BufCard2 = null; } } //else //{ // // LockAllCards(false); //} }