示例#1
0
    public void Select()
    {
        GameObject Canvas = GameObject.Find("BuilderGUICanvas(Clone)");

        //If you've clicked on a UI element then you didn't mean to click the terrain
        for (int i = 0; i < Canvas.transform.childCount; i++)
        {
            if (Canvas.transform.GetChild(i).name == "RR")
            {
                break;                                              //because RR covers the whole screen
            }
            RectTransform RT           = Canvas.transform.GetChild(i).GetComponent <RectTransform>();
            Vector3[]     worldCorners = new Vector3[4];
            RT.GetWorldCorners(worldCorners);
            if (Input.mousePosition.x >= worldCorners[0].x && Input.mousePosition.x < worldCorners[2].x &&
                Input.mousePosition.y >= worldCorners[0].y && Input.mousePosition.y < worldCorners[2].y)
            {
                return;
            }
        }
        foreach (PlaceableObject p in Scenery.Instance.Objects)
        {
            p.HideAllGizmos();
            p.DeselectClickColliders();
        }
        try { BezCtrlPt.Current.goRdMkr.GetComponent <RoadMarker>().Gizmo.SetActive(false); }
        catch { }
        Toolbox = Canvas.GetComponent <ToolboxController>();
        Toolbox.SetToolToggle("Scenery", false);
        ShowGizmo(Toolbox.Gizmo);
        Current = this;
        SelectClickColliders();
    }
示例#2
0
 protected virtual void Dispose(bool b)
 {
     HideAllGizmos();
     RemoveGameObject();
     System.GC.Collect();
     Toolbox          = null;
     mtlClickCollider = null;
 }
示例#3
0
    public void Select()
    {
        try
        {
            PlaceableObject.Current.HideAllGizmos();
            PlaceableObject.Current.EnableClickColliders();
        }
        catch { }

        Material[] Mats;
        Material   Mat;

        //Deselect the current roadmarker
        if (BezCtrlPt.Current != null)
        {
            if (BezCtrlPt.Current.goRdMkr != null)
            {
                Mats    = BezCtrlPt.Current.goRdMkr.GetComponentInChildren <MeshRenderer>().sharedMaterials;
                Mat     = (Material)Resources.Load("Prefabs/Materials/Orange", typeof(Material));
                Mats[1] = Mat;
                BezCtrlPt.Current.goRdMkr.GetComponentInChildren <MeshRenderer>().sharedMaterials = Mats;
                BezCtrlPt.Current.goRdMkr.GetComponent <RoadMarker>().Gizmo.SetActive(false);
                BezCtrlPt.Current.goRdMkr.GetComponent <RoadMarker>().GizmoBankL.SetActive(false);
                BezCtrlPt.Current.goRdMkr.GetComponent <RoadMarker>().GizmoBankR.SetActive(false);
                BezCtrlPt.Current.goRdMkr.GetComponent <RoadMarker>().Selected = false;
            }
        }
        Selected = true;
        CtrlPt.Select();    //sets th Current CtrlPt and Current Line;
        Mats    = BezCtrlPt.Current.goRdMkr.GetComponentInChildren <MeshRenderer>().sharedMaterials;
        Mat     = (Material)Resources.Load("Prefabs/Materials/BrightGreen", typeof(Material));
        Mats[1] = Mat;
        GetComponentInChildren <MeshRenderer>().sharedMaterials = Mats;
        Gizmo.SetActive(true);
        Gizmo.transform.rotation = Quaternion.identity;
        if (CtrlPt.SegStartIdx < Road.Instance.XSecs.Count)     //put this in because the GizmoBank was failing on the last CtrlPt
        {
            GizmoBankR.SetActive(true);
            GizmoBankR.GetComponent <GizmoBank>().Init();
            GizmoBankL.SetActive(true);
            GizmoBankL.GetComponent <GizmoBank>().Init();
            _bc.LerpTowards(BezCtrlPt.Current.Pos + Vector3.up * 10);
        }
        ToolboxController tbc = GameObject.Find("BuilderGUICanvas(Clone)").GetComponent <ToolboxController>();

        tbc.SetToolToggle("RoadSectn", false);
        tbc.ShowInsertButton(true);
        if (Road.Instance.Sectns[CtrlPt.CtrlPtId].RoadMaterial != null)
        {
            tbc.ShowRoadToolOptionForSelectedSection(ShopItemType.Road, Road.Instance.Sectns[CtrlPt.CtrlPtId].RoadMaterial);
        }
        tbc.ShowRoadToolOptionForSelectedSection(ShopItemType.Fence, Road.Instance.Sectns[CtrlPt.CtrlPtId].LFenceType, "L");
        tbc.ShowRoadToolOptionForSelectedSection(ShopItemType.Fence, Road.Instance.Sectns[CtrlPt.CtrlPtId].RFenceType, "R");
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        _canvas    = GameObject.Find("BuilderGUICanvas(Clone)");
        BuilderCam = GameObject.Find("BuilderCamera").GetComponent <Camera>();
        Toolbox    = _canvas.GetComponent <ToolboxController>();
        Toolbox.ToolOptionChanged += ToolChange;
        Bez = BezierLine.Instance;
        Rd  = Road.Instance;
        if (Road.Instance.Segments.Count == 0 || Road.Instance.Segments[0].goSeg == null)    //Cos When they might already be built
        {
            if (Road.Instance.StartingLinePos != null)
            {
                PlaceStartingLine(Road.Instance.StartingLineSegIdx);
            }
        }
        Bez.CreateGameObject();
        Bez.DrawLine();
        if (GameData.current.MacId == SystemInfo.deviceUniqueIdentifier)
        {
            Bez.CreateRoadMarkers();
        }
        //Open the tutorial if building first track
        if (SaveLoadModel.savedGames.Count < 3)     //!!!!!change to 3
        {
            UnityEngine.Object objPnl1 = Resources.Load("Prefabs/pnlTutorialBuild1");
            GameObject         goVid   = (GameObject)(GameObject.Instantiate(objPnl1, _canvas.transform));
            goVid.transform.localScale = Vector3.one;
            goVid.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
        }

        //Open the turorial panel so you can say how many cones left
        UnityEngine.Object objPnl = Resources.Load("Prefabs/pnlTutorialBuild2");
        GameObject         goTut  = (GameObject)(GameObject.Instantiate(objPnl, _canvas.transform));

        Tut = goTut.GetComponent <Tutorial>();
        Tut.transform.localScale = Vector3.one;
        Tut.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
        Tut.gameObject.SetActive(false);
    }