SHARE
TWEET

PlayAreaManager

a guest Feb 15th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayAreaManager : MonoBehaviour
  6. {
  7.     [SerializeField]
  8.     private int playerMana; //Determines the player's mana
  9.     [SerializeField]
  10.     private Cards selectedCard; //A "get" to determine which card is being attempted to cast by the player Used ONLY if card is cast and everything is fine
  11.     private DragDrop draggerControl;
  12.     public GameObject cardContainer;
  13.  
  14.         void OnCollisionEnter(Collision other)
  15.         {
  16.             cardContainer = other.gameObject;
  17.             draggerControl = cardContainer.GetComponent<DragDrop>();
  18.             selectedCard = cardContainer.GetComponent<CardStartSprite>().card;
  19.         }
  20.  
  21.         private void Update()
  22.         {
  23.             if (draggerControl != null)
  24.             {
  25.                 if (draggerControl.playAllowed && draggerControl.castChecker)
  26.                 {
  27.                     manaCheck();
  28.                 }
  29.             }
  30.         }
  31.  
  32.         void manaCheck()
  33.         {
  34.                 if (selectedCard.manaCost > playerMana)
  35.                 {
  36.                     Debug.Log("Failed to cast " + selectedCard.name + "!");
  37.                     draggerControl.ResetPos();
  38.                     cardContainer = null;
  39.                     draggerControl = null;
  40.                 }
  41.                 if (selectedCard.manaCost <= playerMana)
  42.                 {
  43.                     Debug.Log("You have cast " + selectedCard.name + "!");
  44.                     cardContainer = null;
  45.                     draggerControl = null;
  46.                 }
  47.         }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top