Example #1
0
    void Start()
    {
        collectionBox = GameObject.FindGameObjectWithTag("CollectionBox");
        if (canvas.activeInHierarchy == false)
        {
            Debug.LogError("canvas is not active");
            canvas.SetActive(true);
        }
        if (poolTable.activeInHierarchy == false)
        {
            poolTable.SetActive(true);
        }

        if (cueBall.activeInHierarchy == false)
        {
            cueBall.SetActive(true);
        }

        if (cue.activeInHierarchy == false)
        {
            cue.SetActive(true);
        }

        if (redBalls.activeInHierarchy == false)
        {
            redBalls.SetActive(true);
        }
        #region resetVariables
        redBallsResetPosition = new List <Vector3>();
        cueResetPosition      = cue.transform.position;
        for (int i = 0; i < redBalls.transform.childCount; i++)
        {
            redBallsResetPosition.Add(redBalls.transform.GetChild(i).position);
            Debug.Log(redBallsResetPosition[i]);
        }

        #endregion
        factor          = 0;
        cuePosition     = Vector3.zero;
        strikeDirection = Vector3.forward;

        //OtherPlayer = new Player("Doe","Player2CollectedBalls");
        imagePanel = GameObject.FindGameObjectWithTag("imagePanel");
        imagePanel.SetActive(false);
        image = GameObject.FindGameObjectWithTag("cueImage");


        if (cueBallCanvas == null)
        {
            Debug.LogError("Not found error ");
        }

        winnerMessage.GetComponent <Canvas>().enabled = false;
        gameState = StatesOfGame.WAITING_FOR_STRIKE_STATE;

        currentState = new GameStates.WaitingForStrikeState(this);
    }
Example #2
0
    void Update()
    {
        gameState = PoolGameController.GameInstance.gameState;
        switch (gameState)
        {
        case StatesOfGame.STRIKE_STATE:
        {
            break;
        }

        case StatesOfGame.STRIKING_STATE:
        {
            break;
        }

        case StatesOfGame.WAITING_FOR_NEXT_PLAYER_STATE:
        {
            break;
        }

        case StatesOfGame.WAITING_FOR_STRIKE_STATE:
        {
            /*(	RaycastHit hit;
             *      Ray ray = new Ray ();
             *      ray.origin = gameObject.transform.position;
             *      ray.direction = PoolGameController.GameInstance.strikeDirection;
             *      if (Physics.Raycast(ray,out hit)) {
             *              if (hit.collider.tag == "redball") {
             *
             *                      line.SetPosition (0, gameObject.transform.position);
             *                      line.SetPosition (1, hit.point);
             *                      Debug.LogError (hit.point+"+++++++++++++++++++"+hit.collider.transform.position);
             *                      //line.SetPosition (2, hit.point);
             *                      line.SetPosition (2, hit.collider.gameObject.transform.position);
             *
             *                      Vector3 direction = (hit.point - hit.collider.gameObject.transform.position).normalized;
             *                      direction = direction * (-1);
             *                      Vector3 desiredPoint = hit.collider.gameObject.transform.position - 2.0f * direction;
             *                      line.SetPosition (3, desiredPoint);
             *                      line.startWidth = 1;
             *                      line.endWidth = 0;
             *                      line.startColor = Color.white;
             *                      line.endColor = Color.white;
             *
             *              }
             *              else {
             *                      line.SetPosition (2, Vector3.zero);
             *                      line.SetPosition (3, Vector3.zero);
             *              //	line.SetPosition (4, Vector3.zero);
             *              }
             *      }*/
            break;
        }
        }
    }
Example #3
0
 //called from GameCommunication when results arrive
 internal void ShowResultsFromGc(TurnResults tr)
 {
     if (StateOfGame == StatesOfGame.GameEnded)
     {
         return;
     }
     if (StateOfGame != StatesOfGame.WaitingForOpponent)
     {
         throw new ApplicationException("Wrong flow");
     }
     ShowDebugMessage("StatesOfGame.ShowingResults");
     StateOfGame = StatesOfGame.ShowingResults;
     ShowResults(tr);
 }
Example #4
0
        //called from GUI
        public void DoneShowingResults()
        {
            if (StateOfGame == StatesOfGame.GameEnded)
            {
                return;
            }
            if (StateOfGame != StatesOfGame.ShowingResults)
            {
                throw new ApplicationException("Wrong flow");
            }

            ShowDebugMessage("StatesOfGame.PlayerDeclaringTurn");
            StateOfGame = StatesOfGame.PlayerDeclaringTurn;
        }
Example #5
0
 //called from GUI
 public void DeclarePlayerTurn(PlayerTurn pt)
 {
     if (StateOfGame == StatesOfGame.GameEnded)
     {
         return;
     }
     if (StateOfGame != StatesOfGame.PlayerDeclaringTurn)
     {
         throw new ApplicationException("Wrong flow");
     }
     StateOfGame = StatesOfGame.WaitingForOpponent;
     ShowDebugMessage("Sending turn to gamecommunication");
     ShowDebugMessage("StatesOfGame.WaitingForOpponent");
     _gc.ThisPlayerTurn(pt);
 }
Example #6
0
 public GameManager(List <Character> chars, int size, Action <TurnResults> sr, Action <string> sm, Action <List <Character> > actualizeCharacters, bool host, string ipAdress, string port)
 {
     Map                  = new Map(chars, size);
     ShowResults          = sr;
     ShowMessage          = sm;
     _actualizeCharacters = actualizeCharacters;
     StateOfGame          = StatesOfGame.PlayerDeclaringTurn;
     if (host)
     {
         _gc = new GameHost(ipAdress, port, this);
     }
     else
     {
         _gc = new GameClient(ipAdress, port, this);
     }
 }
Example #7
0
 void Start()
 {
     gameState = PoolGameController.GameInstance.gameState;
     line      = gameObject.GetComponent <LineRenderer> ();
 }
Example #8
0
 public void EndOfGame()
 {
     StateOfGame = StatesOfGame.GameEnded;
     ShowMessage("Game ended");
 }