Example #1
0
    // Use this for initialization
    void Start()
    {
        player    = 1;
        img       = cross;
        gridScr   = new GridScript();
        modelScr  = new ModelScript();
        gamePanel = gridScr.CreatePanel(gameObject, "GameGrid", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                        new Vector2(100, 50), new Vector2(-100, -50), false, new Vector2(400, 400), new Vector3(-75, 0, 0), spr, new Color32(100, 200, 100, 0));
        menuPanel = gridScr.CreatePanel(gameObject, "MenuPanel", new Vector2(1.0f, 0.5f), new Vector2(1.0f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                        new Vector2(0, 0), new Vector2(0, 0), false, new Vector2(160, 320), new Vector3(-80, 0, 0), spr, new Color32(255, 255, 255, 0));
        gameButtonList = gridScr.FillWithButtons(gamePanel, 3, 3, spr);
        menuButtonList = gridScr.FillWithButtons(menuPanel, 1, 2, spr);

        menuButtonList[0].GetComponent <Button>().image.sprite = reload;
        menuButtonList[1].GetComponent <Button>().image.sprite = exit;

        menuButtonList[0].GetComponent <Button>().onClick.AddListener(
            delegate { SceneManager.LoadScene(SceneManager.GetActiveScene().name); }
            );
        menuButtonList[1].GetComponent <Button>().onClick.AddListener(delegate { Application.Quit(); });

        action act = new action(ButtonAction);

        gridScr.SetAction(gameButtonList, act);
    }
    // Use this for initialization
    void Start()
    {
        model    = gameObject.AddComponent <ModelScript>();
        view     = gameObject.AddComponent <ViewScript>();
        soundScr = gameObject.AddComponent <SoundScript>();

        Invoke("SetUpGame", 0.1f);
    }
Example #3
0
    public void Initialize()
    {
        model      = this.transform.Find("Model").gameObject.GetComponent <ModelScript>(); // Nice Unity object referencing
        view       = this.transform.Find("View").gameObject.GetComponent <ViewScript>();
        controller = this.transform.Find("Controller").gameObject.GetComponent <ControllerScript>();

        if (model == null)
        {
            throw new KeyNotFoundException("Failed to assign \"ModelScript\"");
        }
        if (view == null)
        {
            throw new KeyNotFoundException("Failed to assign \"ViewScript\"");
        }
        if (controller == null)
        {
            throw new KeyNotFoundException("Failed to assign \"ControllerScript\"");
        }

        DoBindings();
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        guiScr    = new GuiScript();
        modelScr  = new ModelScript(CELL_COUNT);
        gamePanel = guiScr.CreatePanel(gameObject, "GamePanel", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                       new Vector2(400, 400), new Vector2(0, 0), spr, new Color32(0, 150, 120, 255));
        menuPanel = guiScr.CreatePanel(gameObject, "MenuPanel", new Vector2(1, 1), new Vector2(1, 1), new Vector3(1, 1, 1), new Vector3(0, 0, 0),
                                       new Vector2(100, 200), new Vector2(-60, -110), spr, new Color32(255, 255, 255, 0));
        tab      = guiScr.FillWithButtons(gamePanel, 4, 4, 100, 100, spr, new Color32(255, 255, 255, 255));
        menuButt = guiScr.FillWithButtons(menuPanel, 1, 2, 100, 100, spr, new Color32(255, 255, 255, 255));
        tex      = guiScr.SetText(modelScr.Table, CELL_COUNT, tab);
        menuTex  = guiScr.SetMenuText(menuButt);

        onClick = new action(Execute);

        guiScr.SetAction(tab, onClick);

        menuButt[0, 0].GetComponent <Button>().onClick.AddListener(delegate
                                                                   { SceneManager.LoadScene(SceneManager.GetActiveScene().name); });
        menuButt[0, 1].GetComponent <Button>().onClick.AddListener(delegate
                                                                   { Application.Quit(); });
    }
    public override void OnInspectorGUI()
    {
        model = (ModelScript)target;

        if (GUILayout.Button("1. Parse Elements"))
        {
            model.ParseElements();
        }

        GUILayout.Space(10);

        if (!tcpClient.IsActive)
        {
            if (GUILayout.Button("2. Connect to TCP Server"))
            {
                tcpClient.ConnectToServer();
            }
        }
        else
        {
            GUI.enabled = tcpClient.IsActive;
            if (GUILayout.Button("2. Disconnect from TCP Server"))
            {
                tcpClient.DisconnectToServer();
            }
        }

        GUI.enabled = tcpClient.IsActive;
        if (GUILayout.Button("2.1 Stop Listening Message"))
        {
            SendStopListeningMessage();
        }

        GUILayout.Space(10);

        GUI.enabled = true;


        //if (GUILayout.Button("Update Glass Panels"))
        //{
        //    UpdatePanels();
        //}

        GUI.enabled = tcpClient.IsActive;

        EditorGUI.BeginDisabledGroup(!tcpClient.IsActive);

        if (GUILayout.Button("3. Gather Elements Info"))
        {
            GatherElementsInfo();
        }

        model.UpdateMaterials = EditorGUILayout.Toggle("Update Materials", model.UpdateMaterials);
        if (GUILayout.Button("4. Gather Materials"))
        {
            GatherMaterials();
        }

        EditorGUI.EndDisabledGroup();

        GUILayout.Space(10);

        GUI.enabled = model.materialsLoaded;

        if (GUILayout.Button("5. Apply Default Materials"))
        {
            ApplyMaterials();
        }

        GUI.enabled = model.elementsLoaded;

        if (GUILayout.Button("6. Update Door Elements"))
        {
            UpdateDoorElements();
        }

        //if (GUILayout.Button("7. Add Lights"))
        //{
        //    AddLights();
        //}

        GUILayout.Space(10);

        GUI.enabled = true;

        model.DebugMode = EditorGUILayout.Toggle("Debug Mode", model.DebugMode);

        if (model.DebugMode)
        {
            DrawDefaultInspector();
        }
    }
Example #6
0
 public void OnPointerDown(PointerEventData eventData)
 {
     ModelScript.AStarClick();
 }
Example #7
0
 void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
 {
     ModelScript.Randomize();
 }
Example #8
0
 private void ChangeStartEndClick(Vector2Int coord)
 {
     ModelScript.SetStartEndPoint(coord);
 }
Example #9
0
 private void ChangeObstacleClick(Vector2Int coord)
 {
     ModelScript.AddRemoveObstacle(coord);
 }
Example #10
0
 public void SetModeScript(ModelScript model)
 {
     this.model = model;
 }
Example #11
0
 private void Awake()
 {
     NewMethod();
     ms = FindObjectOfType <ModelScript>();
 }