private GameObject CreateMagnus(string name) { GameObject magnus = (GameObject)Instantiate(magnusPrefab, Vector3.zero, Quaternion.identity); Magnus magnusScript = magnus.GetComponent <Magnus>(); for (int i = 0; i < magnusList.Length; i++) { if (magnusList[i] == name) { magnusScript.SetName(name); magnusScript.SetIsAtk(Convert.ToBoolean(GetPropertyValue(magnusList[++i]))); magnusScript.SetIsDef(Convert.ToBoolean(GetPropertyValue(magnusList[++i]))); magnusScript.SetIsHeal(Convert.ToBoolean(GetPropertyValue(magnusList[++i]))); magnusScript.SetIsFinisher(Convert.ToBoolean(GetPropertyValue(magnusList[++i]))); magnusScript.SetNeutralStat(Convert.ToInt32(GetPropertyValue(magnusList[++i]))); magnusScript.SetElementStat(Convert.ToInt32(GetPropertyValue(magnusList[++i]))); magnusScript.SetAtkCombo(Convert.ToInt32(GetPropertyValue(magnusList[++i]))); magnusScript.SetDefCombo(Convert.ToInt32(GetPropertyValue(magnusList[++i]))); magnusScript.SetElement(GetPropertyValue(magnusList[++i])); Sprite s = Resources.Load <Sprite>("Images/Magnus/" + name); magnusScript.SetGraphic(s); break; } } return(magnus); }
//Shifts cards in hand over to make space for newly drawn card. private void ShiftCards(int start, int end) { for (int i = start; i <= end; i++) { Magnus magnusScript = cards[i].GetComponent <Magnus>(); cards[i].transform.position = cards[i].transform.position - new Vector3(magnusScript.GetWidth(), 0, 0); } }
public MagnusCombo(Magnus hero) : base(hero) { this.Magnus = hero; this.StunHandler = UpdateManager.Run(this.AntiFail); this.SkewerHandler = UpdateManager.Run(this.SkewerStandalone); UpdateManager.Subscribe(OnUpdate, 25); }
//Set Magnus' valid state based on current battle round public void ValidateCard(GameObject card) { if (card != null) { Magnus cardScript = card.GetComponent <Magnus>(); if (isPlayerTurn) { //All cards are invalid if an invalid card was played during player turn if (playedInvalid) { cardScript.SetValid(false); } //def only magnus invalid else if (cardScript.GetIsDef() && !cardScript.GetIsAtk()) { cardScript.SetValid(false); } //atk combo too high else if (cardScript.GetAtkCombo() > currCombo) { cardScript.SetValid(false); } //heal magnus invalid after attacking or attack magnus after healing else if ((cardScript.GetIsHeal() && playedAttack) || (cardScript.GetIsAtk() && playedHeal)) { cardScript.SetValid(false); } else { cardScript.SetValid(true); } } else { //atk only magnus invalid //heal magnus invalid if (!cardScript.GetIsDef()) { cardScript.SetValid(false); } //def combo too high else if (cardScript.GetDefCombo() > currCombo) { cardScript.SetValid(false); } else { cardScript.SetValid(true); } } } }
private void AddToDeck() { if (deck.Count == 0) { deck.Add(new List <GameObject>()); } List <GameObject> lastRow = deck[deck.Count - 1]; //last row is full, add new row if (lastRow.Count == NUM_COLUMNS) { deck.Add(new List <GameObject>()); lastRow = deck[deck.Count - 1]; } //Add currently selected gathering card to deck, replace card in gathering with new card with same name lastRow.Add(gathering[currentRow][currentCol]); string magnusName = gathering[currentRow][currentCol].GetComponent <Magnus>().GetName(); Vector3 magnusPos = gathering[currentRow][currentCol].transform.position; gathering[currentRow][currentCol] = CreateMagnus(magnusName); gathering[currentRow][currentCol].transform.position = magnusPos; //Proper position for card in deck Magnus magnusScript = lastRow[lastRow.Count - 1].GetComponent <Magnus>(); float x = (lastRow.Count - 1) * (magnusScript.GetWidth() + 0.1f) + DECK_LEFT_BOUND; float y; if (deck[0].Count == 1) { y = TOP_BOUND - ((deck.Count - 1) * (magnusScript.GetHeight() + 0.5f)); } //deck section might be scrolled down, so TOP_BOUND is incorrect else { y = deck[0][0].transform.position.y - ((deck.Count - 1) * (magnusScript.GetHeight() + 0.5f)); } lastRow[lastRow.Count - 1].transform.position = new Vector3(x, y, 0); if (deck.Count - 1 > topDeckRow + 1) { magnusScript.Hide(); } deckCount++; deckText.text = "Deck: " + deckCount + "/" + MAX_DECK_SIZE; }
private void ShiftRows(bool shiftUp) { if (inGathering) { for (int row = 0; row < gathering.Count; row++) { for (int col = 0; col < gathering[row].Count; col++) { Magnus magnusScript = gathering[row][col].GetComponent <Magnus>(); if (shiftUp) { gathering[row][col].transform.position += new Vector3(0, magnusScript.GetHeight() + 0.5f, 0); } else { gathering[row][col].transform.position -= new Vector3(0, magnusScript.GetHeight() + 0.5f, 0); } } } } else { for (int row = 0; row < deck.Count; row++) { for (int col = 0; col < deck[row].Count; col++) { Magnus magnusScript = deck[row][col].GetComponent <Magnus>(); if (shiftUp) { deck[row][col].transform.position += new Vector3(0, magnusScript.GetHeight() + 0.5f, 0); } else { deck[row][col].transform.position -= new Vector3(0, magnusScript.GetHeight() + 0.5f, 0); } } } } }
private void ShowCurrentRows() { for (int row = 0; row < gathering.Count; row++) { bool showRow = (row == topGatheringRow) || (row == topGatheringRow + 1); for (int col = 0; col < gathering[row].Count; col++) { Magnus magnus = gathering[row][col].GetComponent <Magnus>(); if (showRow) { magnus.Show(); } else { magnus.Hide(); } } } for (int row = 0; row < deck.Count; row++) { bool showRow = (row == topDeckRow) || (row == topDeckRow + 1); for (int col = 0; col < deck[row].Count; col++) { Magnus magnus = deck[row][col].GetComponent <Magnus>(); if (showRow) { magnus.Show(); } else { magnus.Hide(); } } } }
private void SetDescription(GameObject card) { if (card != null) { Magnus cardScript = card.GetComponent <Magnus>(); string magnusName = cardScript.GetName().Replace("_", " "); string elementStat = cardScript.GetElementStat().ToString(); string totalStat = (cardScript.GetNeutralStat() + cardScript.GetElementStat()).ToString(); string element = cardScript.GetElement().ToString(); string effect = "ATK/DEF "; if (cardScript.GetIsHeal()) { effect = "Heals " + totalStat + " HP"; } else { if (element == "Neutral") { effect += totalStat; } else { effect += totalStat + " (" + element + " " + elementStat + ")"; } } bottomBar.GetChild(1).GetComponent <Text>().text = magnusName; bottomBar.GetChild(2).GetComponent <Text>().text = effect; } else { bottomBar.GetChild(1).GetComponent <Text>().text = ""; bottomBar.GetChild(2).GetComponent <Text>().text = ""; } }
public PlayedMagnus(Magnus magnus, int spiritNumber) { this.magnus = magnus; this.spiritNumber = spiritNumber; }
//Choose a card and its spirit number private void ChooseCard(int spiritNumberIndex) { //First card played cancels the timer for the player to make a move. if (!gameManager.GetFirstMoveDone()) { gameManager.SetFirstMoveDone(true); gameManager.SetTimeProcessed(); } numCardsPlayed++; Magnus magnus = selectedMagnus.GetComponent <Magnus>(); magnus.ChooseNumber(spiritNumberIndex); gameManager.PlayMagnus(new PlayedMagnus(magnus, magnus.GetSpiritNumber(spiritNumberIndex))); //Choosing a finisher special or an invalid Magnus ends the attack combo if (gameManager.GetIsPlayerTurn()) { if (!magnus.GetIsValid() || magnus.GetIsFinisher()) { SetCanSelect(false); } } //Move the Magnus to the appropriate space Transform playerCurrMagnus = currMagnusSpace.GetChild(0); if (playerCurrMagnus.childCount == 0) { selectedMagnus.transform.position = currMagnusSpace.position; selectedMagnus.transform.SetParent(playerCurrMagnus, true); selectedMagnus.transform.localScale = new Vector3(1, 1, 1); } else { selectedMagnus.transform.position = nextMagnusSpace.position; selectedMagnus.transform.SetParent(nextMagnusSpace, true); selectedMagnus.transform.localScale = new Vector3(1, 1, 1); SetCanSelect(false); //Magnus queue is full, wait to select more } cards.RemoveAt(currentPosition); ValidateHand(); //validate the hand after played card is removed from the hand //selected card not rightmost card in hand, shift cards on right normally and cursor position stays the same if (currentPosition != cards.Count) { ShiftCards(currentPosition, cards.Count - 1); MoveToPosition(currentPosition); } bool cardDrawn = DrawCard(); //cursor was rightmost, select newly drawn card if (cardDrawn && currentPosition == cards.Count - 1) { MoveToPosition(currentPosition); } //cursor was rightmost and no new card drawn, move cursor left if (!cardDrawn && currentPosition == cards.Count) { //no more cards in hand if (currentPosition == 0) { SetDescription(null); Hide(); } else { MoveToPosition(currentPosition - 1); } } }