Exemplo n.º 1
0
 public void TestAttack1()
 {
     //List<Gameobject> enemiesToDamage = selectenemies(1);
     //enemyToDamge.takedamage(10)
     Debug.Log("skill used");
     turn.EndTurn();
 }
Exemplo n.º 2
0
    void Update()
    {
        /*Game Phases:
         *      - Player idle
         *      - Player choose weapon
         *      - Player shoot
         *      - Change turn
         *      (Repeat process until somone dies)
         */
        if (Input.GetKeyDown(KeyCode.P))
        {
            // check player, game will start when player press space
            playerMove();
            Debug.Log("Game started");
            //player1Turn = turnController.changeTurn;
            generatePlayers(2);
            turnController.Initialize(characters);
            turnController.GenerateTurnOrder();
            turnController.BeginTurn();
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            turnController.EndTurn();
            turnController.NextTurn();

            var player = turnController.WhoIsActive();
            if (player.GetComponent <Character>().isDead)
            {
                spawnController.SpawnPlayer(player);
            }

            turnController.BeginTurn();
        }
    }
Exemplo n.º 3
0
 public void NextLine()
 {
     if (writer.isTyping == false)
     {
         if (startingText)
         {
             startingText = false;
             turnSystem.StartTurn();
             if (turnSystem.FirstTurn && turnSystem.enemies[0].name.Equals("Player"))
             {
                 Debug.Log("Runda Gracza");
                 ms.swapMenu("Main");
             }
         }
         else
         {
             if ((turnSystem.index < turnSystem.enemies.Count - 1 && turnSystem.enemies[turnSystem.index + 1].name.Equals("Player")) || (turnSystem.index == turnSystem.enemies.Count - 1 && turnSystem.enemies[0].name.Equals("Player")))
             {
                 Debug.Log("Runda Gracza");
                 ms.swapMenu("Main");
             }
             else
             {
                 gameObject.SetActive(false);
             }
             turnSystem.EndTurn();
         }
     }
     else
     {
         writer.Skip();
     }
 }
Exemplo n.º 4
0
    IEnumerator SelectNextObject()
    {
        if (SelectedCardObject != null)
        {
            SelectedCardObject.CombatChangeObservers -= SelectedObjectCombatChange;
            SelectedCardObject.MoveChangeObservers   -= SelectedObjectMoveStateChange;
        }

        // Select next object available
        if (index + 1 <= enemyCardObjectsOut.Count)
        {
            if (SelectedObjectAttacked)
            {
                // Wait for the combat scenes to end
                yield return(new WaitForSeconds(1.5f));

                SelectedCardObject = enemyCardObjectsOut[index];
            }
            else
            {
                SelectedCardObject = enemyCardObjectsOut[index];
                yield return(new WaitForSeconds(.1f));
            }

            SelectedObjectAttacked = false;
            SelectObject(enemyCardObjectsOut[index]);
        }
        // If no next object available end turn
        else
        {
            // Debug.Log("TurnOver");
            turnSystem.EndTurn(2);
        }
    }
Exemplo n.º 5
0
        public void EndTurnTest5()
        {
            TurnSystem.InitializeData();

            TurnSystem.FirstMove = false;
            TurnSystem.EndTurn();
            bool result = TurnSystem.FirstMove;

            GameMechanics.ResetGame();

            Assert.AreEqual(true, result);
        }
Exemplo n.º 6
0
        public void EndTurnTest3()
        {
            TurnSystem.InitializeData();

            TurnSystem.BrownPlayerTurn = true;
            TurnSystem.EndTurn();
            int layer = CheckerManager.BrownCheckers[0].GameObj.layer;

            GameMechanics.ResetGame();

            Assert.AreEqual(0, layer);
        }
Exemplo n.º 7
0
        public void EndTurnTest2()
        {
            TurnSystem.InitializeData();

            GameMechanics.Move(CheckerManager.BrownCheckers[0].GameObj, new Vector3(1, 0, 7));
            GameMechanics.Move(CheckerManager.BrownCheckers[1].GameObj, new Vector3(3, 0, 7));
            GameMechanics.Move(CheckerManager.BrownCheckers[2].GameObj, new Vector3(5, 0, 7));
            GameMechanics.Move(CheckerManager.BrownCheckers[3].GameObj, new Vector3(7, 0, 7));
            GameMechanics.Move(CheckerManager.BrownCheckers[4].GameObj, new Vector3(9, 0, 7));

            GameMechanics.Move(CheckerManager.BrownCheckers[5].GameObj, new Vector3(2, 0, 6));
            GameMechanics.Move(CheckerManager.BrownCheckers[6].GameObj, new Vector3(4, 0, 6));
            GameMechanics.Move(CheckerManager.BrownCheckers[7].GameObj, new Vector3(6, 0, 6));
            GameMechanics.Move(CheckerManager.BrownCheckers[8].GameObj, new Vector3(8, 0, 6));
            GameMechanics.Move(CheckerManager.BrownCheckers[9].GameObj, new Vector3(10, 0, 6));

            TurnSystem.EndTurn();
            string result = GameObject.Find("PlayerWinsText").GetComponent <TMPro.TextMeshPro>().text;

            GameMechanics.ResetGame();

            Assert.AreEqual("Brown player wins", result);
        }
Exemplo n.º 8
0
    //Update is called once per frame
    void Update()
    {
        //Set checkers color depending on their state
        MaterialsManager.SetMaterialsToDefault(this);

        //If player cursor points on clickable object
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100, clickableLayer.value))
        {
            //Assign pointed object to variable
            GameObject selectedObject = hit.collider.gameObject;

            //Change cursor texture to "clickable" and change pointed checker color to white
            CursorManager.SetCursorToClickablePointer(this);
            MaterialsManager.ChangeObjectMaterialTo(this, selectedObject, 4);

            //If left mouse button was clicked
            if (Input.GetMouseButtonDown(0))
            {
                if (selectedObject.tag == "Exit")
                {
                    GameMechanics.Exit();
                }

                if (selectedObject.tag == "Restart")
                {
                    TurnSystem.StartGame();
                }

                //If player tries to move or jump
                if (selectedObject.tag == "Field" && GameMechanics.AnyCheckerIsSelected())
                {
                    //Distance variable measures distance between selected checker, and field on which player wants to move
                    //Basing on that distance, you can check if player tries to move or jump
                    double distance = Vector3.Distance(CheckerManager.SelectedChecker().GameObj.transform.position, selectedObject.transform.position);

                    //If player tries to move
                    if (distance < 1.65f)
                    {
                        //If its players first move allow to move, otherwise if player already jumped, allow only next jumps(if they are possible)
                        if (TurnSystem.FirstMove)
                        {
                            //Player have to always jump if its possible
                            if (GameMechanics.IsAnyJumpPossible(CheckerManager.SelectedChecker().PlayerColor))
                            {
                                Debug.Log("You have to jump.");
                            }

                            //If its first move and move is allowed, move player
                            else
                            if (GameMechanics.IsMovePossible(CheckerManager.SelectedChecker().GameObj, selectedObject))
                            {
                                GameMechanics.Move(CheckerManager.SelectedChecker().GameObj, selectedObject.transform.position);
                                TurnSystem.EndTurn();
                            }
                        }

                        //If player already jumped and tries to move instead of jumping
                        else
                        {
                            Debug.Log("You have to jump.");
                        }
                    }

                    //If player tries to jump
                    if (distance > 1.65f && distance < 2.95f)
                    {
                        if (GameMechanics.IsJumpPossible(CheckerManager.SelectedChecker().GameObj, selectedObject))
                        {
                            CheckerManager.RemoveEnemyBetween(CheckerManager.SelectedChecker().GameObj, selectedObject);
                            GameMechanics.Move(CheckerManager.SelectedChecker().GameObj, selectedObject.transform.position);
                            TurnSystem.FirstMove = false;

                            //If selected checker after previous jump can do another jump, dont end turn and let user know that next move is possible
                            if (GameMechanics.CanCheckerJump(CheckerManager.SelectedChecker()))
                            {
                                Debug.Log("Next move is possible");
                            }

                            else
                            {
                                TurnSystem.EndTurn();
                            }
                        }
                    }
                }

                //If player didn't click on selected checker, deselect previous selected checker
                if (GameMechanics.AnyCheckerIsSelected() && CheckerManager.SelectedChecker().GameObj != selectedObject)
                {
                    CheckerManager.DeselectCheckers();
                }

                CheckerManager.SelectChecker(selectedObject);
            }
        }

        //If cursor doesn't point on anything clickable
        else
        {
            CursorManager.SetCursorToNormalPointer(this);

            if (Input.GetMouseButtonDown(0))
            {
                CheckerManager.DeselectCheckers();
            }
        }
    }
Exemplo n.º 9
0
 public void EndTurn()
 {
     turnSystem.EndTurn();
 }