Exemple #1
0
    private void endDialogue(int answer = 0, bool soundOnClose = true)
    {
        // strange behavior here when tasks are checkpointed, look into this when bugs arise
        if (answer == 0)
        {
            if (OnDialogueCancel != null)
            {
                OnDialogueCancel.Invoke();
            }

            DialogueViewTransitionOut();
        }

        if (window)
        {
            window.playSoundOnClose = soundOnClose;
            window.CloseUI();
            Destroy(window.transform.root.gameObject);
        }

        if (OnDialogueEnd != null)
        {
            // Debug.Log(OnDialogueEnd);
            OnDialogueEnd.Invoke(answer);
        }
    }
Exemple #2
0
    void FixedUpdate()
    {
        CalculateWindowEnabled();
        Vector3 mousePos = Input.mousePosition;

        mousePos.z -= Camera.main.transform.position.z;
        mousePos    = Camera.main.ScreenToWorldPoint(mousePos);
        if (cursor.type == ObjectTypes.Platform)
        {
            mousePos.x = cursorOffset.x + tileSize * (int)((mousePos.x - cursorOffset.x) / tileSize + (mousePos.x / 2 > 0 ? 0.5F : -0.5F));
            mousePos.y = cursorOffset.y + tileSize * (int)((mousePos.y - cursorOffset.y) / tileSize + (mousePos.y / 2 > 0 ? 0.5F : -0.5F));
        }
        else
        {
            mousePos.x = 0.5F * tileSize * Mathf.RoundToInt((mousePos.x) / (0.5F * tileSize));
            mousePos.y = 0.5F * tileSize * Mathf.RoundToInt((mousePos.y) / (0.5F * tileSize));
        }

        if (Input.GetKeyDown("g") && !windowEnabled)
        {
            mainMenu.ToggleActive();
            if (mainMenu.gameObject.activeSelf)
            {
                coreEditor.gameObject.SetActive(false);
            }
        }
        else
        {
            /*if(Input.GetKeyDown("g") && sectorProps.gameObject.activeSelf && !sectorProps.transform.Find("Sector Name").GetComponent<InputField>().isFocused) {
             *  sectorProps.ToggleActive();
             * }
             * if(Input.GetKeyDown("g") && hotkeyList.gameObject.activeSelf) {
             *  hotkeyList.ToggleActive();
             * }
             * if(Input.GetKeyDown("g") && readFile.gameObject.activeSelf && !readFile.transform.Find("JSONPath").GetComponent<InputField>().isFocused) {
             *  readFile.ToggleActive();
             * }*/
        }

        if (Input.GetKeyDown("t") &&
            (!windowEnabled || nodeEditor.transform.parent.gameObject.activeSelf))
        {
            nodeEditor.ToggleActive();
        }

        if (!windowEnabled)
        {
            if (Input.GetKeyDown("space"))
            {
                Command com = new Command();
                com.position = Camera.main.transform.position;
                com.type     = CommandTypes.Center;
                undoStack.Push(com);
                redoStack.Clear();
                Vector3 pos = center;
                pos.z = Camera.main.transform.position.z;
                Camera.main.transform.position = pos;
            }

            if (Input.GetKeyDown("k"))
            {
                GetPlatformIndex(mousePos);
            }
#if UNITY_EDITOR
            if (Input.GetKeyDown("z"))
            {
                Undo();
            }

            if (Input.GetKeyDown("y"))
            {
                Redo();
            }
#else
            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown("z"))
            {
                Undo();
            }
            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown("y"))
            {
                Redo();
            }
#endif
            if (Input.GetKeyDown("q") || (Input.GetAxis("Mouse ScrollWheel") < 0 && !Input.GetKey(KeyCode.LeftControl)))
            {
                Destroy(cursor.obj);
                if (--cursorCount < 0)
                {
                    cursorCount = placeables.Length - 1;
                }

                cursor     = placeables[cursorCount % placeables.Length];
                cursor.obj = Instantiate(placeables[cursorCount % placeables.Length].obj, cursor.obj.transform.position, Quaternion.identity);
            }

            if (Input.GetKeyDown("c"))
            {
                Command com = new Command();
                List <PlaceableObject> oldList = new List <PlaceableObject>();
                foreach (PlaceableObject placeable in objects)
                {
                    oldList.Add(placeable);
                    Destroy(placeable.obj);
                }

                com.type        = CommandTypes.Clear;
                com.clearedList = oldList;
                undoStack.Push(com);
                redoStack.Clear();
                objects.Clear();
            }

            if (Input.GetKeyDown("e") || (Input.GetAxis("Mouse ScrollWheel") > 0 && !Input.GetKey(KeyCode.LeftControl)))
            {
                Destroy(cursor.obj);
                cursor     = placeables[++cursorCount % placeables.Length];
                cursor.obj = Instantiate(placeables[cursorCount % placeables.Length].obj, cursor.obj.transform.position, Quaternion.identity);
            }

            if (Input.GetKeyDown("r") || Input.GetMouseButtonDown(1))
            {
                DeleteObject();
            }

            if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("f"))
            {
                Command com   = new Command();
                bool    found = false;
                foreach (PlaceableObject obj in objects)
                {
                    if (obj.pos == cursor.obj.transform.position && cursor.type == obj.type)
                    {
                        if (GetIsFactable(cursor))
                        {
                            com.type     = CommandTypes.ChangeFaction;
                            com.position = cursor.obj.transform.position;
                            var newObj = obj;
                            if (obj.type == ObjectTypes.Other)
                            {
                                mainMenu.CloseUI();
                                coreEditor.Initialize(newObj, this);
                            }
                            else
                            {
                                newObj.faction = (obj.faction + 1) % numberOfFactions;
                                com.obj        = newObj;
                                undoStack.Push(com);
                            }

                            objects.Remove(obj);
                            objects.Add(newObj);
                            UpdateColors();
                        }
                        else if (obj.type == ObjectTypes.Platform)
                        {
                            objects.Remove(obj);
                            PlaceableObject newObj = obj;
                            newObj.rotation = (newObj.rotation + 1) % 4;
                            Vector3 rot = newObj.obj.transform.localEulerAngles;
                            rot.z = 90 * newObj.rotation;
                            newObj.obj.transform.localEulerAngles = rot;
                            objects.Add(newObj);
                        }
                        else if (obj.assetID == "flag")
                        {
                            coreEditor.Initialize(obj, this);
                        }
                        else
                        {
                            com.type     = CommandTypes.Remove;
                            com.position = cursor.obj.transform.position;
                            com.obj      = obj;
                            undoStack.Push(com);
                            objects.Remove(obj);
                            Destroy(obj.obj);
                        }

                        redoStack.Clear();
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    com.type = CommandTypes.Place;
                    PlaceableObject newo = cursor;
                    newo.pos     = cursor.obj.transform.position;
                    com.position = newo.pos;
                    newo.obj     = Instantiate(cursor.obj, newo.pos, Quaternion.identity);
                    com.obj      = newo;
                    undoStack.Push(com);
                    redoStack.Clear();
                    objects.Add(newo);
                }
            }

            cursor.obj.transform.position = new Vector3(mousePos.x, mousePos.y, 0);
        }
    }
Exemple #3
0
 public void EntitySelection()
 {
     taskInterface.CloseUI();
     SetMode(WCCursorMode.SelectEntity);
 }