コード例 #1
0
    void mouseSpecial()
    {
        _currentPlayersPiece = false;
        if (_targetHex != null)
        {
            _targetHex.GetComponent <HexScript>().setColor();
        }
        switch (_currentPiece.GetComponent <ChessPieceBehaviour>()._effectType)
        {
        case ChessPieceBehaviour.specialEffectType.SELF:
            GameState.Instance.MouseEnabled = false;
            StartCoroutine(_currentPiece.GetComponent <ChessPieceBehaviour>().doSpecial());
            _currentState = PickingStates.ACTION_MODE;
            break;

        case ChessPieceBehaviour.specialEffectType.AOE:
            GameState.Instance.MouseEnabled = false;
            StartCoroutine(_currentPiece.GetComponent <ChessPieceBehaviour>().doSpecial());
            _currentState = PickingStates.ACTION_MODE;
            break;

        case ChessPieceBehaviour.specialEffectType.DIRECTED:
            Cursor.SetCursor(_specialTexture, Vector2.zero, CursorMode.Auto);
            _currentPiece.GetComponent <ChessPieceBehaviour>().mouseInput();
            break;

        default:
            _currentState = PickingStates.PICK_MODE;
            break;
        }
    }
コード例 #2
0
    void gameMenu(int winID)
    {
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        GUILayout.Label(GameState.Instance.getPlayer(true).Name + " vs " + GameState.Instance.getPlayer(false).Name + ":  ");
        GUILayout.Label(GameState.Instance.CurrentPlayer.Name + "'s turn");
        GUI.enabled = GameState.Instance.MouseEnabled;
        if (GUILayout.Button("End Turn"))
        {
            if (_tutorial == false)
            {
                endTurn();
            }
            else
            {
                gameObject.GetComponent <TutorialGUI>().CurrentLesson.next();
            }
        }
        if (_tutorial == false)
        {
            if (GUILayout.Button("Menu Options"))
            {
                _currentState = PickingStates.MENU_MODE;
            }

            /*if(GUILayout.Button("Duel Mode"))
             * {
             *      _currentState=GameplayGUI.PickingStates.DUEL_MODE;
             *      StartCoroutine(GameState.Instance.DuelRoutine());
             * }*/
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
    }
コード例 #3
0
    void saveDialog()
    {
        GUILayout.BeginArea(_loadSaveDialog);
        _saveSelectionIndex = GUILayout.SelectionGrid(_saveSelectionIndex, GameState.Instance.SaveList, 1);
        GUILayout.BeginHorizontal();
        string file = GUILayout.TextField(_defaultFileName);

        if (GUILayout.Button("New Save"))
        {
            GameState.Instance.SaveGame(file);
            _currentState       = PickingStates.MENU_MODE;
            _saveSelectionIndex = 0;
        }
        GUILayout.EndHorizontal();
        string prevSave = GameState.Instance.SaveList[_saveSelectionIndex];

        if (!prevSave.Equals("No Games Are Saved"))
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save Over.."))
            {
                GameState.Instance.SaveGame(prevSave);
                _currentState       = PickingStates.MENU_MODE;
                _saveSelectionIndex = 0;
            }
            GUILayout.Label(prevSave);
            GUILayout.EndHorizontal();
        }
        if (GUILayout.Button("Cancel"))
        {
            _currentState       = PickingStates.MENU_MODE;
            _saveSelectionIndex = 0;
        }
        GUILayout.EndArea();
    }
コード例 #4
0
 //check to see if the player can make anymore actions
 public void checkEndTurn()
 {
     _specialPick = false;
     if (_tutorial == false)
     {
         if (!GameState.Instance.checkPossibleAttacks() && !GameState.Instance.checkPossibleMoves())
         {
             _guiCanvas.GetComponent <GUIMetaControls> ().OpenEndTurnDialog();
         }
         else if (!GameState.Instance.checkPossibleAttacks() && _canMove == false)
         {
             _guiCanvas.GetComponent <GUIMetaControls> ().OpenEndTurnDialog();
         }
         else if (_canAttack == false && !GameState.Instance.checkPossibleMoves())
         {
             _guiCanvas.GetComponent <GUIMetaControls> ().OpenEndTurnDialog();
         }
         else if (_canMove == false && _canAttack == false)
         {
             _guiCanvas.GetComponent <GUIMetaControls> ().OpenEndTurnDialog();
         }
         else if (_canMove == false || _canAttack == false)
         {
             _currentState = PickingStates.ACTION_MODE;
         }
     }
     else
     {
         _currentState = PickingStates.ACTION_MODE;
     }
     restoreHexColors();
 }
コード例 #5
0
 void specialSelect()
 {
     if (_currentPiece.GetComponent <ChessPieceBehaviour> ()._effectType == ChessPieceBehaviour.specialEffectType.DIRECTED &&
         _currentPiece.GetComponent <ChessPieceBehaviour> ().canDoSpecial())
     {
         _currentState = PickingStates.SPECIAL_MODE;
     }
 }
コード例 #6
0
 void mouseMove()
 {
     _specialPick         = false;
     _currentPlayersPiece = false;
     if (_currentHex != _targetHex)
     {
         _currentHex.gameObject.GetComponent <Renderer>().material.color = Color.green;
     }
     if (Input.GetMouseButtonUp(1) && GameState.Instance.MouseEnabled == true)
     {
         _currentPlayersPiece = true;
         Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
         _currentState = PickingStates.ACTION_MODE;
         restoreHexColors();
     }
     else
     {
         _ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit[] hits = Physics.RaycastAll(_ray, 500f);
         foreach (RaycastHit hit in hits)
         {
             if (hit.collider.gameObject.tag == "Hex")
             {
                 if (_targetHex != null)
                 {
                     if (_targetHex.GetComponent <Renderer>().material.color.Equals(startColor))
                     {
                         _targetHex.GetComponent <Renderer>().material.color = Color.green;
                     }
                 }
                 _targetHex = hit.collider.gameObject;
                 if (_targetHex.GetComponent <HexScript>().Occupant == null && _currentHex.GetComponent <HexScript>().canMoveToHex(_targetHex))
                 {
                     _targetHex.GetComponent <Renderer>().material.color = startColor;
                     if (Input.GetAxis("Select") > 0 && GameState.Instance.MouseEnabled == true)
                     {
                         GameState.Instance.MouseEnabled = false;
                         Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
                         _currentState = PickingStates.ACTION_MODE;
                         StartCoroutine(_currentPiece.GetComponent <ChessPieceBehaviour>().Move(_targetHex));
                     }
                 }
             }
             else
             {
                 if (_targetHex != null)
                 {
                     if (_targetHex.GetComponent <Renderer>().material.color.Equals(startColor))
                     {
                         _targetHex.GetComponent <Renderer>().material.color = Color.green;
                     }
                     _targetHex = null;
                 }
             }
         }
     }
 }
コード例 #7
0
 public void resetGUI()
 {
     _canAttack    = true;
     _canMove      = true;
     _canDoSpecial = true;
     if (_currentHex != null)
     {
         _currentHex.GetComponent <HexScript> ().setColor();
     }
     _currentPiece = null;
     _currentState = PickingStates.PICK_MODE;
 }
コード例 #8
0
 void cantDoSpecialDialog(int winID)
 {
     GUILayout.Label("Can't do special action this turn.");
     if (GUILayout.Button("Ok"))
     {
         _currentPlayersPiece = true;
         Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
         _specialPick  = false;
         _currentState = GameplayGUI.PickingStates.ACTION_MODE;
         GameState.Instance.MouseEnabled = true;
     }
 }
コード例 #9
0
 void mouseAttack()
 {
     _specialPick         = false;
     _currentPlayersPiece = false;
     if (_currentHex != _targetHex)
     {
         _currentHex.gameObject.GetComponent <Renderer>().material.color = Color.green;
     }
     if (Input.GetMouseButtonUp(1) && GameState.Instance.MouseEnabled == true)
     {
         _currentPlayersPiece = true;
         Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
         _currentState = PickingStates.ACTION_MODE;
         restoreHexColors();
     }
     else
     {
         _ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(_ray, out hit, 500f))
         {
             if (hit.collider.gameObject.tag == "ChessPiece")
             {
                 if (_targetHex != null)
                 {
                     _targetHex.GetComponent <Renderer>().material.color = startColor;
                 }
                 GameObject targetPiece = hit.collider.gameObject;
                 _targetHex = targetPiece.GetComponent <ChessPieceBehaviour>().HomeHex;
                 startColor = _targetHex.GetComponent <Renderer>().material.color;
                 if (_currentPiece.GetComponent <ChessPieceBehaviour>().legitTarget(targetPiece))
                 {
                     _targetHex.gameObject.GetComponent <Renderer>().material.color = new Color(0, .5f, 0);
                     if (Input.GetAxis("Select") > 0 && GameState.Instance.MouseEnabled == true)
                     {
                         GameState.Instance.MouseEnabled = false;
                         StartCoroutine(_currentPiece.GetComponent <ChessPieceBehaviour>().Attack(targetPiece));
                     }
                 }
             }
         }
         else
         {
             _targetHex = null;
         }
     }
 }
コード例 #10
0
 void mousePick()
 {
     _specialPick = false;
     if (_targetHex != null)
     {
         _targetHex.GetComponent <HexScript>().setColor();
     }
     if (_currentPiece != null && GameState.Instance.CurrentPlayer.getColor() == _currentPiece.GetComponent <ChessPieceBehaviour>().TeamColor)
     {
         _currentPiece.GetComponent <ChessPieceBehaviour> ().HomeHex.gameObject.GetComponent <Renderer>().material.color = Color.green;
     }
     if (Input.GetAxis("Select") > 0 && GameState.Instance.MouseEnabled == true)
     {
         if (_currentHex != null)
         {
             _currentHex.GetComponent <HexScript>().setColor();
         }
         _ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(_ray, out hit, 500f))
         {
             if (hit.collider.gameObject.tag == "ChessPiece")
             {
                 _currentPiece = hit.collider.gameObject;
                 _currentHex   = _currentPiece.GetComponent <ChessPieceBehaviour>().HomeHex;
                 if (GameState.Instance.CurrentPlayer.getColor() == _currentPiece.GetComponent <ChessPieceBehaviour>().TeamColor&& !
                     _currentPiece.GetComponent <ChessPieceBehaviour>().containsModifier(Modifier.ModifierType.PETRIFIED) &&
                     _currentPiece.GetComponent <ChessPieceBehaviour>().Held == false)
                 {
                     _currentHex.gameObject.GetComponent <Renderer>().material.color = Color.green;
                     _currentState        = PickingStates.ACTION_MODE;
                     _currentPlayersPiece = true;
                 }
                 else
                 {
                     _currentHex.gameObject.GetComponent <Renderer>().material.color = Color.red;
                     _currentPlayersPiece = false;
                 }
             }
             else
             {
                 _currentPiece        = null;
                 _currentPlayersPiece = false;
             }
         }
     }
 }
コード例 #11
0
 public void Cancel()
 {
     if (_targetHex != null)
     {
         _targetHex.GetComponent <HexScript>().setColor();
     }
     _targetHex = null;
     if (_currentHex != null)
     {
         _currentHex.GetComponent <HexScript>().setColor();
     }
     _currentHex          = null;
     _currentPiece        = null;
     _currentPlayersPiece = false;
     Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
     _currentState = PickingStates.PICK_MODE;
 }
コード例 #12
0
 void moveSelect(GameObject target)
 {
     _targetHex = target;
     if (_targetHex.GetComponent <HexScript>().Occupant == null && _currentHex.GetComponent <HexScript>().canMoveToHex(_targetHex) &&
         _canMove == true)
     {
         _targetHex.gameObject.GetComponent <Renderer>().material.color = Color.green;
         if (Input.GetAxis("Select") > 0 && GameState.Instance.MouseEnabled == true)
         {
             GameState.Instance.MouseEnabled = false;
             Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
             _currentState = PickingStates.PICK_MODE;
             StartCoroutine(_currentPiece.GetComponent <ChessPieceBehaviour>().Move(_targetHex));
         }
     }
     else
     {
         _targetHex.gameObject.GetComponent <Renderer>().material.color = Color.red;
     }
 }
コード例 #13
0
 void allySelect(GameObject target)
 {
     if (target.GetComponent <ChessPieceBehaviour>().containsModifier(Modifier.ModifierType.PETRIFIED) ||
         target.GetComponent <ChessPieceBehaviour>().Held == true)
     {
         _currentPiece = target;
         _currentHex.GetComponent <HexScript>().setColor();
         _currentHex = _currentPiece.GetComponent <ChessPieceBehaviour>().HomeHex;
         _currentHex.gameObject.GetComponent <Renderer>().material.color = Color.red;
         _currentPlayersPiece = false;
         _currentState        = PickingStates.PICK_MODE;
     }
     else
     {
         if (Input.GetAxis("Select") > 0 && GameState.Instance.MouseEnabled == true)
         {
             _currentPiece = target;
             _currentHex.GetComponent <HexScript>().setColor();
             _currentHex = _currentPiece.GetComponent <ChessPieceBehaviour>().HomeHex;
             _currentHex.gameObject.GetComponent <Renderer>().material.color = Color.green;
         }
     }
 }
コード例 #14
0
 void menuDialog()
 {
     GUILayout.BeginArea(_MenuDialog);
     if (GUILayout.Button("Save Game"))
     {
         GameState.Instance.populateSaveList();
         _defaultFileName = GameState.Instance.setDefaultSaveName();
         _currentState    = PickingStates.SAVE_MODE;
     }
     if (GUILayout.Button("Exit(Main Menu)"))
     {
         GameState.Instance.clearGameData();
         SceneManager.LoadScene("MainMenu");
     }
     if (GUILayout.Button("Exit(Desktop)"))
     {
         Application.Quit();
     }
     if (GUILayout.Button("Resume"))
     {
         _currentState = PickingStates.PICK_MODE;
     }
     GUILayout.EndArea();
 }
コード例 #15
0
    void pieceInterface(int winID)
    {
        if (_currentPiece == null)
        {
            GUILayout.Label(" No Piece Selected");
        }
        else if (_currentState == PickingStates.MOVE_MODE)
        {
            GUILayout.Label(" Hover the mouse over a valid hex to move to, then left click to move. Right click to cancel");
            if (GUILayout.Button("Cancel"))
            {
                _currentPlayersPiece = true;
                Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
                _currentState = PickingStates.ACTION_MODE;
                restoreHexColors();
            }
        }
        else if (_currentState == PickingStates.ATTACK_MODE)
        {
            GUILayout.Label(" Hover the mouse over a valid target, then left click to attack. Right click to cancel");
            if (GUILayout.Button("Cancel"))
            {
                _currentPlayersPiece = true;
                _currentState        = PickingStates.ACTION_MODE;
                restoreHexColors();
            }
        }
        else if (_currentState == PickingStates.SPECIAL_MODE &&
                 _currentPiece.GetComponent <ChessPieceBehaviour>()._effectType == ChessPieceBehaviour.specialEffectType.DIRECTED)
        {
            _currentPiece.GetComponent <ChessPieceBehaviour>().specialInterface();
            if (GUILayout.Button("Cancel"))
            {
                _specialPick = false;
                Cursor.SetCursor(_pickTexture, Vector2.zero, CursorMode.Auto);
                _currentPiece.GetComponent <ChessPieceBehaviour>().cancelAction();
            }
        }
        else
        {
            _scrollPos = GUILayout.BeginScrollView(_scrollPos);
            string currentHitPoints = _currentPiece.GetComponent <ChessPieceBehaviour>().CurrentHP.ToString();
            string fullHitPoints    = _currentPiece.GetComponent <ChessPieceBehaviour>()._hitPoints.ToString();
            //type of piece
            GUILayout.BeginHorizontal();
            GUILayout.Label("Piece Type:");
            GUILayout.Label(_currentPiece.GetComponent <ChessPieceBehaviour> ()._name);
            GUILayout.EndHorizontal();
            //peices hit points
            GUILayout.BeginHorizontal();
            GUILayout.Label("Current Hit Points:");
            GUILayout.Label(currentHitPoints + " / " + fullHitPoints);
            GUILayout.EndHorizontal();

            GUILayout.Label("Current Modifiers");
            GUILayout.TextArea(modDescriptions());

            GUI.enabled = enableMove();
            if (GUILayout.Button("Move"))
            {
                Cursor.SetCursor(_moveTexture, Vector2.zero, CursorMode.Auto);
                lightUpMoveHexes();
                _currentState = PickingStates.MOVE_MODE;
            }
            GUILayout.TextArea(_currentPiece.GetComponent <ChessPieceBehaviour> ().MoveDescription);
            GUI.enabled = enableAttack();
            if (GUILayout.Button("Attack"))
            {
                Cursor.SetCursor(_attackTexture, Vector2.zero, CursorMode.Auto);
                lightUpAttackHexes();
                _currentState = PickingStates.ATTACK_MODE;
            }
            GUILayout.TextArea(_currentPiece.GetComponent <ChessPieceBehaviour> ().AttackDescription);
            GUI.enabled = enableSpecial();
            if (GUILayout.Button("Special"))
            {
                _currentState = PickingStates.SPECIAL_MODE;
            }
            GUILayout.TextArea(_currentPiece.GetComponent <ChessPieceBehaviour> ().SpecialDescription);
            GUILayout.EndScrollView();
        }
    }