using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewCardScript : MonoBehaviour
{
private Vector2 mousePos;
private Vector2 originalCardPosition;
private SpriteRenderer sprite; // LAYER TEST
private int sortingOrder; // LAYER TEST
//
//
public enum CardStates
{
MOVABLE,
NOTMOVABLE
}
public static CardStates currentCardState;
void Start()
{
sprite = GetComponent<SpriteRenderer>(); // LAYER TEST
// currentCardState = CardStates.MOVABLE; // needed? Remove later? Screws up order?
originalCardPosition = transform.position; // takes the original position of the card so it can snap back to it
}
void Update()
{
switch (currentCardState)
{
case (CardStates.MOVABLE):
Debug.Log("Movable");
break;
case (CardStates.NOTMOVABLE):
Debug.Log("NotMovable");
break;
}
}
private void OnMouseOver()
{
if (currentCardState == CardStates.MOVABLE)
{
transform.localScale = new Vector2(0.09f, 0.09f); // makes card a little bigger
if (Input.GetMouseButton(0) && transform.localScale == new Vector3(0.09f, 0.09f)) // if LMB is held then it will move //
{
sprite.sortingOrder = 10; // LAYER TEST
mousePos = Input.mousePosition;/////////////////////////////
mousePos = Camera.main.ScreenToWorldPoint(mousePos);// basically this whole thing moves the card along with your mouse when you hold down the LMB
transform.position = mousePos;//////////////////////////////
}
else
{
transform.position = originalCardPosition; // sets the card back into its original position so it doesn't stick in its mid air spot if you don't leave the border of the card
}
}
else
{
transform.localScale = new Vector2(0.07f, 0.07f);
transform.position = originalCardPosition;
}
}
private void OnMouseExit()
{
sprite.sortingOrder = 5; // LAYER TEST
if (currentCardState == CardStates.MOVABLE)
{
transform.localScale = new Vector2(0.07f, 0.07f); // when the cursor leaves the card then it shrinks back to normal size
transform.position = originalCardPosition; // when the cursor leaves it snaps back to its original position (taken in Void Start())
}
else
{
transform.localScale = new Vector2(0.07f, 0.07f);
transform.position = originalCardPosition; // sets the card back into its original position so it doesn't stick in its mid air spot if you don't leave the border of the card
}
}
private void OnTriggerEnter2D(Collider2D collision) // This method checks if the card hits the Earth Target (Earth Target is tagged "Finish"), it'll do whats in the if statement
{
if (collision.gameObject.tag == "Finish")
{
NewAGM.cardPlaysLeftThisTurn = NewAGM.cardPlaysLeftThisTurn - 1;
Destroy(gameObject); // gameObject.SetActive(false); (maybe this??) Could clog system with clones n stuff tho...
// Do each specific cards effect here (also dmg and heal)??????? Will this mess with cardPlaysLeftThisTurn
// add if card is this do this much dmg if this do this much blah blah blah
}
}
}
You are unlikely to get any responses because you have provided no context for your problem other than a code snippet that may or may not be relevant to your issue.