Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- public class ConjurationData : MonoBehaviour
- {
- public static ConjurationData Instance;
- //Indentificadores de cartas
- private int CardNumber;
- private WarriorObject[] WarriorDeck = new WarriorObject[5];
- private int cardIndex;
- private int currentCardId;
- //Variaveis dos jogadores
- private int _PlayerHealth;
- private int _PlayerCardCount;
- private int _EnemyHealth;
- //Variaveis de jogo
- private int maxCards;
- private float gameTime;
- private float conjurationTime;
- private bool hasGoneToBattle;
- //Garante persistencia entre as cenas
- void Awake()
- {
- if (Instance == null)
- {
- DontDestroyOnLoad(gameObject);
- Instance = this;
- }
- else if (Instance != this)
- {
- Destroy(gameObject);
- }
- }
- //Função de parametros da partida
- public void SetGameParameters(int nCards, int pLife, int gTime, int cTime)
- {
- maxCards = nCards;
- _PlayerHealth = pLife;
- _EnemyHealth = pLife;
- gameTime = gTime;
- conjurationTime = cTime;
- //Reseta o resto
- CardNumber = 0;
- Array.Clear(WarriorDeck, 0, 5);
- cardIndex = 0;
- currentCardId = 0;
- }
- public void ResetCardNumber()
- {
- CardNumber = 0;
- }
- public void SetHasGoneToBattle()
- {
- hasGoneToBattle = true;
- }
- public bool GetHasGoneToBattle()
- {
- return hasGoneToBattle;
- }
- ///Funções para acesso via mesa de conjuração
- public float GetConjurationTime()
- {
- return conjurationTime;
- }
- public int GetMaxCards()
- {
- return maxCards;
- }
- //Adciona carta no inventario (mesa de conjuração)
- public void AddCard(WarriorCard newCard, int inventoryIndex)
- {
- CardNumber++;
- WarriorDeck[inventoryIndex] = new WarriorObject(newCard.GetCardId(), newCard.GetCardPod(), newCard.GetCardCon(), newCard.GetCardMaxCon(), inventoryIndex);
- }
- public void ResetCardsDeck()
- {
- Array.Clear(WarriorDeck, 0, WarriorDeck.Length);
- }
- //atualiza as cartas depois que o combate é encerrado
- public void UpdateCard(BattleCard updCard, int inventoryIndex)
- {
- WarriorDeck[inventoryIndex] = new WarriorObject(updCard.GetId(), updCard.GetPod(), updCard.GetCon(), updCard.GetMaxCon(), inventoryIndex);
- }
- //Recupera uma carta
- public WarriorObject GetWarriorCard(int index)
- {
- return WarriorDeck[index];
- }
- //Retira uma carta (mesa de conjuração)
- public void RemoveCard(int inventoryIndex)
- {
- CardNumber--;
- WarriorDeck[inventoryIndex] = null;
- }
- public int GetCardNumber()
- {
- return CardNumber;
- }
- //Debug Function
- public void GetCardsPrint()
- {
- for (int i = 0; i < WarriorDeck.Length; i++)
- {
- if (WarriorDeck[i] == null)
- {
- print("carta " + i + ": Vazia");
- }
- else
- {
- print("Carta " + i + ": " + WarriorDeck[i].GetCardID());
- }
- }
- }
- //Funções de controle do jogador na mesa de batalha
- public void ReduceHealth()
- {
- if (_PlayerHealth == 0)
- {
- _PlayerHealth = 0;
- }
- else
- {
- _PlayerHealth--;
- }
- }
- public void ReduceEnemyHealth()
- {
- if (_EnemyHealth == 0)
- {
- _EnemyHealth = 0;
- }
- else
- {
- _EnemyHealth--;
- }
- }
- public int GetHealth()
- {
- return _PlayerHealth;
- }
- public int GetEnemyHealth()
- {
- return _EnemyHealth;
- }
- //Atualização das cartas do deck
- public void KillCard(int CardIndex)
- {
- CardNumber--;
- WarriorDeck[CardIndex] = null;
- }
- //Variaveis para mesa de batalha
- public float GetGameTime()
- {
- return gameTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment