Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class CardScript : NetworkBehaviour
- {
- public GameObject center;
- public Game _game;
- public GameObject _singleton;
- public Singleton _singletonScript;
- public GameObject[] Players;
- public GameObject Player;
- public Player _player;
- private SpriteRenderer spriteColor;
- public int C;
- public string cardName;
- public int cardScore;
- public int cardRank;
- public string cardSuit;
- public string turn;
- public bool isPossible;
- public bool spawnedCard;
- public bool deletedCard;
- public bool cat;
- public int whichCard;
- void Start ()
- {
- isPossible = false;
- deletedCard = false;
- cat = false;
- whichCard = 5;
- _game = GameObject.Find("Game").GetComponent<Game>();
- _singleton = GameObject.Find("SINGLETON");
- _singletonScript = _singleton.GetComponent<Singleton>();
- spriteColor = gameObject.GetComponent<SpriteRenderer>();
- turn = "First";
- if (Players != null)
- {
- Players = GameObject.FindGameObjectsWithTag("Player");
- }
- }
- void Update ()
- {
- if (Players != null)
- {
- Players = GameObject.FindGameObjectsWithTag("Player");
- }
- if (gameObject.name == "1(Clone)" || gameObject.name == "5(Clone)" || gameObject.name == "9(Clone)" || gameObject.name == "13(Clone)" || gameObject.name == "21(Clone)" || gameObject.name == "25(Clone)" || gameObject.name == "29(Clone)")
- {
- if (_singletonScript.RoundTrump == "Clubs")
- {
- cardSuit = "Trump";
- }
- else
- {
- cardSuit = "Clubs";
- }
- }
- else if (gameObject.name == "4(Clone)" || gameObject.name == "8(Clone)" || gameObject.name == "12(Clone)" || gameObject.name == "16(Clone)" || gameObject.name == "24(Clone)" || gameObject.name == "28(Clone)" || gameObject.name == "32(Clone)")
- {
- if (_singletonScript.RoundTrump == "Spades")
- {
- cardSuit = "Trump";
- }
- else
- {
- cardSuit = "Spades";
- }
- }
- else if (gameObject.name == "3(Clone)" || gameObject.name == "7(Clone)" || gameObject.name == "11(Clone)" || gameObject.name == "15(Clone)" || gameObject.name == "23(Clone)" || gameObject.name == "27(Clone)" || gameObject.name == "31(Clone)")
- {
- if (_singletonScript.RoundTrump == "Hearts")
- {
- cardSuit = "Trump";
- }
- else
- {
- cardSuit = "Hearts";
- }
- }
- else if (gameObject.name == "2(Clone)" || gameObject.name == "6(Clone)" || gameObject.name == "10(Clone)" || gameObject.name == "14(Clone)" || gameObject.name == "22(Clone)" || gameObject.name == "26(Clone)" || gameObject.name == "30(Clone)")
- {
- if (_singletonScript.RoundTrump == "Diamonds")
- {
- cardSuit = "Trump";
- }
- else
- {
- cardSuit = "Diamonds";
- }
- }
- else if (gameObject.name == "17(Clone)" || gameObject.name == "18(Clone)" || gameObject.name == "19(Clone)" || gameObject.name == "20(Clone)")
- {
- cardSuit = "Trump";
- }
- if (_singletonScript.Turn != "First" && _singletonScript.playerMass[0] == _singletonScript._yourName)
- {
- whichCard = 0;
- }
- else if (_singletonScript.Turn != "Second" && _singletonScript.playerMass[1] == _singletonScript._yourName)
- {
- whichCard = 0;
- }
- else if (_singletonScript.Turn != "Third" && _singletonScript.playerMass[2] == _singletonScript._yourName)
- {
- whichCard = 0;
- }
- else if (_singletonScript.Turn != "Fourth" && _singletonScript.playerMass[3] == _singletonScript._yourName)
- {
- whichCard = 0;
- }
- else if (spawnedCard == true)
- {
- whichCard = 0;
- }
- else if (deletedCard == true)
- {
- whichCard = 0;
- }
- else if (_singletonScript.playerMass[0] == _singletonScript._yourName && _singletonScript.Turn == "First" && deletedCard != true && spawnedCard != true)
- {
- whichCard = 1;
- }
- else if (_singletonScript.FirstCardSuit == cardSuit && cardSuit != "Trump")
- {
- whichCard = 1;
- }
- else
- {
- whichCard = 3;
- }
- if (whichCard == 0)
- {
- isPossible = false;
- }
- if (isPossible)
- {
- spriteColor.color = new Color(1f, 1f, 1f, 1f);
- }
- else if (!isPossible && spawnedCard == false)
- {
- spriteColor.color = new Color(0.3f, 0.3f, 0.3f, 1f);
- }
- }
- public int playerNumber;
- private void OnMouseDown()
- {
- if (isPossible)
- {
- if (_singletonScript.playerMass[0] == _singletonScript._yourName && _singletonScript.Turn == "First")
- {
- playerNumber = 1;
- Player.GetComponent<Player>().isCardTouched = true;
- Player.GetComponent<Player>().centerCardName = cardName;
- Player.GetComponent<Player>().stopper = 1;
- Player.GetComponent<Player>().num = 1;
- deletedCard = true;
- gameObject.transform.position = new Vector3(-100, 0, 0);
- }
- if (_singletonScript.playerMass[1] == _singletonScript._yourName && _singletonScript.Turn == "Second")
- {
- Player.GetComponent<Player>().isCardTouched = true;
- Player.GetComponent<Player>().centerCardName = cardName;
- Player.GetComponent<Player>().stopper = 1;
- Player.GetComponent<Player>().num = 2;
- deletedCard = true;
- gameObject.transform.position = new Vector3(-100, 0, 0);
- }
- if (_singletonScript.playerMass[2] == _singletonScript._yourName && _singletonScript.Turn == "Third")
- {
- Player.GetComponent<Player>().isCardTouched = true;
- Player.GetComponent<Player>().centerCardName = cardName;
- Player.GetComponent<Player>().stopper = 1;
- Player.GetComponent<Player>().num = 3;
- deletedCard = true;
- gameObject.transform.position = new Vector3(-100, 0, 0);
- }
- if (_singletonScript.playerMass[3] == _singletonScript._yourName && _singletonScript.Turn == "Fourth")
- {
- Player.GetComponent<Player>().isCardTouched = true;
- Player.GetComponent<Player>().centerCardName = cardName;
- Player.GetComponent<Player>().stopper = 1;
- Player.GetComponent<Player>().num = 4;
- deletedCard = true;
- gameObject.transform.position = new Vector3(-100, 0, 0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement