//Function for finishing the match
 public void FinishMatch(BaseCharStateMachine Winner, BaseCharStateMachine Loser, string WinReason)
 {
     Winner.TurnState = BaseCharStateMachine.CharTurnState.WIN;
     Loser.TurnState  = BaseCharStateMachine.CharTurnState.LOSS;
     TheTurn          = TurnStates.MATCHFINISHED;
     this.WinReason   = WinReason;
 }
Beispiel #2
0
    void MoveCharacter(GameObject Character)
    {
        print("111111111");
        for (int i = 0; i < ActionPoints; i++)
        {
            if (grid.path.Count > i)
            {
                Vector3 MoveDirection;

                MoveDirection = grid.path[i].worldPosition - Character.transform.position;

                MoveDirection.x *= 0.1f;
                MoveDirection.y *= 0.1f;
                MoveDirection.z *= 0.1f;


                for (int j = 0; j < 10; j++)
                {
                    Character.transform.position += MoveDirection;
                }
            }
        }

        State = TurnStates.EnemyTurn;
    }
    public IEnumerator DQStrikeChar()
    {
        //Incrament strikes
        CurrentChar.DQ_Strikes++;

        //Write Note
        string ReffMessage = CurrentChar.Stats.Name + "! That is strike " + CurrentChar.DQ_Strikes.ToString() + "!";

        //If Strikes = 3, Ring the Bell
        if (CurrentChar.DQ_Strikes >= 3)
        {
            ReffMessage += " Ring the Bell!";
        }

        //Display Note
        DisplayNote(ReffMessage);

        yield return(new WaitForSeconds(2));

        if (CurrentChar.DQ_Strikes >= 3)
        {
            FinishMatch(ThisTurn.Target, ThisTurn.Actor, "Disqualification");
        }
        else
        {
            TheTurn = TurnStates.DONE;
        }
    }
Beispiel #4
0
 void Start()
 {
     //Find and assign script variables
     pauseMenu   = gameObject.GetComponent <GUIPauseMenu> ();
     optionsMenu = gameObject.GetComponent <GUIOptionsMenu> ();
     gridScript  = (GameObject.Find("Grid Controller")).GetComponent <GridCS> ();
     gridScript.CreateGrid();
     //Tell the grid to spawn
     //GridCS.Instance.CreateGrid ();
     //Set the currently loaded layer to the one designated by the grid script
     LayerSwitcher.Instance.CurrentLayer = GridCS.coreLayer;
     for (int layer = 0; layer <= GridCS.layerCount; layer++)
     {
         if (layer != GridCS.coreLayer)
         {
             LayerSwitcher.Instance.HideLayer(layer);
         }
     }
     //Go and find the main camera
     MainCamera = GameObject.Find("Main Camera").GetComponent <Camera> ();
     //Assign states, enter into the Insert phase
     turnState = TurnStates.InsertPhase;
     menuState = MenuStates.NullState;
     _EnterInsertPhase();
     //Put the Layer Switcher button into the main GUI
     guiFunction += LayerSwitcher.Instance.GUIFunction;
 }
Beispiel #5
0
    void OnGUI()
    {
        if(GUILayout.Button("Next State"))
        {
            currentState += 1;

            Debug.Log(currentState);
        }

        if (GUILayout.Button("Spawn Blue"))
        {
            string teamColour = "BlueTroop";
            Vector3 position = new Vector3(0, 0, 0);
            Quaternion rotation = new Quaternion(0, 0, 0, 0);
            sT.TroopSpawn(teamColour, position, rotation);
        }

        if (GUILayout.Button("Spawn Red"))
        {
            string teamColour = "RedTroop";
            Vector3 position = new Vector3(0, 0, 0);
            Quaternion rotation = new Quaternion(0, 0, 0, 0);
            sT.TroopSpawn(teamColour, position, rotation);
        }
    }
Beispiel #6
0
 //null or end phase to insert phase
 public void _EnterInsertPhase()
 {
     //If the OnTurnBegin delegate isn't empty, activate it. Good for effects that happen early in the turn.
     if (OnTurnBegin != null)
     {
         OnTurnBegin();
     }
     //Clear the UnitChoice list that contains all of the spawnable units in one team.
     UnitChoice.Instance.AllSpawnableUnits.Clear();
     //Set the camera to perspective view.
     CameraPerspective();
     //set the cursor selection script to its ordinary function
     CursorSelection.Instance.mouseFunction = CursorSelection.Instance.InsertMouseFunction;
     //Show which spaces can be spawned in for this turn
     SwitchButton.Instance.EnableSpawnableArea();
     //Set the phase state
     turnState = TurnStates.InsertPhase;
     //TODO: Remove this
     SelectionBoxSize = UnitChoice.Instance.NumberOfButtons * 200 + 50;
     //Insert all of the GUI buttons. TODO: Move this stuff to NGUI
     guiFunction += TurnActionOrderHandler.Instance.UndoGUI;
     guiFunction += GUISelectionBox;
     guiFunction += SwitchButton.Instance.GUIPlayerStats;
     //guiFunction += UnitChoice.Instance.SpawnButton;
     phaseGUIFunction = guiFunction;
     UnitChoice.Instance.GUISelectionBoxInsert();
 }
    private void UpdateTurnState(TurnStates newTurnState)
    {
        currentTurnState = newTurnState;

        switch (currentTurnState)
        {
        case TurnStates.ROLLING:
            rollButton.interactable = true;
            rollText.text           = string.Empty;
            RollUI.SetActive(true);

            break;

        case TurnStates.SELECTING:
            // Now the game should allow the player to select one of their Pieces to move
            // by calling PieceSelection from Update()
            // Maybe show some UI here

            break;

        case TurnStates.MOVING:
            RollUI.SetActive(false);
            StartCoroutine(WaitForMove());
            break;

        default:
            break;
        }
    }
Beispiel #8
0
    public void Changestate(TurnStates NewState)
    {
        currentstate = NewState;
        switch (NewState)
        {
        case TurnStates.PlayerTurn:
        {
            player.GetComponent <PlayerController>().playerturn();
        }
        break;

        case TurnStates.EnemyTurn:
        {
            //if(enemydostuff != null)
            //enemydostuff();

            GetComponent <EnemySpawner>().spawnenemy();
            enemyturn();
        }
        break;

        case TurnStates.NoCombat:
        {
            player.GetComponent <PlayerController>().playerturn();
        }
        break;

        default:
            break;
        }
    }
Beispiel #9
0
    public void _EnterResolvePhase()
    {
        //If there's anything loaded into the OnResolveTransitionInitial delegate, run it. This is useful for loading animations?
        if (OnResolveTransitionInitial != null)
        {
            OnResolveTransitionInitial();
        }
        //Disable the spawn indicator
        SwitchButton.Instance.DisableSpawnableArea();
        //Drop cursor selection functionality
        CursorSelection.Instance.mouseFunction = null;
        //Make a temp tile slot, fill it with the currently-selected tile. If such a tile exists, deselect it.
        Tile TileScript;

        TileScript = CursorSelection.Instance.selectedTile;
        if (TileScript != null)
        {
            if (TileScript.LoadedUnitScript != null)
            {
                TileScript.LoadedUnitScript.OnActionDeselect();
            }
            if (TileScript != null)
            {
                TileScript.TileSelectionType = Tile.OverlayType.Unselected;
            }
        }
        CursorSelection.Instance.selectedTile = null;
        //If there was a tile that had a mouseover, then unload the mouseover as well.
        if (CursorSelection.Instance.tileMouseOverScript != null)
        {
            CursorSelection.Instance.tileMouseOverScript.IsMouseOver = false;
        }
        //Set the turn state
        turnState = TurnStates.ResolutionPhase;
        //Drop the buttons out of the buttonsGUIFunction, which loads into the GUI master
        buttonsGUIFunction = null;
        //Drop the layer, undo, scrollbox, and player stats from the master GUI.
        guiFunction -= LayerSwitcher.Instance.GUIFunction;
        guiFunction -= TurnActionOrderHandler.Instance.UndoGUI;
        guiFunction -= GUISelectionBox;
        guiFunction -= SwitchButton.Instance.GUIPlayerStats;
        //If there are any functions to drop actions into the front or the back of the GUI stack, resolve them here.
        if (StackInsertFinalActions != null)
        {
            StackInsertFinalActions();
        }
        if (StackInsertInitialActions != null)
        {
            StackInsertInitialActions();
        }
        //Resolve and empty the Action list.
        TurnActionOrderHandler.Instance.ResolveActions();
        TurnActionOrderHandler.Instance.InitializeList();
        //If there's anything that should happen after the action stack has resolved and emptied, it should happen here.
        if (OnResolveTransitionFinal != null)
        {
            OnResolveTransitionFinal();
        }
    }
Beispiel #10
0
 public void _EnterEndPhase()
 {
     //Add in the layer buttons for viewing.
     guiFunction += LayerSwitcher.Instance.GUIFunction;
     //Change the phase
     turnState = TurnStates.EndPhase;
     //If anything happens at the beginning of the End phase, that should happen here.
     if (OnEndPhaseTransition != null)
     {
         OnEndPhaseTransition();
     }
 }
    void UpdateActionBar()
    {
        CurrentActionCD = CurrentActionCD + Time.deltaTime;
        float CalculateCD = CurrentActionCD / MaxActionCD;

        ActionBar.transform.localScale = new Vector3(Mathf.Clamp(CalculateCD, 0, 1), ActionBar.transform.localScale.y, ActionBar.transform.localScale.z);

        if (CurrentActionCD >= MaxActionCD)
        {
            currentState = TurnStates.addtolist;
        }
    }
Beispiel #12
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (Moving == 0)
            {
                Moving = 1;
            }
            else if (Moving == 1)
            {
                Moving = 0;
            }
        }

        switch (State)
        {
        case (TurnStates.PlayerTurn):
            Ray     ray           = cam.ScreenPointToRay(Input.mousePosition);
            Vector3 mousePosition = Input.mousePosition;
            mousePosition.z = 18f;
            target          = Camera.main.ScreenToWorldPoint(mousePosition);
            FindPathA_M2(Player.transform.position, target);
            if (Input.GetMouseButtonDown(0))
            {
                print("HELLO");
                MoveCharacter(Player);
                Destroy(pathHolder);
            }
            break;

        case (TurnStates.EnemyTurn):
            if (WhichEnemy < Enemies.Length)
            {
                if (EnemiesCheckSurrounding(WhichEnemy))
                {
                    FindPathA_M2(Enemies[WhichEnemy].transform.position, Player.transform.position);
                    MoveCharacter(Enemies[WhichEnemy]);
                }
                else
                {
                    EnemiesPatrol(WhichEnemy);
                }

                WhichEnemy++;
            }
            else
            {
                WhichEnemy = 0;
                State      = TurnStates.PlayerTurn;
            }
            break;
        }
    }
 public void StartTwoPlayer()
 {
     state         = TurnStates.Player1;
     player1.state = Player.PlayerStates.MyTurn;
     player1.isAI  = false;
     player2.state = Player.PlayerStates.OpponentsTurn;
     player2.isAI  = false;
     player1.gameObject.SetActive(true);
     player2.gameObject.SetActive(true);
     MenuPanel.gameObject.SetActive(false);
     GamePanel.SetActive(true);
 }
Beispiel #14
0
 public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
 {
     if (newStatus == TrackableBehaviour.Status.DETECTED ||
         newStatus == TrackableBehaviour.Status.TRACKED ||
         newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
     {
         status = TurnStates.TRACK;
     }
     else
     {
         status = TurnStates.LOST;
     }
 }
    public void ClickDefendButton()
    {
        //Turn on the defend status
        CurrentChar.Status_Defend = true;

        //Deactivate the UI
        APM.DeactivateAllPanel();

        //Move Target Arrow
        PlayerChars[0].GetComponent <PlayerStateMachine>().TargetArrow.transform.position = new Vector3(0, -5f, 0);

        //Immediatly go on to next turn
        TheTurn = TurnStates.WHOSNEXT;
    }
 public void changeTurn()
 {
     if (state == TurnStates.Player1) //change to player 2
     {
         state         = TurnStates.Player2;
         player1.state = Player.PlayerStates.OpponentsTurn;
         player2.state = Player.PlayerStates.MyTurn;
     }
     else if (state == TurnStates.Player2) //change to player 1
     {
         state         = TurnStates.Player1;
         player1.state = Player.PlayerStates.MyTurn;
         player2.state = Player.PlayerStates.OpponentsTurn;
     }
 }
 private void Start()
 {
     if (player1 != null && player2 != null && player1.isX != player2.isX)//not same player
     {
         state         = TurnStates.None;
         player1.state = Player.PlayerStates.None;
         player2.state = Player.PlayerStates.None;
         player1.gameObject.SetActive(false);
         player2.gameObject.SetActive(false);
         MenuPanel.SetActive(true);
         GamePanel.SetActive(false);
         GameOverPanel.SetActive(false);
         PauseGamePanel.SetActive(false);
     }
     else
     {
         Debug.LogWarning("Error with Players");
     }
 }
    ///////////////////////////////////////////////////////////////////////////////////////

    public void CheckForDQ()
    {
        //Check if match has DQs
        if (Refferee.DQ == true)
        {
            //Check if Refferee is down
            if (Refferee.Down == false)
            {
                StartCoroutine(DQStrikeChar());
                TheTurn = TurnStates.WAIT;
            }
            else
            {
                TheTurn = TurnStates.DONE;
            }
        }
        else
        {
            TheTurn = TurnStates.DONE;
        }
    }
    /**********************************************************************************************************/

    //Put BattleState Machine Constructor here with info inside

    /**********************************************************************************************************/
    // Use this for initialization
    void Start()
    {
        //Initialize States
        TheTurn = TurnStates.WHOSNEXT;

        ReffObj  = Instantiate(ReffObj);
        Refferee = ReffObj.GetComponent <ReffSM>();

        //Load Match Rules
        Refferee.LoadRulesAtStart(this);

        //Assign Character Positions
        AssignPositions();

        //Assign State Machines
        AssignStateMachines();

        //Add State Machines to list
        AddSMsToList();

        //Set up UI
        AssignStatPanels();
    }
 ResetTurnBasedGame()
 {
     TurnState = TurnStates.NotTurn;
 }
Beispiel #21
0
 void Start()
 {
     currentState = TurnStates.START;
 }
Beispiel #22
0
 private void startTurn()
 {
     curTurnState = TurnStates.TURN_START;
 }
Beispiel #23
0
 void Awake()
 {
     grid       = GetComponent <Grid>();
     pathHolder = new GameObject("PathHolder");
     State      = TurnStates.PlayerTurn;
 }
Beispiel #24
0
 public void OnChangeState(TurnStates newState)
 {
     //Set the new state
     state = newState;
 }
Beispiel #25
0
 public override void _Ready()
 {
     state = TurnStates.PLAYER_TURN;
 }
 // Use this for initialization
 void Start()
 {
     currentState = TurnStates.processing;
 }
    // Update is called once per frame
    void Update()
    {
        switch (TheTurn)
        {
        case (TurnStates.WAIT):
        {
            //idle state
            break;
        }

        case (TurnStates.WHOSNEXT):
        {
            //Disable NotePanel
            DeactivateNote();

            CurrentChar = GetNextTurn();

            if (CurrentChar.Status_Down == true)
            {
                TheTurn = TurnStates.ISDOWNED;
            }
            else
            {
                TheTurn = TurnStates.GETACTION;
            }

            break;
        }

        case (TurnStates.GETACTION):
        {
            CurrentChar.TurnState = BaseCharStateMachine.CharTurnState.GETACTION;
            TheTurn = TurnStates.WAIT;
            break;
        }

        case (TurnStates.PERFORMACTION):
        {
            //Take cost from currentchar once
            if (ThisTurn.Action.ActionStarted == false)
            {
                CurrentChar.TakeCostOfAction(ThisTurn.Action);
                DisplayNote();
            }

            // Perform Chosen Action
            StartCoroutine(ThisTurn.Action.PerformAction(ThisTurn.Actor, ThisTurn.Target));

            break;
        }

        case (TurnStates.REFFCHECK):
        {
            CheckForDQ();
            break;
        }

        case (TurnStates.DONE):
        {
            // If Character was Downed this turn, change their state and CurrentTurn gets another turn
            if (ThisTurn.Target.Status_Down == false && ThisTurn.Target.Stats.HP.Current == 0f)
            {
                DisplayNote(ThisTurn.Target.Stats.Name + " is Down!");

                ThisTurn.Target.Status_Down = true;
                if (ThisTurn.Target.Status_Defend == true)
                {
                    ThisTurn.Target.Status_Defend = false;
                }
                ThisTurn.Target.StartWP = ThisTurn.Target.Stats.WP.Current;
                TheTurn = TurnStates.GETACTION;
            }

            // Else, End turn
            else
            {
                TheTurn = TurnStates.WHOSNEXT;
            }

            Destroy(GameObject.Find(ThisTurn.Action.name));
            break;
        }

        case (TurnStates.ISDOWNED):
        {
            // This character tries to get up.
            CurrentChar.TurnState = BaseCharStateMachine.CharTurnState.DOWN;

            //Wait for update from Character State Maching
            TheTurn = TurnStates.WAIT;
            break;
        }

        case (TurnStates.MATCHFINISHED):
        {
            //For now, just check who won. Add character specific stuff later.
            bool pWin = false;

            foreach (BaseCharStateMachine Character in AllChars)
            {
                if (Character.TurnState == BaseCharStateMachine.CharTurnState.WIN && Character.type == "PLAYER")
                {
                    pWin = true;
                }
            }

            //Create Win Message
            string WinMessage = PlayerChars[0].GetComponent <PlayerStateMachine>().Stats.Name;

            for (int x = 1; x < PlayerChars.Count; x++)
            {
                if (x < PlayerChars.Count - 1)
                {
                    WinMessage = WinMessage + " and " + PlayerChars[x].GetComponent <PlayerStateMachine>().Stats.Name;
                }
                else
                {
                    WinMessage = WinMessage + ", " + PlayerChars[x].GetComponent <PlayerStateMachine>().Stats.Name;
                }
            }

            //If the player won, have that appear
            if (pWin)
            {
                WinMessage += " Win";
            }
            else
            {
                WinMessage += " Lose";
            }

            //Display Win Message
            DisplayNote(WinMessage + " by " + WinReason + "!");

            //Wait for scene transition
            StartCoroutine(EndOfMatch());
            TheTurn = TurnStates.WAIT;

            break;
        }
        }
    }