public void CreateNewSpeech(UINode node)
        {
            // Create new speech, the argument option is the speechs parent
            EditableSpeechNode newSpeech = new EditableSpeechNode();

            newSpeech.ID = CurrentAsset.CurrentIDCounter++;

            // Give the speech it's default values
            newSpeech.Name    = CurrentAsset.DefaultName;
            newSpeech.Icon    = CurrentAsset.DefaultSprite;
            newSpeech.TMPFont = CurrentAsset.DefaultFont;

            // Set this new speech as the options child
            if (node is UIOptionNode)
            {
                (node as UIOptionNode).OptionNode.SetSpeech(newSpeech);
            }
            else if (node is UISpeechNode)
            {
                (node as UISpeechNode).SpeechNode.SetSpeech(newSpeech);
            }

            // This new speech doesn't have any children yet
            newSpeech.Options = null;

            // Create a new UI object to represent the new speech
            UISpeechNode ui = new UISpeechNode(newSpeech, Vector2.zero);

            uiNodes.Add(ui);

            // Set the input state appropriately
            m_inputState         = eInputState.PlacingSpeech;
            m_currentPlacingNode = ui;
        }
Exemple #2
0
 void Awake()
 {
     inputState = eInputState.DISABLED;
     GetComponent <BattleController>().stateChange += BattleStateChanged;
     highlighter   = GetComponent <GridHighlighter> ();
     guiController = GetComponent <BattleGUIController> ();
 }
        //--------------------------------------
        // Event listeners
        //--------------------------------------

        /* -- Creating Nodes -- */

        public void CreateNewOption(UISpeechNode speechUI)
        {
            // Create new option, the argument speech is the options parent
            EditableOptionNode newOption = new EditableOptionNode();

            newOption.ID = CurrentAsset.CurrentIDCounter++;

            // Give the speech it's default values
            newOption.TMPFont = CurrentAsset.DefaultFont;

            // Add the option to the speechs' list of options
            speechUI.SpeechNode.AddOption(newOption);

            // The option doesn't point to an speech yet
            newOption.Speech = null;

            // Create a new UI object to represent the new option
            UIOptionNode ui = new UIOptionNode(newOption, Vector2.zero);

            uiNodes.Add(ui);

            // Set the input state appropriately
            m_inputState         = eInputState.PlacingOption;
            m_currentPlacingNode = ui;
        }
Exemple #4
0
 private void AnimationCompleted()
 {
     if (BattleController.instance.battleState == BattleController.eBattleState.PLAYER_TURN)
     {
         inputState = eInputState.PLAYER_DEFAULT;
         GetMovementRange();
     }
 }
        /* -- Connecting Nodes -- */

        public void ConnectNode(UINode option)
        {
            // The option if what we are connecting
            m_currentConnectingNode = option;

            // Set the input state appropriately
            m_inputState = eInputState.ConnectingNode;
        }
        private static eInputState checkStringLengthValidity(string i_StringToCheck)
        {
            eInputState stringLengthValidity = eInputState.InvalidInput;

            if (i_StringToCheck.Length == 8)
            {
                stringLengthValidity = eInputState.ValidInputLength;
            }

            return(stringLengthValidity);
        }
        private static eInputState checkIfStringConsistsOnlyOfDigits(string i_StringToCheck)
        {
            int         tempStringToIntValue;
            bool        isInputValid       = int.TryParse(i_StringToCheck, out tempStringToIntValue) && (tempStringToIntValue >= 0);
            eInputState currentStringState = eInputState.InvalidInput;

            if (isInputValid)
            {
                currentStringState = eInputState.NumericString;
            }

            return(currentStringState);
        }
        private static eInputState checkIfStringConsistsOnlyOfEnglishLetters(string i_StringToCheck)
        {
            eInputState currentStringState = eInputState.EnglishAlphabetString;

            for (int i = 0; i < i_StringToCheck.Length; i++)
            {
                if (!(char.IsUpper(i_StringToCheck[i]) || char.IsLower(i_StringToCheck[i])))
                {
                    currentStringState = eInputState.InvalidInput;
                    break;
                }
            }

            return(currentStringState);
        }
        private static eInputState checkStringValidityState(string i_StringToCheck)
        {
            eInputState inputStringState = checkStringLengthValidity(i_StringToCheck);

            if (inputStringState == eInputState.ValidInputLength)
            {
                inputStringState = checkIfStringConsistsOnlyOfDigits(i_StringToCheck);
                if (inputStringState == eInputState.InvalidInput)
                {
                    inputStringState = checkIfStringConsistsOnlyOfEnglishLetters(i_StringToCheck);
                }
            }

            return(inputStringState);
        }
        // INPUT STRING METHODS
        private static string getInputString(out eInputState o_InputState)
        {
            o_InputState = eInputState.InvalidInput;
            string inputString = string.Empty;

            while (o_InputState == eInputState.InvalidInput)
            {
                Console.Write("Please enter a string with 8 characters: ");
                inputString  = Console.ReadLine();
                o_InputState = checkStringValidityState(inputString);
                if (o_InputState == eInputState.InvalidInput)
                {
                    Console.WriteLine("The input you entered is invalid. Please try again.\n");
                }
            }

            return(inputString);
        }
Exemple #11
0
    //*************************//
    // Unity member methods    //
    //*************************//

    void OnGUI()
    {
        switch (m_State)
        {
        case eInputState.MouseKeyboard:
            if (isControlerInput())
            {
                m_State = eInputState.Controler;
            }
            break;

        case eInputState.Controler:
            if (isMouseKeyboard())
            {
                m_State = eInputState.MouseKeyboard;
            }
            break;
        }
    }
Exemple #12
0
    public void ChangeState(int state)
    {
        if (state == (int)inputState)
        {
            return;
        }
        switch (state)
        {
        case (int)eInputState.CONTROL_OBJECT:
            peek.Find("Cube").GetComponent <MeshRenderer>().enabled = false;
            inputState = eInputState.CONTROL_OBJECT;
            break;

        case (int)eInputState.CREATE_OBJECT:
            peek.Find("Cube").GetComponent <MeshRenderer>().enabled = true;
            inputState = eInputState.CREATE_OBJECT;
            break;
        }
    }
Exemple #13
0
    private void BattleStateChanged(BattleController.eBattleState state)
    {
        switch (state)
        {
        case BattleController.eBattleState.INITIALISATION:
            inputState = eInputState.DISABLED;
            highlighter.InitHighlighter();
            mouseHoverEvent = false;
            currentUnit     = null;
            break;

        case BattleController.eBattleState.UNIT_PLACEMENT:
            inputState     = eInputState.UNIT_PLACEMENT;
            playerStartPos = BattleController.instance.playerStartPos;
            enemyStartPos  = BattleController.instance.enemyStartPos;
            highlighter.HighlightPlayerStart(playerStartPos);
            highlighter.HighlightEnemyStart(enemyStartPos);
            currentUnit = null;
            break;

        case BattleController.eBattleState.PLAYER_TURN:
            inputState = eInputState.PLAYER_DEFAULT;
            UpdateUnitState();
            break;

        case BattleController.eBattleState.AI_TURN:
            inputState = eInputState.NPC_DEFAULT;
            highlighter.ClearAll();
            UpdateUnitState();
            break;

        case BattleController.eBattleState.VICTORY:
            inputState  = eInputState.DISABLED;
            currentUnit = null;
            break;

        case BattleController.eBattleState.DEFEAT:
            inputState  = eInputState.DISABLED;
            currentUnit = null;
            break;
        }
    }
Exemple #14
0
    //*************************//
    // Unity member methods    //
    //*************************//

    public void Update()
    {
        switch (m_State)
        {
        case eInputState.MouseKeyboard:
            if (isControlerInput())
            {
                m_State = eInputState.Controler;
                Debug.Log("DREAM - JoyStick being used");
            }
            break;

        case eInputState.Controler:
            if (isMouseKeyboard())
            {
                m_State = eInputState.MouseKeyboard;
                Debug.Log("DREAM - Mouse & Keyboard being used");
            }
            break;
        }
    }
    //*************************//
    // Unity member methods    //
    //*************************//

    void OnGUI()
    {
        switch (m_State)
        {
        case eInputState.MouseKeyboard:
            if (isControlerInput())
            {
                m_State = eInputState.Controler;
                Debug.Log("JoyStick being used");
            }
            break;

        case eInputState.Controler:
            if (isMouseKeyboard())
            {
                m_State = eInputState.MouseKeyboard;
                Debug.Log("Mouse & Keyboard being used");
            }
            break;
        }
    }
        //--------------------------------------
        // Input
        //--------------------------------------

        private void ProcessInput()
        {
            Event e = Event.current;

            switch (m_inputState)
            {
            case eInputState.Regular:
                bool inPanel = panelRect.Contains(e.mousePosition) || e.mousePosition.y < TOOLBAR_HEIGHT;
                ProcessNodeEvents(e, inPanel);
                ProcessEvents(e);
                break;

            case eInputState.draggingPanel:
                panelWidth = (position.width - e.mousePosition.x);
                if (panelWidth < 100)
                {
                    panelWidth = 100;
                }

                if (e.type == UnityEngine.EventType.MouseUp && e.button == 0)
                {
                    m_inputState = eInputState.Regular;
                    e.Use();
                }
                Repaint();
                break;

            case eInputState.PlacingOption:
                m_currentPlacingNode.SetPosition(e.mousePosition);

                // Left click
                if (e.type == UnityEngine.EventType.MouseDown && e.button == 0)
                {
                    // Place the option
                    SelectNode(m_currentPlacingNode, true);
                    m_inputState = eInputState.Regular;
                    Repaint();
                    e.Use();
                }
                break;

            case eInputState.PlacingSpeech:
                m_currentPlacingNode.SetPosition(e.mousePosition);

                // Left click
                if (e.type == UnityEngine.EventType.MouseDown && e.button == 0)
                {
                    // Place the option
                    SelectNode(m_currentPlacingNode, true);
                    m_inputState = eInputState.Regular;
                    Repaint();
                    e.Use();
                }
                break;

            case eInputState.ConnectingNode:
                // Click.
                if (e.type == UnityEngine.EventType.MouseDown && e.button == 0)
                {
                    // If we're connecting a Speech node
                    if (m_currentConnectingNode is UISpeechNode)
                    {
                        for (int i = 0; i < uiNodes.Count; i++)
                        {
                            if (uiNodes[i] == m_currentConnectingNode)
                            {
                                continue;
                            }

                            if (uiNodes[i].rect.Contains(e.mousePosition))
                            {
                                if (uiNodes[i] is UISpeechNode)
                                {
                                    UISpeechNode connecting = m_currentConnectingNode as UISpeechNode;
                                    UISpeechNode toBeChild  = uiNodes[i] as UISpeechNode;

                                    // If a relationship between these speechs already exists, swap it
                                    // around, as a 2way speech<->speech relationship cannot exist.
                                    if (connecting.SpeechNode.parents.Contains(toBeChild.SpeechNode))
                                    {
                                        // Remove the relationship
                                        connecting.SpeechNode.parents.Remove(toBeChild.SpeechNode);
                                        toBeChild.SpeechNode.Speech = null;
                                    }

                                    (m_currentConnectingNode as UISpeechNode).SpeechNode.SetSpeech((uiNodes[i] as UISpeechNode).SpeechNode);
                                }
                                else if (uiNodes[i] is UIOptionNode)
                                {
                                    (m_currentConnectingNode as UISpeechNode).SpeechNode.AddOption((uiNodes[i] as UIOptionNode).OptionNode);
                                }

                                m_inputState = eInputState.Regular;
                                e.Use();

                                break;
                            }
                        }
                    }

                    // Else if we're connecting an Option node
                    else if (m_currentConnectingNode is UIOptionNode)
                    {
                        for (int i = 0; i < uiNodes.Count; i++)
                        {
                            if (uiNodes[i] == m_currentConnectingNode)
                            {
                                continue;
                            }

                            if (uiNodes[i].rect.Contains(e.mousePosition))
                            {
                                if (uiNodes[i] is UISpeechNode)
                                {
                                    (m_currentConnectingNode as UIOptionNode).OptionNode.SetSpeech((uiNodes[i] as UISpeechNode).SpeechNode);

                                    m_inputState = eInputState.Regular;
                                    e.Use();
                                    break;
                                }
                            }
                        }
                    }
                }

                // Esc
                if (e.type == UnityEngine.EventType.KeyDown && e.keyCode == KeyCode.Escape)
                {
                    m_inputState = eInputState.Regular;
                }
                break;
            }
        }
Exemple #17
0
 public void OnEvent(eInputState hit)
 {
     _gameScene.InputState = hit;
 }
    void Start()
    {
        guiTexture = this.gameObject.GetComponent<GUITexture>();
        if (Input.GetJoystickNames().Length > 0)
        {
            if (guiTexture)
            {
                guiTexture.texture = controllerTexture;
                m_State = eInputState.Controller;
            }
            else
            {
                this.renderer.material.mainTexture = controllerTexture;
                m_State = eInputState.Controller;
            }
        }

        numberOfJoysticksConnected = Input.GetJoystickNames().Length;
    }
        private void ProcessEvents(Event e)
        {
            dragDelta = Vector2.zero;

            switch (e.type)
            {
            case UnityEngine.EventType.MouseDown:
                // Left click
                if (e.button == 0)
                {
                    if (panelRect.Contains(e.mousePosition))
                    {
                        clickInBox = true;
                    }
                    else if (InPanelDrag(e.mousePosition))
                    {
                        clickInBox   = true;
                        m_inputState = eInputState.draggingPanel;
                    }
                    else if (e.mousePosition.y > TOOLBAR_HEIGHT)
                    {
                        clickInBox = false;
                        if (!DialogueEditorWindow.NodeClickedOnThisUpdate)
                        {
                            UnselectNode();
                            e.Use();
                        }
                    }
                }
                // Right click
                else if (e.button == 1)
                {
                    if (DialogueEditorUtil.IsPointerNearConnection(uiNodes, e.mousePosition, out m_connectionDeleteParent, out m_connectionDeleteChild))
                    {
                        GenericMenu rightClickMenu = new GenericMenu();
                        rightClickMenu.AddItem(new GUIContent("Delete connection"), false, DeleteConnection);
                        rightClickMenu.ShowAsContext();
                    }
                }

                if (e.button == 0 || e.button == 2)
                {
                    dragging = true;
                }
                else
                {
                    dragging = false;
                }
                break;

            case UnityEngine.EventType.MouseDrag:
                if (dragging && (e.button == 0 || e.button == 2) && !clickInBox && !IsANodeSelected())
                {
                    OnDrag(e.delta);
                }
                break;

            case UnityEngine.EventType.MouseUp:
                dragging = false;
                break;
            }
        }
Exemple #20
0
 public static void SetInputState(eInputState state)
 {
     inputState = state;
 }
    void OnGUI()
    {
        switch (m_State)
        {
            case eInputState.MouseKeyboard:
                if (isControllerInput())
                {
                    m_State = eInputState.Controller;
                    Debug.Log("JoyStick being used");
                    if (controllerTexture)
                    {
                        if (guiTexture)
                        {
                            guiTexture.texture = controllerTexture;
                        }
                        else
                        {
                            this.renderer.material.mainTexture = controllerTexture;
                        }

                    }
                }
                break;
            case eInputState.Controller:
                if (isMouseKeyboard())
                {
                    m_State = eInputState.MouseKeyboard;
                    Debug.Log("Keyboard being used");
                    if (keyboardTexture)
                    {
                        if (guiTexture)
                        {
                            guiTexture.texture = keyboardTexture;
                        }
                        else
                        {
                            this.renderer.material.mainTexture = keyboardTexture;
                        }
                    }
                }
                break;
        }
    }
Exemple #22
0
 private void PathSelected()
 {
     inputState = eInputState.DISABLED;
     currentUnit.Move(movementPath, target, movementPenalty);
 }
 //*************************//
 // Unity member methods    //
 //*************************//
 void OnGUI()
 {
     switch( m_State )
      {
          case eInputState.MouseKeyboard:
              if(isControlerInput())
              {
                  m_State = eInputState.Controler;
                  Debug.Log("DREAM - JoyStick being used");
              }
              break;
          case eInputState.Controler:
              if (isMouseKeyboard())
              {
                  m_State = eInputState.MouseKeyboard;
                  Debug.Log("DREAM - Mouse & Keyboard being used");
              }
              break;
      }
 }