public void ShowMarket(UEO_MarketObject[] items)
    {
        if (!showing)
        {
            showing = true;
            MouseLockCursor.ShowCursor(true, "market show");
            Player.inst.FreezePlayer();
            marketParent.GetComponent <SinPop>().Begin();
            foreach (Transform t in itemListParent)
            {
                Destroy(t.gameObject);                 // clear old market.
            }
            foreach (UEO_MarketObject mo in items)
            {
                // instantiate a new item for each sale item in this market.
                GameObject   p    = (GameObject)Instantiate(marketObjectPrefab.gameObject);
                MarketUIItem item = p.GetComponent <MarketUIItem>();
                //			Debug.Log("item:"+mo.name);
                //			Debug.Log(",p:"+p);
                //			Debug.Log(",item:"+item);
                item.name.text  = mo.itemName;
                item.item       = mo;           // the prefab reference?
                item.price.text = mo.price.ToString();
                item.transform.SetParent(itemListParent);
                item.transform.localScale = Vector3.one;
                item.icon.sprite          = mo.icon;
            }

            // Resize content window to let all contents be visible by scrolling
            ScrollRect sr         = GetComponentInChildren <ScrollRect>();
            float      itemHeight = 90f;
            sr.content.sizeDelta = new Vector2(sr.content.sizeDelta.x, 400 + Mathf.Max(0, (items.Length - 2) * itemHeight));
        }
    }
 void Start()
 {
     MouseLockCursor.ShowCursor(false, "ghost");
     LevelBuilder.inst.camUI.enabled  = false;
     LevelBuilder.inst.camSky.enabled = false;
     LevelBuilder.inst.eventSystem.SetActive(false);
 }
Beispiel #3
0
    public void HidePauseMenu(bool force = false)
    {
        if (!paused && !force)
        {
            return;
        }
        Inventory.inst.UpdateBeltPosition();
        MouseLockCursor.ShowCursor(false, "HIDE PAUSE");
//		Inventory.inst.ShowInventory(true);
        Time.timeScale = 1;
//		Inventory.inst.beltParent.gameObject.SetActive(true);
//		Inventory.inst.ShowInventory(true);
        paused = false;
        pauseMenu.GetComponent <ShrinkAndDisable>().Begin();
//		Time.timeScale = 1;
//		Camera.main.GetComponent<AudioListener>().pause = false;
//		AudioListener.pause = false;
        if (Player.inst)
        {
            Player.inst.UnfreezePlayer("PAUSE un-pressed.");
        }
        foreach (CCText t in pauseMenu.GetComponentsInChildren <CCText>())
        {
            t.enabled = false;             // an unfortunate, fragile, way to disable all cctext when pause menu is being closed so that those CCText do not appear "on top" of other ui elements
            // they will appear "on top" because we moved CCText towards the camear in Z-plane in pause menu so that they would be displayed correctly to user
            // We use CCText with real Z position here because Unity's UI text does not scale correctly and looks weird kearning/thickness at large scales
        }
    }
    public void SetPlayerState(PlayMode mode)
    {
        if (mode == PlayMode.Editor)
        {
            PlayerVehicleController.inst.SetPlayerVehicleState(PlayMode.Editor);
            PlayerUnderwaterController.inst.SetPlayerUnderwater(false);
            Player.inst.FreezePlayer("Level builder shown.");
            MouseLockCursor.ShowCursor(true, "levelbuilder show");
            Player.inst.transform.localScale = Vector3.one * 2;
//			Camera.main.enabled = false;
            MainCameraCullingManager.inst.SetCameraMode(PlayMode.Editor);
//			Camera
            Player.inst.Unparent();
            GameManager.inst.GameFrozen = true;
        }
        else if (mode == PlayMode.Player)
        {
            Player.inst.transform.localScale = Vector3.one;
            GameManager.inst.GameFrozen      = false;
            MouseLockCursor.ShowCursor(false, "LB Hide");
            Player.inst.UnfreezePlayer();
//			CanvasMouseController.inst.ShowRetrapMouseDialogue();//"Play mode","Press TAB to get back to the editor later.");
            MainCameraCullingManager.inst.SetCameraMode(PlayMode.Player);
//			Camera.main.enabled = true;
        }
    }
    public void EndEditing()
    {
        MouseLockCursor.ShowCursor(false, "end edit dan meyer cube");
        LevelBuilder.inst.RestrictInput(false);
//		LevelBuilder.inst.overrideLevelBuilderMouseEvents = false;
        // todo potential bug, what if the object closes or is destroyed while right mouse button held down (stacked mouselocks?)
        editing = false;
        editorCameraParent.gameObject.SetActive(false);
    }
 void OnDestroy()
 {
     EditorTesting.inst.crudeGhostBlocker.SetActive(false);
     MouseLockCursor.ShowCursor(true, "ghost");
     LevelBuilder.inst.camUI.enabled  = true;
     LevelBuilder.inst.camSky.enabled = true;
     LevelBuilder.inst.eventSystem.SetActive(true);
     LevelBuilder.inst.SnapPanToPosition(transform.position);
 }
 public void ShowControls()
 {
     if (!controlsDialogue.activeSelf)
     {
         controlsDialogue.SetActive(true);
         Player.inst.FreezePlayerFreeLook();
         MouseLockCursor.ShowCursor(true, "controls open");
         Player.inst.FreezePlayer("showcontrols");
         Inventory.inst.DisableBelt();
     }
 }
    public void CloseControlsDialogue()
    {
        if (controlsDialogue.activeSelf)
        {
//			Inventory.inst.UpdateBeltPosition
            Inventory.inst.UpdateBeltPosition();
            controlsDialogue.SetActive(false);
            Player.inst.UnfreezePlayer("contr closed");
            Player.inst.UnfreezePlayerFreeLook();
            MouseLockCursor.ShowCursor(false, "controls closed");
        }
    }
    public void BeginEditing()
    {
        MouseLockCursor.ShowCursor(true, "begin edit dan meyer cube");
//		LevelBuilder.inst.overrideLevelBuilderMouseEvents = true;
//		LevelBuilder.inst.camSky.enabled = false;
//		LevelBuilder.inst.camUI.enabled = false;
//		LevelBuilder.inst.mode = LBMode.EditingSeparately;
        LevelBuilder.inst.RestrictInput(true);
        editing = true;
        editorCameraParent.gameObject.SetActive(true);
        UpdateCountText();
    }
 public void HideMarket()
 {
     if (showing)
     {
         showing = false;
         Player.inst.UnfreezePlayer();
         MouseLockCursor.ShowCursor(false, "market hide");
         // not used, market is closed only by "leave market" button?!
         // Use INTERFACE to close all IMyCloseableUI
         marketParent.GetComponent <ShrinkAndDisable>().Begin();
         //		marketParent.SetActive(false);
     }
 }
    public void HidePlayerDialogue()
    {
        if (!showing)
        {
            return;
        }
        Inventory.inst.UpdateBeltPosition();
        showing = false;
        playerDialogue.GetComponent <ShrinkAndDisable>().Begin();
//		AudioListener.pause = false;
        MouseLockCursor.ShowCursor(false, "hide player dialogue");
        Player.inst.UnfreezePlayer("Player Dialogue hidden.");
    }
Beispiel #12
0
    public void ShowPauseMenu()
    {
        // TODO we really need a DIALOGUE MANAGER.
//		Debug.Log("show");
        if (paused)
        {
            return;
        }
        if (!GameManager.inst.gameStarted)
        {
            return;
        }
        Inventory.inst.DisableBelt();

        Inventory.inst.HideInventory(true);
        if (!GameManager.inst.CanDisplayDialogue())
        {
            return;
        }
        MarketUI.inst.HideMarket();         // ugh use interface for closing all these.

        pauseMenu.GetComponent <SinPop>().Begin();
        Time.timeScale = 0;
//		WebGLComm.inst.Debug("paused at "+Time.time+", scale : 0");
//		tryResume = false;
        if (LevelBuilder.inst)
        {
            if (LevelBuilder.inst.levelBuilderIsShowing)
            {
                return;
            }
        }
//		Debug.Log("pause true");
        paused = true;
        PlayerDialogue.inst.HidePlayerDialogue();
        CanvasMouseController.inst.CloseCanvasMouseDialogue();
        CanvasMouseController.inst.CloseControlsDialogue();
        CanvasMouseController.inst.ClosePlayerStartDialogue();

//		AudioListener.pause = true;
        MouseLockCursor.ShowCursor(true, "SHOW PAUSE");
        Player.inst.FreezePlayer("PAUSE presesed.");
        foreach (CCText t in pauseMenu.GetComponentsInChildren <CCText>())
        {
            t.enabled = true;
        }
//		Player.
//		// commented Debug.Log("paused..");
    }
Beispiel #13
0
    public void ShowBig(string text, Texture icon, float extraTime = 1)
    {
        if (showingbig)
        {
            return;
        }
        Hide();
        showingbig = true;
//		// commented Debug.Log ("Show big");
        MouseLockCursor.ShowCursor(true, "helpbig");

        bigBox.SetActive(true);
        TypewriterSay(bigCCText, text, extraTime);
        bigIcon.material.mainTexture = icon;
    }
    public void ShowPlayerDialogue(string messageSmall, string messageBig, Sprite sprite = null)
    {
        if (showing)
        {
            return;
        }
        Inventory.inst.DisableBelt();

        if (sprite)
        {
            iconImage.sprite = sprite;
            iconImage.color  = Color.white;
        }
        else
        {
            iconImage.sprite = null;
            iconImage.color  = Color.white;
        }


        if (LevelBuilder.inst)
        {
            if (LevelBuilder.inst.levelBuilderIsShowing)
            {
                return;
            }
        }
        showing = true;
        playerDialogue.GetComponent <SinPop>().Begin();
        displayedMessageSmall.Text = messageSmall;
        displayedMessageBig.Text   = messageBig;
//		AudioListener.pause = true;
        MouseLockCursor.ShowCursor(true, "show player dialogue");
        Player.inst.FreezePlayer("Player Dialogue shown.");
//		Player.
//		// commented Debug.Log("showing..");
    }
Beispiel #15
0
    public void ShowCursor(string f)
    {
        bool flag = f == "true";

        MouseLockCursor.ShowCursor(flag, "external");
    }
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            UpdateClickableStateForAllCubes();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (rotating)
            {
                MouseLockCursor.ShowCursor(true, "end edit dan meyer cube while rotating");
            }
            lm.EndEditing();             // will disable this object, preventing further updates from happening after the following return; statement
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            mouseLook.enabled = true;
            rotating          = true;    // mouse look
            MouseLockCursor.ShowCursor(false, "eidting dan meyer cube");
        }
        if (Input.GetMouseButtonUp(1))
        {
            mouseLook.enabled = false;
            rotating          = false;
            MouseLockCursor.ShowCursor(true, "eidting dan meyer cube");
        }

        if (rotating)
        {
            return;
        }

//		RaycastHit[] hits;
        List <DanMeyerCube> cubesToAffect = new List <DanMeyerCube>();

        foreach (RaycastHit hit in Physics.RaycastAll(cam.ScreenPointToRay(Input.mousePosition), 300))
        {
            DanMeyerCube dmc = hit.collider.GetComponent <DanMeyerCube>();
//			if (!dmc) {
//				// maybe they clicked the toggle!
//				UIBooleanSlider =
//			}
            if (dmc)
            {
                // we are hovering over a cube while in editing mode.
                // Hotkeys are SHIFT, ALT, CTRL for columns, x rows, z rows
                foreach (DanMeyerCube dm2 in lm.cubes)
                {
                    // columns let's say
                    // get all cubes in this column.
                    if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftAlt))
                    {
                        //ALL of them.
//						if ((int)dm2.indexedPosition.y == (int)dmc.indexedPosition.y  (int)dm2.indexedPosition.z == (int)dmc.indexedPosition.z){
                        cubesToAffect.Add(dm2);
                        LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
//						}
                    }
                    else if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.LeftControl))
                    {
                        // HORIZONTAL PLANE
                        if ((int)dm2.indexedPosition.y == (int)dmc.indexedPosition.y)
                        {
                            cubesToAffect.Add(dm2);
                            LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.LeftAlt))
                    {
                        // VERTICAL Z PLANE
                        if ((int)dm2.indexedPosition.z == (int)dmc.indexedPosition.z)
                        {
                            cubesToAffect.Add(dm2);
                            LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftAlt))
                    {
                        // VERTICAL X PLANE
                        if ((int)dm2.indexedPosition.x == (int)dmc.indexedPosition.x)
                        {
                            cubesToAffect.Add(dm2);
                            LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftShift))
                    {
                        // Z ROW ONLY

                        if ((int)dm2.indexedPosition.y == (int)dmc.indexedPosition.y && (int)dm2.indexedPosition.z == (int)dmc.indexedPosition.z)
                        {
                            cubesToAffect.Add(dm2);
                            LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftControl))
                    {
                        // X ROW ONLY
                        if ((int)dm2.indexedPosition.x == (int)dmc.indexedPosition.x && (int)dm2.indexedPosition.y == (int)dmc.indexedPosition.y)
                        {
                            cubesToAffect.Add(dm2);
                            LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
                        }
                    }
                    else if (Input.GetKey(KeyCode.LeftAlt))
                    {
                        // COLUMN ONLY
                        if ((int)dm2.indexedPosition.x == (int)dmc.indexedPosition.x && (int)dm2.indexedPosition.z == (int)dmc.indexedPosition.z)
                        {
                            cubesToAffect.Add(dm2);
                            LevelBuilder.inst.MakeHighlightFX2(dm2.transform, "dan meyer cube high");
                        }
                    }
                }
                if (cubesToAffect.Count == 0)
                {
                    // no hotkeys pressed so we didn't add the "focus" cube under the mouse cursor.
                    cubesToAffect.Add(dmc);
                    LevelBuilder.inst.MakeHighlightFX2(dmc.transform, "dan meyer cube high");
                }
                if (Input.GetMouseButtonDown(0))
                {
//					Debug.Log("<color=#00f>Affecting</color>Affecting:"+cubesToAffect.Count+"cubes.");
                    bool active = !slider.GetSliderValue();                     // cache this value for .000001s savings. By the way slider value == true is DESTROY in this setup.
                    foreach (DanMeyerCube dm3 in cubesToAffect)
                    {
                        if (active)
                        {
                            dm3.TurnCubeOff(active);                                 // note we are comparing ONLY the active value of the exact hovering cube, so all column/row cubes are set to the SAME bool value, not "flipped"
                        }
                        else
                        {
                            dm3.TurnCubeOn(active);
                        }
                    }
                    lm.UpdateCountText();
                }
                break;                 // the foreach doesn't continue after this.
            }
        }
    }
Beispiel #17
0
 public void PlayerPressedStart(string flag)
 {
     MouseLockCursor.ShowCursor(false, "web gl player pressed start");
 }
 public void SetInstance()
 {
     inst = this;
 }