ShowTurnPlayerObject.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ShowTurnPlayerObject : MonoBehaviour
  6. {
  7. public Image BackGround;
  8. public Text TurnPlayerText;
  9. public bool isClose { get; set; }
  10. public void Init()
  11. {
  12. Off();
  13. }
  14. public void ShowTurnPlayer(Player turnPlayer)
  15. {
  16. if (turnPlayer.isYou)
  17. {
  18. TurnPlayerText.text = "Your Turn";
  19. BackGround.color = new Color32(121, 153, 255, 222);
  20. }
  21. else
  22. {
  23. TurnPlayerText.text = "Opponent's Turn";
  24. BackGround.color = new Color32(255, 131, 121, 222);
  25. }
  26. isClose = false;
  27. this.gameObject.SetActive(true);
  28. StartCoroutine(CloseCoroutine());
  29. }
  30. IEnumerator CloseCoroutine()
  31. {
  32. GetComponent<Animator>().SetInteger("Close", 0);
  33. yield return new WaitForSeconds(0.3f);
  34. GetComponent<Animator>().SetInteger("Close", 1);
  35. }
  36. public void Off()
  37. {
  38. this.gameObject.SetActive(false);
  39. isClose = true;
  40. }
  41. }