123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ModeController : MonoBehaviour
- {
-
-
- public GameObject Player;
- public GameObject Locations;
- public GameObject Editor;
- public GameObject EditorTools;
- public GameObject Plane;
- public GameObject Grid;
- public GameObject LineX;
- public GameObject LineY;
- public GameObject Markers;
- public GameObject Beacons;
- public GameObject Walls;
- public GameObject WallCursor;
- public GameObject Zones;
- Transform maps;
- public static bool editor = false;
- Button button;
- Dropdown.OptionData item;
-
- void Start()
- {
- button = gameObject.GetComponent<Button>();
- button.onClick.AddListener(() => {
- Switch();
- });
- if (editor) EditorMode();
- maps = Player.transform.Find("Dropdown_maps");
- }
-
- void Update()
- {
-
- }
- public void Switch()
- {
- editor = !editor;
- transform.GetChild(0).gameObject.SetActive(!editor);
- transform.GetChild(1).gameObject.SetActive(editor);
- if (editor)
- {
- Player.GetComponent<PlayerController>().StopProgress();
- EditorMode();
- }
- else PlayerMode();
- }
- void PlayerMode()
- {
- Player.SetActive(true);
-
- Markers.SetActive(true);
-
- Editor.SetActive(false);
- EditorTools.SetActive(false);
- Plane.SetActive(false);
- Grid.SetActive(false);
- Walls.SetActive(false);
- Zones.SetActive(false);
- Destroy(GameObject.Find("SizeX"));
- Destroy(GameObject.Find("SizeY"));
- maps.transform.SetParent(Player.transform);
- maps.transform.SetSiblingIndex(1);
- maps.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 200);
- if(item != null)maps.GetComponent<Dropdown>().options.Remove(item);
- maps.GetComponent<Dropdown>().value = 0;
- for (int i = 0; i < Beacons.transform.childCount; i++)
- {
- Beacons.transform.GetChild(i).GetComponent<BeaconController>().mode = BeaconController.Mode.Player;
- Beacons.transform.GetChild(i).GetComponent<LabelObjectScript>().enabled = true;
- }
- WallCursor.SetActive(false);
- GameObject old_button = null;
- switch (WallCreate.mode)
- {
- case WallCreate.Mode.Cursor:
- old_button =EditorTools.transform.GetChild(0).gameObject;
- break;
- case WallCreate.Mode.Room:
- old_button = EditorTools.transform.GetChild(1).gameObject;
- break;
- case WallCreate.Mode.Wall:
- old_button = EditorTools.transform.GetChild(2).gameObject;
- break;
- }
- if (old_button != null) old_button.GetComponent<Image>().color = Color.white;
-
-
-
-
- }
- void EditorMode()
- {
- Player.SetActive(false);
-
- Markers.SetActive(false);
-
- Editor.SetActive(true);
- EditorTools.SetActive(true);
- Plane.SetActive(true);
- Grid.SetActive(true);
- Walls.SetActive(true);
- Zones.SetActive(true);
- maps.transform.SetParent(Editor.transform);
- maps.transform.SetSiblingIndex(0);
- maps.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 190);
- item = new Dropdown.OptionData("Новая локация");
- maps.GetComponent<Dropdown>().options.Add(item);
- for (int i = 0; i < Beacons.transform.childCount; i++)
- {
- Beacons.transform.GetChild(i).GetComponent<BeaconController>().info = false;
- Beacons.transform.GetChild(i).GetComponent<BeaconController>().mode = BeaconController.Mode.Editor;
- Beacons.transform.GetChild(i).GetComponent<LabelObjectScript>().enabled = false;
- }
- var color = new Color();
- ColorUtility.TryParseHtmlString("#C8C8C8", out color);
- EditorTools.transform.GetChild(0).gameObject.GetComponent<Image>().color = color;
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
|