コード例 #1
0
 //  private int X1 = 24, X2 = -24, Z1 = 30, Z2 = -30;
 public StrikingState(MonoBehaviour parent)
     : base(parent)
 {
     gameController = (PoolGameController)parent;
     cue            = gameController.cue;
     cueBall        = gameController.cueBall;
 }
コード例 #2
0
        public WaitingForStrikeState(MonoBehaviour parent) : base(parent)
        {
            gameController = (PoolGameController)parent;
            PlayerPrefs.SetFloat("factor", 0.0f);
            gameController.gameState = StatesOfGame.WAITING_FOR_STRIKE_STATE;
            cue     = gameController.cue;
            cueBall = gameController.cueBall;
            PoolGameController.GameInstance.gameState = StatesOfGame.WAITING_FOR_STRIKE_STATE;

            line       = cueBall.GetComponent <LineRenderer> ();
            line2      = gameController.GetComponent <LineRenderer> ();
            text       = GameObject.FindGameObjectWithTag("Timer").GetComponent <Text> ();
            mainCamera = gameController.mainCamera;
            cue.GetComponent <Renderer> ().enabled = true;
            image = gameController.image;
            if (MoveImageScript.Instance != null)
            {
                MoveImageScript.Instance.handler += OnDragEvent;
            }
            else
            {
            }
            imagePanel = gameController.imagePanel;
            imagePanel.SetActive(true);
            cue.transform.position = cueBall.transform.position + gameController.strikeDirection * (-1) * PoolGameController.MIN_DISTANCE;
            cue.transform.position = new Vector3(cue.transform.position.x, 9f, cue.transform.position.z);
            cue.transform.RotateAround(cueBall.transform.position, Vector3.down, 0);

            //cue.transform.RotateAround (cueBall.transform.position, Vector3.up, 0);
        }
コード例 #3
0
 public StrikingState(MonoBehaviour parent)
     : base(parent)
 {
     gameController = (PoolGameController)parent;
     cue = gameController.cue;
     cueBall = gameController.cueBall;
 }
コード例 #4
0
 public cuePosition(MonoBehaviour parent) : base(parent)
 {
     game       = (PoolGameController)parent;
     cue        = game.cue;
     cueBall    = game.cueBall;
     mainCamera = game.mainCamera;
     cue.GetComponent <Renderer>().enabled = true;
 }
コード例 #5
0
        private PoolGameController gameController;         // assign the pool controller to game controller variable

        // Inheritance the pool game controller
        public WaitingForStrikeState(MonoBehaviour parent) : base(parent)
        {
            gameController = (PoolGameController)parent;
            cue            = gameController.cue;
            cue_ball       = gameController.cueBall;
            main_camera    = gameController.mainCamera;

            cue.GetComponent <Renderer>().enabled = true;
        }
コード例 #6
0
        public WaitingForStrikeState(MonoBehaviour parent)
            : base(parent)
        {
            gameController = (PoolGameController)parent;
            cue = gameController.cue;
            cueBall = gameController.cueBall;
            mainCamera = gameController.mainCamera;

            cue.GetComponent<Renderer>().enabled = true;
        }
コード例 #7
0
    void Awake()
    {
        GameInstance = this;
        pausedGame   = null;
//		Input.simulateMouseWithTouches = true;
        if (cue == null)
        {
        }
        CurrentPlayer = new Player("John", "Player1CollectedBalls");
    }
コード例 #8
0
 void Start()
 {
     strikeDirection = Vector3.forward;
     // sets the player name, if time let user set it
     Player_one   = new Player("P1");
     Player_two   = new Player("P2");
     GameInstance = this;
     winnerMessage.GetComponent <Canvas>().enabled = false;
     currentState = new GameStates.WaitingForStrikeState(this);
 }
コード例 #9
0
        public StrikeState(MonoBehaviour parent) : base(parent)
        {
            gameController = (PoolGameController)parent;
            cue            = gameController.cue;
            cueBall        = gameController.cueBall;

            var forceAmplitude   = gameController.maxForce - gameController.minForce;
            var relativeDistance = (Vector3.Distance(cue.transform.position, cueBall.transform.position) - PoolGameController.MIN_DISTANCE) / (PoolGameController.MAX_DISTANCE - PoolGameController.MIN_DISTANCE);

            force = forceAmplitude * relativeDistance + gameController.minForce;
        }
コード例 #10
0
        public cueForce(MonoBehaviour parent) : base(parent)
        {
            game    = (PoolGameController)parent;
            cue     = game.cue;
            cueBall = game.cueBall;

            var force    = game.maxForce - game.minForce;
            var distance = (Vector3.Distance(cue.transform.position, cueBall.transform.position) - PoolGameController.MIN_DISTANCE) / (PoolGameController.MAX_DISTANCE - PoolGameController.MIN_DISTANCE);

            game.force = force * distance + game.minForce;
        }
コード例 #11
0
ファイル: StrikeState.cs プロジェクト: sachgits/unity3d-pool
        public StrikeState(MonoBehaviour parent)
            : base(parent)
        {
            gameController = (PoolGameController)parent;
            cue = gameController.cue;
            cueBall = gameController.cueBall;

            var forceAmplitude = gameController.maxForce - gameController.minForce;
            var relativeDistance = (Vector3.Distance(cue.transform.position, cueBall.transform.position) - PoolGameController.MIN_DISTANCE) / (PoolGameController.MAX_DISTANCE - PoolGameController.MIN_DISTANCE);
            force = forceAmplitude * relativeDistance + gameController.minForce;
        }
コード例 #12
0
    void Start()
    {
        strikeDirection = Vector3.forward;
        CurrentPlayer   = new Player("John");
        OtherPlayer     = new Player("Doe");

        GameInstance = this;
        winnerMessage.GetComponent <Canvas>().enabled = false;

        currentState = new GameStates.WaitingForStrikeState(this);
    }
コード例 #13
0
 public nextTurn(MonoBehaviour parent) : base(parent)
 {
     game           = (PoolGameController)parent;
     cue            = game.cue;
     cueBall        = game.cueBall;
     mainCamera     = game.mainCamera;
     cameraOffset   = cueBall.transform.position - mainCamera.transform.position;
     cameraRotation = mainCamera.transform.rotation;
     cueOffset      = cueBall.transform.position - cue.transform.position;
     cueRotation    = cue.transform.rotation;
 }
コード例 #14
0
 void Start()
 {
     if (PoolGameController.GameInstance != null)
     {
         gameController = PoolGameController.GameInstance;
         cueBall        = gameController.cueBall;
     }
     else
     {
         cueBall = null;
     }
 }
コード例 #15
0
    void Start()
    {
        //   Physics.gravity = new Vector3(-112, 98, -16);
        strikeDirection = Vector3.left;
        CurrentPlayer   = new Player("Anan1");
        OtherPlayer     = new Player("Anan2");

        GameInstance = this;
        winnerMessage.GetComponent <Canvas>().enabled = false;

        currentState = new GameStates.WaitingForStrikeState(this);
    }
コード例 #16
0
    void Start()
    {
        originalCueBallPosition = cueBall.transform.position;
        if (PoolGameController.GameInstance != null)
        {
            gameController = PoolGameController.GameInstance;
        }

        collectionBox = GameObject.FindGameObjectWithTag("CollectionBox");
        if (collectionBox == null)
        {
            Debug.LogError("Not found");
        }
    }
コード例 #17
0
        public WaitingForNextTurnState(MonoBehaviour parent) : base(parent)
        {
            gameController = (PoolGameController)parent;

            cue        = gameController.cue;
            cueBall    = gameController.cueBall;
            redBalls   = gameController.redBalls;
            mainCamera = gameController.mainCamera;

            cameraOffset   = cueBall.transform.position - mainCamera.transform.position;
            cameraRotation = mainCamera.transform.rotation;
            cueOffset      = cueBall.transform.position - cue.transform.position;
            cueRotation    = cue.transform.rotation;
        }
コード例 #18
0
    void Awake()
    {
        GameInstance = this;
        pausedGame   = null;
//		Input.simulateMouseWithTouches = true;
        if (cue == null)
        {
        }
        CurrentPlayer = new Player("John", "Player1CollectedBalls");
        line3         = gameObject.GetComponent <LineRenderer> ();
        if (line3 == null)
        {
            Debug.LogError("Line rendered error ");
        }
    }
コード例 #19
0
        public WaitingForNextTurnState(MonoBehaviour parent)
            : base(parent)
        {
            gameController = (PoolGameController)parent;

            cue = gameController.cue;
            cueBall = gameController.cueBall;
            redBalls = gameController.redBalls;
            mainCamera = gameController.mainCamera;

            cameraOffset = cueBall.transform.position - mainCamera.transform.position;
            cameraRotation = mainCamera.transform.rotation;
            cueOffset = cueBall.transform.position - cue.transform.position;
            cueRotation = cue.transform.rotation;
        }
コード例 #20
0
        public StrikingState(MonoBehaviour parent) : base(parent)
        {
            gameController           = (PoolGameController)parent;
            cue                      = gameController.cue;
            cueBall                  = gameController.cueBall;
            gameController.gameState = StatesOfGame.STRIKING_STATE;
            line                     = cueBall.GetComponent <LineRenderer> ();
            line.startWidth          = 0;
            line.endWidth            = 0;
            line.enabled             = false;

            PoolGameController.GameInstance.gameState = StatesOfGame.STRIKING_STATE;

            factor = PlayerPrefs.GetFloat("factor", factor);
            K      = 0.1f;
        }
コード例 #21
0
        public StrikeState(MonoBehaviour parent) : base(parent)
        {
            gameController           = (PoolGameController)parent;
            gameController.gameState = StatesOfGame.STRIKE_STATE;
            cue     = gameController.cue;
            cueBall = gameController.cueBall;
            factor  = gameController.factor;
            var forceAmplitude   = gameController.maxForce - gameController.minForce;
            var relativeDistance = (Vector3.Distance(cue.transform.position, cueBall.transform.position) - PoolGameController.MIN_DISTANCE) / (PoolGameController.MAX_DISTANCE - PoolGameController.MIN_DISTANCE);

            force      = forceAmplitude * factor + gameController.minForce;
            imagePanel = gameController.imagePanel;
            imagePanel.SetActive(false);
            PoolGameController.GameInstance.gameState = StatesOfGame.STRIKE_STATE;

            line            = cueBall.GetComponent <LineRenderer> ();
            line.startWidth = 0;
            line.endWidth   = 0;
        }
コード例 #22
0
        public WaitingForNextTurnState(MonoBehaviour parent) : base(parent)
        {
            gameController           = (PoolGameController)parent;
            gameController.gameState = StatesOfGame.WAITING_FOR_NEXT_PLAYER_STATE;

            cue        = gameController.cue;
            cueBall    = gameController.cueBall;
            redBalls   = gameController.redBalls;
            mainCamera = gameController.mainCamera;

            PoolGameController.GameInstance.gameState = StatesOfGame.WAITING_FOR_NEXT_PLAYER_STATE;

            cue.transform.position = cueBall.transform.position + gameController.strikeDirection * (-1) * PoolGameController.MIN_DISTANCE;
            cue.transform.position = new Vector3(cue.transform.position.x, 4.55f, cue.transform.position.z);
            cue.transform.RotateAround(cueBall.transform.position, Vector3.down, 0);


            cameraOffset   = cueBall.transform.position - mainCamera.transform.position;
            cameraRotation = mainCamera.transform.rotation;
            cueOffset      = cueBall.transform.position - cue.transform.position;
            cueRotation    = cue.transform.rotation;
            Debug.Log("waiting for next Player ");
        }
コード例 #23
0
 public PlaceCueBallState(MonoBehaviour parent) : base(parent)
 {
     gameController = (PoolGameController)parent;
     cueBall        = gameController.cueBall;
     cue            = gameController.cue;
 }
コード例 #24
0
 void Start()
 {
     cueBallDirection = Vector3.forward;
     GameInstance     = this;
     currentState     = new Game.cuePosition(this);
 }
コード例 #25
0
    void Start()
    {
        strikeDirection = Vector3.forward;
        CurrentPlayer = new Player("John");
        OtherPlayer = new Player("Doe");

        GameInstance = this;
        winnerMessage.GetComponent<Canvas>().enabled = false;

        currentState = new GameStates.WaitingForStrikeState(this);
    }
コード例 #26
0
 public FinishState(MonoBehaviour parent) : base(parent)
 {
     gameController           = (PoolGameController)parent;
     time                     = gameController.t;
     gameController.gameState = StatesOfGame.FINISH_STATE;
 }
コード例 #27
0
        //private float speed = 50;

        public cueSpeed(MonoBehaviour parent) : base(parent)
        {
            game    = (PoolGameController)parent;
            cue     = game.cue;
            cueBall = game.cueBall;
        }