WallsController.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class WallsController : MonoBehaviour
  8. {
  9. //public Button ButtonWall;
  10. //public Button ButtonRoom;
  11. //public Button ButtonDel;
  12. public GameObject Cursor;
  13. public int Rounding = 1;
  14. public List<GameObject> Walls = new List<GameObject>();
  15. enum Tools { Wall, Room, Del, Cursor};
  16. Tools tools = Tools.Cursor;
  17. private Vector3 screenPoint;
  18. private Vector3 offset;
  19. private Vector3 curScreenPoint;
  20. private Vector3 curPosition;
  21. bool new_well = false;
  22. // Start is called before the first frame update
  23. void Start()
  24. {
  25. }
  26. // Update is called once per frame
  27. void Update()
  28. {
  29. }
  30. public void WallCreate()
  31. {
  32. tools = Tools.Wall;
  33. Cursor.SetActive(true);
  34. var last = Walls.LastOrDefault();
  35. if(last != null)last.GetComponent<Room>().BoxColliderEnabled = false;
  36. }
  37. public void RoomCreate()
  38. {
  39. tools = Tools.Room;
  40. var Cube = Instantiate(Resources.Load("GameObjects/Cube", typeof(GameObject))) as GameObject;
  41. Cube.AddComponent<Room>();
  42. Cube.transform.position = new Vector3(0.5f, 0.5f, 0.5f);
  43. new_well = true;
  44. Walls.Add(Cube);
  45. Cursor.SetActive(false);
  46. }
  47. public void Delete()
  48. {
  49. tools = Tools.Del;
  50. }
  51. void Editor()
  52. {
  53. switch (tools)
  54. {
  55. case Tools.Room:
  56. var Cube = Instantiate(Resources.Load("GameObjects/Cube", typeof(GameObject))) as GameObject;
  57. Cube.AddComponent<Room>();
  58. Walls.Add(Cube);
  59. break;
  60. }
  61. }
  62. //void OnMouseDown()
  63. //{
  64. // //Debug.Log(StagesEditorController.indexCursor);
  65. // switch (tools)
  66. // {
  67. // case Tools.Room:
  68. // screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
  69. // offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
  70. // break;
  71. // }
  72. //}
  73. // Перемещение
  74. }