예제 #1
0
        public void PhaseEnd()
        {
            var go = new GameObject();
            // create a WARGame object to store the game phase
            var game = go.AddComponent <WARGame>() as WARGame;

            WARGame.Instance = game;
            // and out gameplay controller to step through the phases
            var gameplay = new GameObject().AddComponent <WARControlGameplay>() as WARControlGameplay;

            WARControlGameplay.Instance = gameplay;
            gameplay.Start();

            // create players to add to our game
            WARGame.Players.Add(new WARPlayer(1));
            WARGame.Players.Add(new WARPlayer(2));

            // the phase we are starting in
            GAME_PHASE startPhase = GAME_PHASE.morale;
            // the phase we expect to transition to
            GAME_PHASE expectedPhase = GAME_PHASE.movement;

            // set the phase to our start phase
            WARGame.SetPhase(startPhase);
            // move to the next phase
            gameplay.nextPhase();

            // make sure we got the desired phase transition
            Assert.AreEqual(expectedPhase, WARGame.Phase.Value.current);
            // destroy the gameplay controller to clean up subscriptions
            gameplay.OnDestroy();
        }
예제 #2
0
        public void TurnTransition()
        {
            var go = new GameObject();
            // create a WARGame object to store the game phase
            var game = go.AddComponent <WARGame>() as WARGame;

            WARGame.Instance = game;
            // and out gameplay controller to step through the phases
            var gameplay = new GameObject().AddComponent <WARControlGameplay>() as WARControlGameplay;

            WARControlGameplay.Instance = gameplay;
            gameplay.Start();

            // create players to add to our game
            WARGame.Players.Add(new WARPlayer(1));
            WARGame.Players.Add(new WARPlayer(2));

            int currentPlayer = 1;
            int targetPlayer  = 2;

            // set the current player
            WARControlGameplay.CurrentPlayer = currentPlayer;
            // set the phase to our start phase
            WARGame.SetPhase(GAME_PHASE.morale);
            // move to the next phase
            gameplay.nextPhase();

            // make sure we got the desired phase transition
            Assert.AreEqual(targetPlayer, WARControlGameplay.CurrentPlayer);
            // destroy the gameplay controller to clean up subscriptions
            gameplay.OnDestroy();
        }
    // the response to clicking when in deployment places a cell owned by the current user
    public void addObject(Vector3 pos)
    {
        // find the cell underneath the point we clicked
        RaycastHit hit;
        int        layerMask = 1 << (int)Layers.TableTile;

        // if there is an object under the vector
        if (Physics.Raycast(ray: Camera.main.ScreenPointToRay(pos), hitInfo: out hit, maxDistance: 5, layerMask: layerMask))
        {
            // the id of the cell we clicked on
            var id = hit.collider.GetComponent <WARActorCell>().id;


            // add a ship to play with
            var ship = GameObject.Instantiate(
                WARToolUnitFinder.GetByArmyUnitName("Shmoogaloo", "ShmooTroop")
                ).GetComponent <WARUnit>() as WARUnit;
            ship.owner = WARControlGameplay.CurrentPlayer;
            WARControlBoard.AddObjectsToCell(id, new List <WARGridObject> {
                ship as WARGridObject
            });

            // place the ship over the cell
            //ship.transform.position = WARControlBoard.Grid.GetCell(id).transform.position;

            // we're done deploying
            WARGame.SetMode(GAME_MODE.gameplay);
        }
    }