public void Draw() { if (currentDeck.Count != 0) { GameObject newCard = (GameObject)Instantiate(card, new Vector3(2.5f, -3.1f, 3), Quaternion.Euler(0f, 180f, 90f)); //GameObject newCard = (GameObject)Instantiate(card, new Vector3(12.5f, 1.1f, 0), Quaternion.identity); // instantiate at deck pile // transform 180 from back to show front // Transform to hand position Sc_Card newCardScript = newCard.GetComponent <Sc_Card>(); newCardScript.cardID = currentDeck[0]; currentDeck.RemoveAt(0); } else if (currentDiscard.Count > 0) // If there are no more cards in the deck, but there are cards in the dicards pile, the discard pile will become the deck and the deck will be shuffled { for (int i = 0; i < currentDiscard.Count; i++) { currentDeck.Add(currentDiscard[i]); } ShuffleDeck(); currentDiscard.Clear(); // Make discard pile invisable GameObject newCard = (GameObject)Instantiate(card, new Vector3(10.55f, 2.21f, 3), Quaternion.FromToRotation(new Vector3(0, 180, 90), new Vector3(0, 0, 0))); Sc_Card newCardScript = newCard.GetComponent <Sc_Card>(); newCardScript.cardID = currentDeck[0]; currentDeck.RemoveAt(0); } else { PrintLog("No Cards in deck or discard pile", "black"); } }
public void Load() { gameManager.isLoading = false; currentDeck = saveDataManager.saveData.currentDeckSave; currentDiscard = saveDataManager.saveData.currentDiscardSave; currentBanished = saveDataManager.saveData.currentBanishedSave; currentEffects = saveDataManager.saveData.currentEffectsSave; currentApUsed = saveDataManager.saveData.currentApUsedSave; currentUtilityAP = saveDataManager.saveData.currentUtilityAPSave; currentApMax = saveDataManager.saveData.currentApMaxSave; currentStage = 1; // Draw hand for (int i = 0; i < saveDataManager.saveData.currentHandObjectsSave.Count; i++) { Debug.Log(saveDataManager.saveData.currentHandObjectsSave[i]); GameObject newCard = (GameObject)Instantiate(card, new Vector3(2.50f, -3.1f, 3), Quaternion.Euler(0f, 180f, 90f)); Sc_Card newCardScript = newCard.GetComponent <Sc_Card>(); newCardScript.cardID = saveDataManager.saveData.currentHandObjectsSave[i]; } // Add saved armor cards into play for (int i = 0; i < saveDataManager.saveData.currentEquipmentArmorSave.Count; i++) { Debug.Log(saveDataManager.saveData.currentEquipmentArmorSave[i]); int idArmor = saveDataManager.saveData.currentEquipmentArmorSave[i]; Debug.Log(idArmor); if (idArmor < 2000) { SO_CardArmor card = cardDataBase.FindArmorCardByID(idArmor); Defence(idArmor, card.armorBonus, card.spickedBonus); PrintLog("you just played " + card.name, "green"); } } // Add saved melee cards into play for (int i = 0; i < saveDataManager.saveData.currentEquipmentMeleeSave.Count; i++) { Debug.Log(saveDataManager.saveData.currentEquipmentMeleeSave[i]); int idMelee = saveDataManager.saveData.currentEquipmentMeleeSave[i]; Debug.Log(idMelee); if (idMelee < 1000) // If the card is a melee card { SO_CardMelee card = cardDataBase.FindMeleeCardByID(idMelee); Melee(idMelee, card.normalDamage, card.bluntDamage, card.piercingDamage, card.poisonDamage); PrintLog("you just played " + card.name, "green"); } } // Draw hand for (int i = 0; i < gameManager.fullDeck.Count; i++) { currentDeck.Add(gameManager.fullDeck[i]); } }
public void DestroyCard() { Sc_BattleManager.currentHandObjects.RemoveAt(placementInHand - 1); _cards = GameObject.FindGameObjectsWithTag("Card"); for (int i = 0; i < _cards.Length; i++) { Sc_Card otherScript = _cards[i].GetComponent <Sc_Card>(); if (otherScript.placementInHand > placementInHand) { otherScript.placementInHand -= 1; } } Destroy(this.gameObject); }
public void Recycle(int cardsToTake) { if (currentDiscard.Count > 0) { for (int i = 0; i < cardsToTake; i++) { int random = Random.Range(0, currentDiscard.Count); GameObject newCard = (GameObject)Instantiate(card, transform.position, transform.rotation); Sc_Card newCardScript = newCard.GetComponent <Sc_Card>(); newCardScript.cardID = currentDiscard[random]; currentDiscard.RemoveAt(random); } } }
public void DiscardCards(int discard, bool isRandom) { if (isRandom == true) { for (int i = 0; i < discard; i++) { if (currentHandObjects.Count > 0) { // get random card in hand int random = Random.Range(0, currentHandObjects.Count); GameObject card = currentHandObjects[random]; Sc_Card cardScript = card.GetComponent <Sc_Card>(); currentDiscard.Add(cardScript.cardID); cardScript.DestroyCard(); } } } }
public void DiscardCardTransform() { Sc_BattleManager.currentHandObjects.RemoveAt(placementInHand - 1); _cards = GameObject.FindGameObjectsWithTag("Card"); for (int i = 0; i < _cards.Length; i++) { Sc_Card otherScript = _cards[i].GetComponent <Sc_Card>(); if (otherScript.placementInHand > placementInHand) { otherScript.placementInHand -= 1; } } if (this.transform.position.x != endPointDiscardX || this.transform.position.y != endPointDiscardY) { if (timer < 1) { timer += 0.5f; float newCurrentX = Mathf.Lerp(this.transform.position.x, endPointDiscardX, timer); float newCurrentY = Mathf.Lerp(this.transform.position.y, endPointDiscardY, timer); Vector3 newVector = new Vector3(newCurrentX, newCurrentY, placementInHand); transform.position = newVector; transform.localScale = new Vector3(4f, 4f, 0f); } else { Vector3 newVector = new Vector3(endPointDiscardX, endPointDiscardY, placementInHand); transform.position = newVector; transform.localScale = new Vector3(4f, 4f, 0f); } } else { timer = 0; } if (this.transform.position.x == endPointDiscardX && this.transform.position.y != endPointDiscardY) { Destroy(this.gameObject); } }
public void ExitBattle() { gameManager.fullDeck.Clear(); for (int i = 0; i < currentDeck.Count; i++) { gameManager.fullDeck.Add(currentDeck[i]); } for (int i = 0; i < currentDiscard.Count; i++) { gameManager.fullDeck.Add(currentDiscard[i]); } for (int i = 0; i < currentHandObjects.Count; i++) { GameObject card = currentHandObjects[i]; Sc_Card cardScript = card.GetComponent <Sc_Card>(); gameManager.fullDeck.Add(cardScript.cardID); } for (int i = 0; i < currentBanished.Count; i++) { gameManager.lostCards.Add(currentBanished[i]); } }
public void SaveGameData() { saveData.isNewGame = false; if (scene.name == "Battle") { saveData.currentDeckSave = battleManager.currentDeck; saveData.currentDiscardSave = battleManager.currentDiscard; saveData.currentBanishedSave = battleManager.currentBanished; saveData.currentStageSave = battleManager.currentStage; saveData.currentApUsedSave = battleManager.currentApUsed; saveData.currentUtilityAPSave = battleManager.currentUtilityAP; saveData.currentApMaxSave = battleManager.currentApMax; saveData.currentMonsterSave = battleManager.monster.monsterID; print("Monster id is " + battleManager.monster.monsterID); saveData.currentHandObjectsSave.Clear(); for (int i = 0; i < Sc_BattleManager.currentHandObjects.Count; i++) { cardInHand = Sc_BattleManager.currentHandObjects[i].GetComponent <Sc_Card>(); Debug.Log(cardInHand.cardID); saveData.currentHandObjectsSave.Add(cardInHand.cardID); } saveData.currentEquipmentArmorSave.Clear(); for (int i = 0; i < battleManager.currentEquipmentArmor.Count; i++) { armorEquipmentSave = battleManager.currentEquipmentArmor[i].GetComponent <Sc_DefenceEquipment>(); Debug.Log(armorEquipmentSave.id); saveData.currentEquipmentArmorSave.Add(armorEquipmentSave.id); } saveData.currentEquipmentMeleeSave.Clear(); for (int i = 0; i < battleManager.currentEquipmentMelee.Count; i++) { meleeEquipmentSave = battleManager.currentEquipmentMelee[i].GetComponent <Sc_MeleeEquipment>(); Debug.Log(meleeEquipmentSave.id); saveData.currentEquipmentMeleeSave.Add(meleeEquipmentSave.id); } saveData.currentEffectsSave.Clear(); for (int i = 0; i < battleManager.currentEffects.Count; i++) { effectSave = battleManager.currentEffects[i]; Debug.Log(effectSave); saveData.currentEffectsSave.Add(effectSave); } } if (scene.name == "Navigation" || scene.name == "Battle") { saveData.eventsDoneSave = gameManager.eventsDone; saveData.monsterDoneSave = gameManager.monsterDone; saveData.fullDeckSave = gameManager.fullDeck; saveData.slayCountSave = gameManager.slayCount; saveData.lostCardsSave = gameManager.lostCards; } if (scene.name == "Navigation") { saveData.firstEventSave = navManager.firstEvent; saveData.currentEventSave = gameManager.currentEvent; } SaveDataWrapper wrapper = new SaveDataWrapper(); wrapper.saveData = saveData; string contents = JsonUtility.ToJson(wrapper, true); System.IO.File.WriteAllText(path, contents); }
public void TakeDamage(int damage, int type) // type blunt = 0 normal = 1 piercing = 2 { for (int i = 0; i < damage; i++) // run though ones for every damage taken { int damageDealt = 0; if (type == 0 || type == 1) { if (currentTotalDefence > 0) { currentTotalDefence -= 1; damageDealt = 1; defenceText.text = "" + currentTotalDefence; if (currentEquipmentArmor.Count > 0) { Sc_DefenceEquipment ArmorScript = currentEquipmentArmor[0].GetComponent <Sc_DefenceEquipment>(); ArmorScript.defence -= 1; ArmorScript.UpdateText(); if (ArmorScript.defence <= 0) { // Sc_DefenceEquipment defenceScript = currentEquipmentArmor[i].GetComponent<Sc_DefenceEquipment>(); ArmorScript.moveToDiscard = true; // Destroy(currentEquipmentArmor[0]); currentEquipmentArmor.RemoveAt(0); GameObject[] _armor = GameObject.FindGameObjectsWithTag("Armor"); for (int j = 0; j < _armor.Length; j++) { Sc_DefenceEquipment otherScript = _armor[j].GetComponent <Sc_DefenceEquipment>(); otherScript.placementInEquipent -= 1; } } } } } if (type == 1 && damageDealt == 0 || type == 2) { if (currentDeck.Count > 0) // check if there are still cards in the deck { currentBanished.Add(currentDeck[0]); // if banished pile is > 0 then make banishpile visable // make discard pile sprite be last discarded card currentDeck.RemoveAt(0); } else if (currentDiscard.Count > 0) // Check if there are cards in discard pile. { PrintLog("Dicard pile is being shuffled into deck", "black"); for (int j = 0; j < currentDiscard.Count; j++) { currentDeck.Add(currentDiscard[j]); } ShuffleDeck(); currentDiscard.Clear(); currentBanished.Add(currentDeck[0]); // if banished pile is > 0 then make banishpile visable // make discard pile sprite be last discarded card currentDeck.RemoveAt(0); } else if (currentHandObjects.Count > 0) { int targetCard = Random.Range(0, currentHandObjects.Count); Destroy(currentHandObjects[targetCard]); currentHandObjects.RemoveAt(targetCard); GameObject[] _cards = GameObject.FindGameObjectsWithTag("Card"); for (int j = 0; j < _cards.Length; j++) { Sc_Card otherScript = _cards[j].GetComponent <Sc_Card>(); if (otherScript.placementInHand > targetCard + 1) { otherScript.placementInHand -= 1; } // if banished pile is > 0 then make banishpile visable // make discard pile sprite be last discarded card } } else { PrintLog("you lost", "red"); playerLost(); } } } }