public void fightAgainstNeighbours(int neighbour_up_id, int neighbour_down_id, int neighbour_left_id, int neighbour_right_id) { if (!script_enabled) { return; } Debug.Log("start fighting against neighbours"); Debug.Log("neighbour Down ID = " + neighbour_down_id); CardProperties card_property = GetComponent <CardProperties>(); CardProperties neighbour_card_property; //check if up neighbour even exists if (neighbour_up_id >= 1) { Debug.Log("neighbour slot exists"); GameObject found_neighbour_card; foreach (GameObject neighbour_slot in game_board_manager.slots) { //search for up neighbour in all slots if (neighbour_slot.GetComponent <SlotProperty>().getSlotID() == neighbour_up_id) { Debug.Log("neighbour slot found"); //does the neighbour slot has a card placed on it? if (neighbour_slot.transform.Find("Rahmen").childCount > 0) { found_neighbour_card = neighbour_slot.transform.Find("Rahmen").GetChild(0).gameObject; neighbour_card_property = found_neighbour_card.GetComponent <CardProperties>(); Debug.Log("placed Card value = " + card_property.up_value); Debug.Log("neighbour Card value = " + neighbour_card_property.up_value); //compare up neighbours value with placed card value //if placed card is stronger then assign the neighbour card to the placed card's owner if (card_property.up_value > neighbour_card_property.down_value) { neighbour_card_property.resetCurrentOwner(card_property.owner); game_board_manager.playTurnCardSound(); Debug.Log("placed Card value is greater than its up neighbour!!!!!!!!!"); } } } } } if (neighbour_down_id >= 1) { Debug.Log("neighbour down slot exists"); GameObject found_neighbour_card; foreach (GameObject neighbour_slot in game_board_manager.slots) { //search for up neighbour in all slots if (neighbour_slot.GetComponent <SlotProperty>().getSlotID() == neighbour_down_id) { Debug.Log("neighbour down slot found"); //does the neighbour slot has a card placed on it? if (neighbour_slot.transform.Find("Rahmen").childCount > 0) { found_neighbour_card = neighbour_slot.transform.Find("Rahmen").GetChild(0).gameObject; neighbour_card_property = found_neighbour_card.GetComponent <CardProperties>(); Debug.Log("placed Card value = " + card_property.down_value); Debug.Log("neighbour Card value = " + neighbour_card_property.down_value); //compare up neighbours value with placed card value //if placed card is stronger then assign the neighbour card to the placed card's owner if (card_property.down_value > neighbour_card_property.up_value) { neighbour_card_property.resetCurrentOwner(card_property.owner); game_board_manager.playTurnCardSound(); Debug.Log("placed Card value is greater than its down neighbour!!!!!!!!!"); } } } } } if (neighbour_left_id >= 1) { Debug.Log("neighbour slot exists"); GameObject found_neighbour_card; foreach (GameObject neighbour_slot in game_board_manager.slots) { //search for up neighbour in all slots if (neighbour_slot.GetComponent <SlotProperty>().getSlotID() == neighbour_left_id) { Debug.Log("neighbour slot found"); //does the neighbour slot has a card placed on it? if (neighbour_slot.transform.Find("Rahmen").childCount > 0) { found_neighbour_card = neighbour_slot.transform.Find("Rahmen").GetChild(0).gameObject; neighbour_card_property = found_neighbour_card.GetComponent <CardProperties>(); Debug.Log("placed Card value = " + card_property.left_value); Debug.Log("neighbour Card value = " + neighbour_card_property.right_value); //compare up neighbours value with placed card value //if placed card is stronger then assign the neighbour card to the placed card's owner if (card_property.left_value > neighbour_card_property.right_value) { neighbour_card_property.resetCurrentOwner(card_property.owner); game_board_manager.playTurnCardSound(); Debug.Log("placed Card value is greater than its left neighbour!!!!!!!!!"); } } } } } if (neighbour_right_id >= 1) { Debug.Log("neighbour slot exists"); GameObject found_neighbour_card; foreach (GameObject neighbour_slot in game_board_manager.slots) { //search for up neighbour in all slots if (neighbour_slot.GetComponent <SlotProperty>().getSlotID() == neighbour_right_id) { Debug.Log("neighbour slot found"); //does the neighbour slot has a card placed on it? if (neighbour_slot.transform.Find("Rahmen").childCount > 0) { found_neighbour_card = neighbour_slot.transform.Find("Rahmen").GetChild(0).gameObject; neighbour_card_property = found_neighbour_card.GetComponent <CardProperties>(); Debug.Log("placed Card value = " + card_property.right_value); Debug.Log("neighbour Card value = " + neighbour_card_property.right_value); //compare up neighbours value with placed card value //if placed card is stronger then assign the neighbour card to the placed card's owner if (card_property.right_value > neighbour_card_property.left_value) { neighbour_card_property.resetCurrentOwner(card_property.owner); game_board_manager.playTurnCardSound(); Debug.Log("placed Card value is greater than its right neighbour!!!!!!!!!"); } } } } } //after each fight against cards, check the current battle status ///////////////////////////////////////////////////////////////// game_board_manager.checkBattleStatus(); game_board_manager.switchPlayersTurn(); }