Advertisement
Guest User

tile manager

a guest
Mar 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Assertions;
  5. using Photon;
  6.  
  7. public class Tile_Manager : Photon.MonoBehaviour {
  8.  
  9. #region Public Variables
  10. public static Tile_Manager instance;
  11. public float delta;// how far to move it from its inital postion
  12. public float speed;// how fast the object is to be moved
  13. public float timeToStartShake;// is time between every shake, every movemnt of the object every change in its position
  14. public float timeToShake;// the time we use to continue our loop for the shaking
  15. public float countDownToFall;
  16. public float countDownToRise;
  17. public bool flagTest;
  18. public GameObject[] temp;
  19. #endregion Private Variables
  20.  
  21. #region Private and Portected Variables
  22. private Vector3 startpos;
  23. private Vector3 defaultpos;
  24. public List<Tile> tiles = new List<Tile>();
  25. public Tile myTile=null;
  26. #endregion
  27.  
  28. #region Unity Functions
  29. private void Start()
  30. {
  31. temp = GameObject.FindGameObjectsWithTag("Tile");
  32. foreach (GameObject tile in temp)
  33. {
  34. //if (!tiles.Contains(tile))
  35. //tiles.Add(tile);
  36. tiles.Add(new Tile(tile));
  37. }
  38. }
  39. private void Awake()
  40. {
  41. instance = this;
  42.  
  43. flagTest = false;
  44. }
  45. #endregion
  46.  
  47. #region My Functions
  48. public void ShakeTile(Tile tileToShake)
  49. {
  50. startpos.x+=delta*Mathf.Sin(speed*Time.time);
  51. tileToShake.myTile.gameObject.transform.position=startpos;
  52. tileToShake.timeToShake--;
  53. //return tileToShake;
  54. }
  55. #endregion
  56.  
  57. #region Coroutines
  58. public IEnumerator DroppingTile(string myTileName)
  59. {
  60. Debug.Log("This gets reached");
  61. GameObject thisTile;
  62. <<<<<<< HEAD
  63. thisTile=GameObject.Find(myTileName);
  64. Debug.Log(thisTile);
  65. // myTile= new Tile (thisTile);
  66. =======
  67. thisTile = GameObject.Find(myTileName);
  68. myTile= new Tile (thisTile);
  69. >>>>>>> c9df56224b18ce0e5d49cedaf618f262dae8a340
  70. myTile.myTile=thisTile;
  71. flagTest = false;
  72. //startpos=myTile.myTile.transform.position;
  73. //defaultpos=myTile.myTile.transform.position;
  74.  
  75. // while (true)
  76. // {
  77. // for(int i=0; i<myTile.timeToShake; i++)
  78. // {
  79. // ShakeTile(myTile);
  80. // yield return new WaitForSeconds(myTile.timeToStartShake);
  81. // }
  82. // break;
  83. // }
  84.  
  85. yield return new WaitForSeconds(myTile.countDownToFall);
  86. Debug.Log("This gets dropped");
  87. myTile.myTile.gameObject.SetActive(false);
  88. yield return new WaitForSeconds(myTile.countDownToRise);
  89. Debug.Log("This gets raised");
  90. //myTile.myTile.transform.position=defaultpos;
  91. myTile.myTile.gameObject.SetActive(true);
  92. myTile.timeToShake=30;
  93. }
  94. #endregion
  95.  
  96. #region RPC
  97. [PunRPC]
  98. public void CallDropTile(string inputName)
  99. {
  100. StartCoroutine(DroppingTile(inputName));
  101. }
  102.  
  103. public void CallDropRPC(string nameToPass)
  104. {
  105. if(flagTest == false)
  106. {
  107. flagTest = true;
  108. photonView.RPC("CallDropTile", PhotonTargets.All, nameToPass);
  109. }
  110. }
  111.  
  112. }
  113. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement