예제 #1
0
        private Aggression getOpponentAggression(Positioning positioning)
        {
            GamePhase previousPhase    = currentGame.Phase - 1;
            var       previousHistory  = actionHistoriesPerPhase.FirstOrDefault(x => x.Phase == previousPhase);
            var       secondLastAction = previousHistory.ActionHistory[previousHistory.ActionHistory.Count - 2];

            // only betting is considered to be aggressive
            if (secondLastAction == FeatureAction.Bet)
            {
                if (previousHistory.ActionHistory.Count % 2 == 0)
                {
                    if (positioning == Positioning.InPosition)
                    {
                        return(Aggression.IsNotLast);
                    }
                    else
                    {
                        return(Aggression.IsLast);
                    }
                }
                else
                {
                    if (positioning == Positioning.InPosition)
                    {
                        return(Aggression.IsLast);
                    }
                    else
                    {
                        return(Aggression.IsNotLast);
                    }
                }
            }

            return(Aggression.None);
        }
예제 #2
0
    void handleBackup(bool refresh, int startCtrl)
    {
        if (!refresh)
        {
            ctrl           += startCtrl;
            backupCtrlCount = ctrl;
        }
        else
        {
            ctrl = backupCtrlCount;
        }

        curPhase = GamePhase.Prep;

        if (refresh)
        {
            ih.loadBackup();
        }
        else
        {
            ih.clearBackup();
            if (ih.unitInventory.Count > 0)
            {
                ih.backupInventory();
            }
        }
    }
예제 #3
0
	void OnGamePhaseChanged (GamePhase previous, GamePhase current) {
		switch ( current ) {
		case GamePhase.Selection:
			gameOverPanel.SetActive ( false );
			
			stockPanel.SetLocalX ( -2000f );
			Go.to ( stockPanel.transform, 1f, new GoTweenConfig()
				.setEaseType (GoEaseType.ElasticOut)
				.localPosition ( new Vector3 ( 0, 106.6675f, 0), false));
			
				
			break;
			
		case GamePhase.Building:
			Go.to ( stockPanel.transform, 0.5f, new GoTweenConfig()
				.setEaseType (GoEaseType.BackIn)
				.localPosition ( new Vector3 ( -2000f, 106.6675f, 0), false));
			break;
			
		case GamePhase.Defending:
			
			break;
			
		case GamePhase.GameOver:
			gameOverPanel.transform.localScale = Vector3.zero;
			gameOverPanel.SetActive ( true );
			Go.to ( gameOverPanel.transform, 1f, new GoTweenConfig()
				.setEaseType (GoEaseType.ElasticOut)
				.scale ( Vector3.one, false ) );
			
			break;
		}
	}
예제 #4
0
 public void ForceGameStart()
 {
     if (CurrentPhase == GamePhase.LOBBY)
     {
         CurrentPhase = GamePhase.RUNNING;
     }
 }
예제 #5
0
    public static void ChangePlayerDeploy(GamePhase gP)
    {
        SpriteState tempState = new SpriteState();

        instance.deployButtons[0].image.sprite = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "Button");
        tempState.highlightedSprite            = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "Button");
        tempState.pressedSprite  = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "ButtonPressed");
        tempState.disabledSprite = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "ButtonDisabled");
        instance.deployButtons[0].spriteState  = tempState;
        instance.deployButtons[1].image.sprite = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "Button");
        tempState.highlightedSprite            = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "Button");
        tempState.pressedSprite  = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "ButtonPressed");
        tempState.disabledSprite = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "ButtonDisabled");
        instance.deployButtons[1].spriteState  = tempState;
        instance.deployButtons[2].image.sprite = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "Button");
        tempState.highlightedSprite            = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "Button");
        tempState.pressedSprite  = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "ButtonPressed");
        tempState.disabledSprite = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "ButtonDisabled");
        instance.deployButtons[2].spriteState = tempState;

        if (gP != GamePhase.Deploy)
        {
            SetPlayerUnitInfo();
        }
    }
예제 #6
0
    private void _PlayMusic(GamePhase phase)
    {
        AudioClip music = m_outsideBodyMusic;

        switch (phase)
        {
        case GamePhase.OutsideBody:
            music = m_outsideBodyMusic;
            break;

        case GamePhase.Wound:
            music = m_onWoundMusic;
            break;

        case GamePhase.Preparation:
            music = m_preparationMusic;
            break;

        case GamePhase.Invasion:
            music = m_invasionMusic;
            break;
        }

        if ((music == m_audioSource.clip) && (m_audioSource.isPlaying))
        {
            return;
        }

        m_audioSource.clip = music;
        m_audioSource.Play();
        m_audioSource.loop = true;
    }
예제 #7
0
    public void MoveNext(GamePhase type)
    {
        if (currentState != null)
        {
            Debug.Log("MoveNext first state " + currentState.ToString());
            currentState.OnExit();
        }

        if (type != GamePhase.ResumeGame)
        {
            try
            {
                String commentary = "State manager go to the state " + type.ToString();
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }

            GameManager.instance.SetCurrentState(type);
            Visual.instance.DisableVisualElementsOnStateEnter();
            GameLogicEvents.CopyGameActorsToCurrentGame();
            SaveLoadHelper.Save(SaveLoadHelper.defaultPrefixString);
            GameManager.instance.RemoveStateComponentsFromActor();

            Visual.instance.UpdateCounters();
        }

        currentState = dictionary[type];

        Visual.instance.disableInput(false);
        currentState.OnEnter();
    }
예제 #8
0
        public GameStatus Click(int x, int y)
        {
            int cellX = GetCellXByRealX(x);
            int cellY = GetCellYByRealY(y);

            Cell clickedCell = GetCellByPosition(cellX, cellY);

            if (_gamePhase == GamePhase.Interaction)
            {
                clickedCell.IsSelected = true;
                _gamePhase             = GamePhase.Selection;
            }
            else if (_gamePhase == GamePhase.Selection)
            {
                Cell selectedCell = GetSelected();
                if (IsTheyNeigbors(clickedCell, selectedCell))
                {
                    swapCell1 = clickedCell;
                    swapCell2 = selectedCell;

                    selectedCell.IsSelected = false;

                    _gamePhase = GamePhase.Swap;
                    Swap(clickedCell, selectedCell);
                }
                else
                {
                    selectedCell.IsSelected = false;
                    _gamePhase = GamePhase.Interaction;
                }
            }

            return(GameStatus.GameScreen);
        }
예제 #9
0
        public void Fall()
        {
            _lastAnimatedCells.Clear();

            _gamePhase = GamePhase.Animation;
            for (int col = 0; col < _cellCols; col++)
            {
                int rowDestroyed = 0;
                for (int row = _cellRows - 1; row >= 0; row--)
                {
                    if (Field[col, row].IsDestroyed)
                    {
                        rowDestroyed++;
                    }
                    if (rowDestroyed > 0 && !Field[col, row].IsDestroyed)
                    {
                        int newRow = row + rowDestroyed;
                        Field[col, row].MoveTo(new Vector2(GetRealXbyCellX(col), GetRealYbyCellY(newRow)));
                        Field[col, newRow] = Field[col, row];
                    }
                }

                for (int row = 0; row < rowDestroyed; row++)
                {
                    Field[col, row] = new Cell(GetRandomCellType(), new Vector2(GetRealXbyCellX(col), (_cellSizeInPx + _betweenCellsInPx) * (rowDestroyed - row) * -1));
                    Field[col, row].ActionCompleted += Cell_ActionCompleted;
                    Field[col, row].MoveTo(new Vector2(GetRealXbyCellX(col), GetRealYbyCellY(row)));
                }
            }
            UpdatePhase();
        }
예제 #10
0
    // main coroutine for scene changing
    IEnumerator ChageScene(int sceneIndex)
    {
        // fades panel in
        yield return(new WaitUntil(() => { return Fade(true); }));

        // loads scene
        yield return(SceneManager.LoadSceneAsync(sceneIndex, LoadSceneMode.Single));

        // gets ref of new scene
        onLoadingDone.Invoke();
        Debug.Log(debugableInterface.debugLabel + "Called specific transition method");

        // calls generic action (generally gets popup refs and init specific popup)
        genericSceneAction.Invoke();

        // fades panel out
        yield return(new WaitUntil(() => { return Fade(false); }));

        // calls transition event
        eventsManager.CallPhaseActions(nextPanel);

        // sets actualPanel
        actualPanel  = nextPanel;
        inTransition = false;
        yield break;
    }
예제 #11
0
    public void load()
    {
        string     svname   = GameObject.Find("panelMenu").gameObject.transform.GetChild(1).GetComponent <InputField>().text;
        MySaveGame loadGame = SaveGameSystem.LoadGame(svname) as MySaveGame;


        numberOfPlayer    = loadGame.numberOfPlayer;
        VPsToWin          = loadGame.VPsToWin;
        barbarianPosition = loadGame.barbarianPosition;
        barbarianAttacked = loadGame.barbarianAttacked;
        barbarianStrength = loadGame.barbarianStrength;
        knightStrength    = loadGame.knightStrength;
        currentPhase      = loadGame.currentPhase;
// pgcard


        List <int> number      = loadGame.numbers;
        List <int> terrians    = loadGame.terrains;
        List <int> harbortypes = loadGame.harbortypes;


        for (int i = 0; i < numberOfPlayer; i++)
        {
            myPlayers._players[i].LoadData(myPlayers._players[i].connectionToClient, svname);
        }
        Debug.Log(loadGame);
        Debug.Log(loadGame.numbers);


        // TODO load
    }
예제 #12
0
	public void SetPhase(int p){
		if(_phase != null){
			Destroy(_phase.gameObject);
		}
		currentPhase = p;
		_phase = (GamePhase)Instantiate(phases[p]);
	}
예제 #13
0
        private void Start()
        {
            GameStartCountdown.instance.RegisterListener(this);

            phase = GamePhase.COUNTING_DOWN;
            GameStartCountdown.instance.StartCountdown();
        }
예제 #14
0
    void OnGamePhaseChanged(GamePhase previous, GamePhase current)
    {
        switch (current)
        {
        case GamePhase.Selection:
            if (IsInvoking("GenerateEnemy"))
            {
                CancelInvoke("GenerateEnemy");
            }
            break;

        case GamePhase.Building:
            if (IsInvoking("GenerateEnemy"))
            {
                CancelInvoke("GenerateEnemy");
            }

            InvokeRepeating("GenerateEnemy", 5, interval);

            break;

        case GamePhase.GameOver:
            if (IsInvoking("GenerateEnemy"))
            {
                CancelInvoke("GenerateEnemy");
            }
            break;
        }
    }
예제 #15
0
        public void ServerStart()
        {
            gamePhase = GamePhase.LOBBY;
            players   = new Dictionary <NetworkConnection, ConnectedPlayer>();
            viewers   = new Dictionary <NetworkConnection, ConnectedViewer>();
            Transport.activeTransport = GetComponent <TelepathyTransport>();

            #region Password Creation
            char[] charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
            lobbyPassword = "";
            for (int i = 0; i < PASSWORD_LENGTH; i++)
            {
                lobbyPassword += charList[UnityEngine.Random.Range(0, charList.Length)];
            }
            Debug.Log("The server password is: {}");
            #endregion

            #region Client Messages
            NetworkServer.RegisterHandler <NetMsg.Client.PlayerJoin>(OnPlayerJoin);
            NetworkServer.RegisterHandler <NetMsg.Client.ActResultsMsg>(OnActResults);
            #endregion
            #region Viewer Messages
            NetworkServer.RegisterHandler <NetMsg.Viewer.Settings>(OnGameSettings);
            NetworkServer.RegisterHandler <NetMsg.Viewer.ViewerLink>(OnViewerLink);
            NetworkServer.RegisterHandler <NetMsg.Viewer.GameStart>(OnGameStart);
            #endregion
            #region Other Messages
            NetworkServer.RegisterHandler <ConnectMessage>(OnConnect);
            NetworkServer.RegisterHandler <DisconnectMessage>(OnDisconnect);
            #endregion

            NetworkServer.Listen(MAX_CONNECTIONS);
        }
예제 #16
0
    public void EnableDisableControls(GamePhase gamePhase, bool clicksRemain, bool waitingForOpponent)
    {
        //Debug.Log("EnableDisableControls");
        ((Button)ClickForCreditsButton.GetComponent(typeof(Button))).interactable = clicksRemain;
        ((Button)ClickForCardsButton.GetComponent(typeof(Button))).interactable   = clicksRemain;

        // some controls only available when in logistics planning and clicks remain
        bool planningClicksRemain = gamePhase == GamePhase.LOGISTICS_PLANNING && clicksRemain;

        ((Button)EndPhaseButton.GetComponent(typeof(Button))).interactable = waitingForOpponent == false &&
                                                                             (
            gamePhase == GamePhase.COMBAT_PLANNING ||
            (gamePhase == GamePhase.LOGISTICS_PLANNING && clicksRemain == false)
                                                                             );

        // handle "advance construction" buttons
        var constructionHandlers = FindObjectsOfType <AdvanceConstructionHandler>();

        foreach (AdvanceConstructionHandler handler in constructionHandlers)
        {
            (handler.GetComponent <Button>()).interactable = planningClicksRemain ||
                                                             (gamePhase == GamePhase.LOGISTICS_PLANNING && handler.IsComplete());
        }

        // handle weapon buttons
        var weaponHandlers = FindObjectsOfType <WeaponHandler>();

        foreach (WeaponHandler handler in weaponHandlers)
        {
            (handler.GetComponent <Button>()).interactable = (handler.BelongsToPlayer) &&
                                                             (gamePhase == GamePhase.COMBAT_PLANNING);
        }
    }
예제 #17
0
    protected override void OnGamePhaseChanged(GamePhase _GamePhase)
    {
        base.OnGamePhaseChanged(_GamePhase);

        switch (_GamePhase)
        {
        case GamePhase.MAIN_MENU:
            Transition(true);
            break;

        case GamePhase.LOADING:
            m_DefaultSkinSelection.SetActive(false);
            if (m_Visible)
            {
                Transition(false);
            }
            break;

        case GamePhase.SHOP:
            if (m_Visible)
            {
                Transition(false);
            }
            break;
        }
    }
예제 #18
0
	public void StartPhase(GamePhase phase){
		foreach (var overlay in Overlays) {
			overlay.gameObject.SetActive (false);
		}

		this.CurrentPhase = phase;

		switch (phase) {
		case GamePhase.Focus:
			StartFocusFase ();
			Overlays [0].SetActive (true);
			AudioSource.PlayClipAtPoint(slowmo_in, gameObject.transform.position);
			break;
		case GamePhase.Cast:
			// handle in cannon
			Overlays [1].SetActive (true);

			break;
		case GamePhase.WaitForFire:
			// handle in cannon
			Overlays [2].SetActive (true);
			AudioSource.PlayClipAtPoint(spellReady, gameObject.transform.position);
			break;
		case GamePhase.Fire:
			// handle in cannonball
			Overlays [3].SetActive (true);
			break;
		}
	}
예제 #19
0
    public void SwitchPhase()
    {
        // This object will now switch phase, so tell the Network Manager
        PutNotReady();
        hostRocket.GetComponent <ServerScript>().playersSwitched[pNo - 1] = true;

        switch (phase)
        {
        case GamePhase.Wait:
            SwitchToPreparePhase();
            playerRB.angularDrag = 3;
            break;

        case GamePhase.Fly:
            phase = GamePhase.Wait;
            break;

        case GamePhase.Prepare:
            phase = GamePhase.Launch;
            playerRB.angularDrag = 4;
            launchTimer          = 5;

            AudioSource audioPlayer = gameObject.GetComponent <AudioSource>();
            audioPlayer.clip = audioClip[5];
            audioPlayer.Play();

            break;

        case GamePhase.Launch:
            phase         = GamePhase.Fly;
            launchPressed = false;
            break;
        }
    }
        // thread-safe, lock-free, performs roll-back on to_factory failure.
        // Intent: I dont want to call the factory before I can successfully assign it.
        // (I could have used a lock, but I didn't...)
        private bool TryTransition(GamePhase from, IGamePhase via, Func <IGamePhase> to_factory)
        {
            // null-checks + transition direction check + via.State is an even (i.e. is transitional) check.
            Debug.Assert(via != null && to_factory != null && (via.Phase - 1 == from) && ((int)via.Phase & 1) == 0);
            var old = _phase;

            if (old.Phase == from && ReferenceEquals(old, Interlocked.CompareExchange(ref _phase, via, old)))
            {
                // we have successfully entered the transition state (i.e. via)!
                // where we have succeeded all others shall fail!
                // ...which is a fancy way of saying only one thread can be in this block at a time.
                // simply put: for as long as _game is in the via state, we have "lock".

                try
                {
                    //var data = old.FinalLockDown(); // TODO <-----------------------------------
                    var next = to_factory();
                    if (next != null && (via.Phase + 1 == next.Phase))
                    {
                        _phase = next; // success, and "lock" released.
                        return(true);
                    }
                    return(false); // (false will be returned *after* finally has executed.)
                }
                finally
                {
                    if (ReferenceEquals(via, _phase)) // we failed to transition to next?
                    {
                        _phase = old;                 // performing roll-back, and "lock" released.
                    }
                }
            }
            return(false); // some other thread beat us to the punch.
        }
예제 #21
0
파일: Game.cs 프로젝트: eo39/Ball-Breaker
        private void ShiftDownGameField()
        {
            for (int x = 0; x < FieldWidth; x++)
            {
                int cellWithOutBallPosition = GetCellWithOutBallPosition(x);

                if (cellWithOutBallPosition < 0)
                {
                    continue;
                }

                for (int y = FieldHeight - 1; y > 0;)
                {
                    if (gameField[x, y].HasBall)
                    {
                        y--;
                    }
                    else
                    {
                        (gameField[x, y], gameField[x, cellWithOutBallPosition]) = (
                            gameField[x, cellWithOutBallPosition], gameField[x, y]);

                        cellWithOutBallPosition--;
                        if (cellWithOutBallPosition < 0)
                        {
                            y = 0;
                        }
                    }
                }
            }

            gamePhase = GamePhase.ShiftRightFieldCells;
        }
예제 #22
0
        public void TestLeaveGame(GamePhase gamePhase)
        {
            var player = game.AddPlayer("Player One");

            game.AddPlayer("Player Two");
            game.AddPlayer("Player Three");
            game.players[0].isPlaying = true;
            game.players[1].isPlaying = true;
            game.players[2].isPlaying = true;

            game.phase = gamePhase;

            var result = control.Leave(new PlayerData {
                id = player
            }).Value;

            // ASSERT
            Assert.IsNotNull(result);
            //Console.WriteLine(result.Message);
            Assert.IsTrue(result.Success);

            Console.WriteLine(game.phase);

            Assert.AreEqual(2, game.GetActivePlayerCount());
        }
예제 #23
0
 public void Update()
 {
     if (myPlayers._players.Count == numberOfPlayer && currentPhase == GamePhase.LoadingPlayers)
     {
         //make sure all players are really set up
         bool ready = true;
         foreach (Player p in myPlayers._players)
         {
             if (p.isReady == false)
             {
                 ready = false;
             }
         }
         if (ready)
         {
             currentPlayer = myPlayers._players [0];
             hostPlayer    = myPlayers._players [0];
             currentPhase  = GamePhase.SetupRoundOne;
             OnBarbarianPositionChanged(0);
             OnBarbarianStrengthChanged(0);
             OnKnightStrengthChanged(0);
             ProgressCard helper = new ProgressCard();
             tradeCardsQueue    = helper.generateDeck(0);
             politicsCardsQueue = helper.generateDeck(1);
             scienceCardsQueue  = helper.generateDeck(2);
         }
     }
     if (!started && !isWaiting && currentPhase == GamePhase.SetupRoundOne)
     {
         StartCoroutine(TurnRotationCoroutine());
         started = true;
     }
 }
예제 #24
0
    public void EndOfGame(int victoriousPlayerIndex)
    {
        Player p = myPlayers._players [victoriousPlayerIndex];

        hostPlayer.RpcAnnounce(p.playerName + " wins the game!");
        currentPhase = GamePhase.Completed;
    }
예제 #25
0
 public void AdvanceTurn()
 {
     if (turnState == GamePhase.Upkeep)
     {
         foreach (Transform player in playersObject.transform)
         {
             player.GetComponent <PlayerScript>().actions = 2;
         }
         turnState = GamePhase.PlayerTurn;
     }
     if (turnState == GamePhase.PlayerTurn)
     {
         foreach (Transform player in playersObject.transform)
         {
             if (player.GetComponent <PlayerScript>().actions > 0)
             {
                 return;
             }
         }
         turnState = GamePhase.EnemyTurn;
     }
     if (turnState == GamePhase.EnemyTurn)
     {
         turnState = GamePhase.EventPhase;
     }
     if (turnState == GamePhase.EventPhase)
     {
         turnState = GamePhase.EndTurn;
     }
     if (turnState == GamePhase.EndTurn)
     {
         turnState = GamePhase.Upkeep;
     }
 }
예제 #26
0
    protected override void OnPhaseUnload(GamePhase phase)
    {
        switch (phase)
        {
        case GamePhase.Afternoon:
            DespawnCreatures(CreatureType.Squirrel, 1);
            DespawnCreatures(CreatureType.Deer, 1);
            break;

        case GamePhase.Dusk:
            DespawnCreatures(CreatureType.Squirrel, -1);
            DespawnCreatures(CreatureType.Deer, -1);
            break;

        case GamePhase.Night:
            break;

        case GamePhase.Latenight3:
            DespawnCreatures(CreatureType.Crow, -1);
            DespawnCreatures(CreatureType.Wolf, -1);
            DespawnCreatures(CreatureType.Shapeshifter, -1);
            DespawnCreatures(CreatureType.Reverse, -1);
            DespawnCreatures(CreatureType.Decoy, -1);
            break;

        case GamePhase.Dawn:
            DespawnCreatures(CreatureType.Raccoon, -1);
            DespawnCreatures(CreatureType.Bunny, -1);
            break;

        case GamePhase.End:
            break;
        }
    }
예제 #27
0
        protected virtual void SetPhase(GamePhase phase)
        {
            this.Phase = phase;
            if (phase == GamePhase.WarmUp)
            {
                PhaseEndTime = GameTime.Ticks + Scenario.WarmUpDuration;
            }
            else if (phase == GamePhase.FadeOut)
            {
                PhaseEndTime = GameTime.Ticks + FadeOutDuration;
            }
            else
            {
                PhaseEndTime = GameTime.Ticks + Scenario.FightDuration;
            }

            if (Phase != GamePhase.WarmUp)
            {
                MissionScreen.Hide();
            }

            OnPhaseChange?.Invoke();

            Log.Logger.Log("Set phase " + phase);
        }
예제 #28
0
    IEnumerator ConnectionsDecay()
    {
        for (int i = connections.Count - 1; i >= 0; i--)
        {
            var connection = connections[i];
            connection.health--;
            if (connection.health <= 0)
            {
                connection.a.connections.Remove(connection);
                connection.b.connections.Remove(connection);
                connections.Remove(connection);
                Destroy(connection.gameObject);
            }
            else
            {
                connection.SetAppearance((float)connection.health / (float)maxConnectionHealth);
            }
        }

        yield return(null);

        firstClicked  = null;
        secondClicked = null;
        phase         = GamePhase.SelectStart;
    }
예제 #29
0
    void ChooseSecondNode(Node node)
    {
        if (node != firstClicked && node.IsNeighbor(firstClicked))
        {
            secondClicked = node;
            firstClicked.Deselect();
        }
        else
        {
            return;
        }

        var connection = Instantiate(connectionPrefab);

        connection.transform.position = firstClicked.transform.position;
        float angle = Mathf.Rad2Deg * Mathf.Atan2(secondClicked.gridCoordinates.y - firstClicked.gridCoordinates.y,
                                                  secondClicked.gridCoordinates.x - firstClicked.gridCoordinates.x);

        connection.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        if (firstClicked.IsDiagonal(secondClicked))
        {
            connection.transform.localScale = new Vector3(1.414f, 1.0f, 1.0f);
        }

        connection.a      = firstClicked;
        connection.b      = secondClicked;
        connection.health = maxConnectionHealth;

        connections.Add(connection);
        firstClicked.connections.Add(connection);
        secondClicked.connections.Add(connection);

        phase = GamePhase.SignalsMove;
        StartCoroutine(HandleSignalsMove());
    }
예제 #30
0
파일: Game.cs 프로젝트: bheimann/StoneAge
        public GameResponse FeedPeople(Guid playerId, IDictionary <Resource, int> otherResourcesToFeedWith)
        {
            if (Phase != GamePhase.FeedPeople)
            {
                return(GameResponse.Fail());
            }

            var player = _players.SingleOrDefault(p => p.Id == playerId);

            if (player == null)
            {
                return(GameResponse.Fail());
            }

            var board        = player.PlayerBoard;
            var peopleToFeed = Math.Max(0, board.TotalPeople - board.FoodTrack);

            player.PlayerBoard.Food = board.Food - peopleToFeed;

            // TODO: support feeding with resources

            player.NeedsToFeed = false;

            if (!_players.Any(p => p.NeedsToFeed))
            {
                Phase = GamePhase.NewRoundPrep;
                PrepareNewRound();
                Phase = GamePhase.PlayersPlacePeople;
            }

            return(GameResponse.Pass());
        }
예제 #31
0
 public IEnumerable <IAction> GetActions(GamePhase phase, GameBoard board)
 {
     if (phase == GamePhase.Player2PreSetup)
     {
         yield return(this);
     }
 }
예제 #32
0
    /// <summary>
    /// Handles winning. Also handles draw condition.
    /// </summary>
    /// <returns><c>true</c>, if game ends, <c>false</c> otherwise.</returns>
    public bool CheckGameEnd()
    {
        if (0 == MapController.instance.vacantBlockCount)
        {
            gamePhase   = GamePhase.EndGame;
            turnOwnerID = -1;

            if (players[0].score == players[1].score)
            {
                GameSetPanel.instance.Draw();
            }
            else if (players[0].score > players[1].score)
            {
                GameSetPanel.instance.Win(players[0].playerColor.color);
            }
            else
            {
                GameSetPanel.instance.Win(players[1].playerColor.color);
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #33
0
        public static string GetGamePhase(GamePhase gamePhase)
        {
            var text = string.Empty;

            switch (gamePhase)
            {
            case GamePhase.Placing:
                text = "Phase 1: Place your pieces";
                break;

            case GamePhase.Moving:
                text = "Phase 2: Move your pieces";
                break;

            case GamePhase.Flying:
                text = "Phase 3: Flying";
                break;

            case GamePhase.Discarding:
                text = "DISCARD phase: discard opponent's token";
                break;

            case GamePhase.END:
                text = "GAME OVER";
                break;

            default:
                break;
            }

            return(text);
        }
예제 #34
0
	void OnGamePhaseChanged (GamePhase previous, GamePhase current) {
		switch ( current ) {
		case GamePhase.Selection:
			foreach ( Unit unit in units )
				unit.ResetRecharge ();
			break;
		}
	}
예제 #35
0
        //-----------CONSTRUCTOR--------------
        #region Constructor
        public MainWindow()
        {
            InitializeComponent();

            this._CurrentPhase = GamePhase.GameOver;
            this._CurrentLevel = 0;
            this.Loaded += (s, e) => { DiscoverKinectSensor(); };
            this.Unloaded += (s, e) => { this.Kinect = null; };
        }
예제 #36
0
 //enemy attacks
 public void LaserDamage()
 {
     if (!player.blocked) {
         player.hp -= 20;
         mainCamera.Shake();
         playerLeft.GetComponent<PlayerAnimations>().SetAnim(5);
         playerRight.GetComponent<PlayerAnimations>().SetAnim(5);
     }
     gameTurn = GamePhase.EndEnemyAttack;
 }
예제 #37
0
	void OnGamePhaseChanged (GamePhase previous, GamePhase current) {
		switch ( current ) {
		case GamePhase.Building:
		case GamePhase.GameOver:
		case GamePhase.Selection:
			if ( IsInvoking ("Fire") )
				CancelInvoke ("Fire");
			break;
		}
	}
예제 #38
0
	void OnGamePhaseChanged (GamePhase previous, GamePhase current) {
		switch ( current ) {
		case GamePhase.Selection:
			DisableCreate();
			break;
		case GamePhase.Building:
		case GamePhase.Defending:
			Invoke ("EnableCreate", 0.5f);
			break;
		}	
	}
예제 #39
0
 void PlacingOrdersPhase()
 {
     if (!allOrdersPlaced)
     {
         return;
     }
     else
     {
         currentPhase = GamePhase.MovingOrders;
     }
 }
예제 #40
0
    private Text timerText; // text used for displaying timer

    #endregion Fields

    #region Methods

    public void ChangeGamePhase(GamePhase gp)
    {
        gamePhase = gp;
        if (gp == GamePhase.Test) {
            elephantObj.rigidbody.isKinematic = false;
            ChangeUIPhase("CloseUI");
            Invoke("StartTestAudio", 1f);
            StartCoroutine(DelayedUIPhase("TestUI", 1.5f));
        }
        else {
            drumLoop.Stop();
        }
    }
예제 #41
0
    private void createBounceSurface()
    {
        GameObject m_bounceSurface = (GameObject)Instantiate (m_bounceSurfacePrefab);
        m_bounceSurface.SetActive (true);

        m_bounceSurface.transform.rotation = targetRotation;

        m_bounceSurface.transform.position = targetPosition;

        gamePhase = GamePhase.PlayGame;
        m_ballManager.SetActive (true);
        m_tangoPointCloud.gameObject.SetActive(false);
    }
예제 #42
0
 public void PlayerAttack()
 {
     playerLeft.GetComponent<PlayerAnimations>().SetAnim(3);
     playerRight.GetComponent<PlayerAnimations>().SetAnim(3);
     playerParticles.partVisible();
     enemyAnimations.SetTrigger("Hurt");
     enemy.DamageEnemy(player.seqMoves * 20);
     CheckDeath();
     if (gameTurn != GamePhase.gameOver)
     {
         Invoke("startEnemyTurn", 1.5f);
         gameTurn = GamePhase.startEnemyTurn;
     }
 }
예제 #43
0
 public void ChangePhase(GamePhase newPhase)
 {
     if(newPhase != Parameters.CurrentPhase)
     {
         if (newPhase == GamePhase.RTS)
         {
             PhaseImage.texture = Resources.Load("strategy") as Texture2D;
             PhaseImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 114);
             Parameters.CurrentPhase = GamePhase.RTS;
         }
         else
         {
             PhaseImage.texture = Resources.Load("action") as Texture2D;
             PhaseImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 88);
             Parameters.CurrentPhase = GamePhase.TPS;
         }
     }
 }
예제 #44
0
	void OnGamePhaseChanged (GamePhase previous, GamePhase current) {
		switch ( current ) {
		case GamePhase.Selection:
			if (IsInvoking ("GenerateEnemy"))
				CancelInvoke ("GenerateEnemy");
			break;
		
		case GamePhase.Building:
			if (IsInvoking ("GenerateEnemy"))
				CancelInvoke ("GenerateEnemy");
			
			InvokeRepeating ("GenerateEnemy", 5, interval);
			
			break;
			
		case GamePhase.GameOver:
			if (IsInvoking ("GenerateEnemy"))
				CancelInvoke ("GenerateEnemy");
			break;
		}
	}
예제 #45
0
        static void Main( string[] args )
        {
            Bot bot = new Bot();

            while ( myPhase != GamePhase.Done )
            {
                // Read a line, remove leading or trailing white
                // space and make all letters lower case
                String line = Console.ReadLine().Trim().ToLower();

                // If line is empty or commented, skip
                if ( line.Length == 0 || line[ 0 ] == '#' )
                    continue;

                if ( myPhase == GamePhase.None )
                {
                    switch ( line )
                    {
                        case "setup":
                            myPhase = GamePhase.Setup;
                            break;
                        case "turn":
                            myPhase = GamePhase.Turn;
                            GameState.PreTurn();
                            break;
                        case "done":
                            myPhase = GamePhase.Done;
                            break;
                        default:
                            continue;
                    }
                }
                else
                {
                    if ( line == "end" )
                    {
                        switch ( myPhase )
                        {
                            case GamePhase.Setup:
                                GameState.PostSetup();
                                break;
                            case GamePhase.Turn:
                                bot.TakeTurn();
                                break;
                        }

                        myPhase = GamePhase.None;
                    }
                    else
                    {
                        String[] split = line.Split( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries );

                        switch ( myPhase )
                        {
                            case GamePhase.Setup:
                                switch ( split[ 0 ] )
                                {
                                    case "width":
                                        GameState.MapWidth = int.Parse( split[ 1 ] );
                                        break;
                                    case "height":
                                        GameState.MapHeight = int.Parse( split[ 1 ] );
                                        break;
                                    case "seed":
                                        GameState.Random = new Random( int.Parse( split[ 1 ] ) );
                                        break;
                                    case "fow":
                                        GameState.FogOfWar = bool.Parse( split[ 1 ] );
                                        break;
                                    case "vrange":
                                        GameState.ViewRange = float.Parse( split[ 1 ] );
                                        break;
                                    case "teams":
                                        GameState.TeamCount = int.Parse( split[ 1 ] );
                                        break;
                                    case "turns":
                                        GameState.TurnLimit = int.Parse( split[ 1 ] );
                                        break;
                                    case "timeout":
                                        GameState.Timeout = int.Parse( split[ 1 ] );
                                        break;
                                }
                                break;
                            case GamePhase.Turn:
                                int team;
                                bool found;
                                Position pos;
                                Direction dir;
                                switch ( split[ 0 ] )
                                {
                                    case "t":
                                        GameState.Turn = int.Parse( split[ 1 ] );
                                        break;
                                    case "a":
                                        team = int.Parse( split[ 1 ] );
                                        pos = new Position( int.Parse( split[ 2 ] ), int.Parse( split[ 3 ] ) );
                                        dir = Direction.Parse( split[ 4 ] );
                                        if ( team == 0 )
                                        {
                                            found = false;
                                            foreach ( Agent agent in GameState.Agents[ 0 ] )
                                            {
                                                if ( agent.Position.Equals( pos ) )
                                                {
                                                    found = true;
                                                    if ( !agent.Confirmed )
                                                        agent.Confirmed = true;
                                                    else
                                                        throw new Exception( "Duplicate agent detected" );

                                                    break;
                                                }
                                            }

                                            if ( !found )
                                                GameState.Agents[ 0 ].Add( new Agent( team, pos, dir ) );
                                        }
                                        else
                                        {
                                            GameState.Agents[ team ].Add( new Agent( team, pos, dir ) );
                                        }
                                        break;
                                    case "d":
                                        team = int.Parse( split[ 1 ] );
                                        pos = new Position( int.Parse( split[ 2 ] ), int.Parse( split[ 3 ] ) );
                                        dir = Direction.Parse( split[ 4 ] );
                                        GameState.Dead[ team ].Add( new Agent( team, pos, dir ) );
                                        break;
                                    case "b":
                                        team = int.Parse( split[ 1 ] );
                                        pos = new Position( int.Parse( split[ 2 ] ), int.Parse( split[ 3 ] ) );
                                        GameState.Bases[ team ].Add( pos );
                                        break;
                                    case "p":
                                        pos = new Position( int.Parse( split[ 1 ] ), int.Parse( split[ 2 ] ) );
                                        GameState.Packages.Add( pos );
                                        break;
                                    case "w":
                                        pos = new Position( int.Parse( split[ 1 ] ), int.Parse( split[ 2 ] ) );
                                        GameState.Map[ pos.X, pos.Y ] = Tile.Wall;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
        }
예제 #46
0
    public bool CurrentPhaseIs(GamePhase phase)
    {
        if(Game.gamePhase == phase)
        {
            return true;
        }

        return false;
    }
예제 #47
0
        public void Cannot_place_people_in_Phase(GamePhase phase)
        {
            var playerId = game.AddPlayer().Value;
            game.Phase = phase;

            var result = game.PlacePeople(playerId, 1, BoardSpace.HuntingGrounds);

            Assert.IsFalse(result.Successful);
        }
예제 #48
0
        public GameResponse PlacePeople(Guid playerId, int quantity, BoardSpace boardSpace)
        {
            if (Phase != GamePhase.PlayersPlacePeople)
                return GameResponse.Fail();

            var player = _players.SingleOrDefault(p => p.Id == playerId);
            if (player == null)
                return GameResponse.Fail();

            if (TurnOrder.Current != player)
                return GameResponse.Fail();

            var space = Board.Spaces.SingleOrDefault(s => s.BoardSpace == boardSpace);
            if (space.QuantityIsInvalidForSpace(quantity))
                return GameResponse.Fail();

            if(space.PlayerPreviouslyPlaced(player) && !space.AllowsPartialPlacement)
                return GameResponse.Fail();

            if(space.NotAvailable(quantity))
                return GameResponse.Fail();

            if(space.HasTooManyUniquePlayers())
                return GameResponse.Fail();

            if(!player.PlayerBoard.HasAvailablePeopleToPlace(quantity))
                return GameResponse.Fail();

            player.PlayerBoard.SetPeopleAsPlaced(quantity);
            space.Place(player, quantity);

            if (_players.Sum(p => p.PlayerBoard.PeopleToPlace) == 0)
            {
                Phase = GamePhase.UsePeopleActions;
                TurnOrder.SetCheiftanToCurrent();
            }
            else
            {
                TurnOrder.NextPlayerToPlace();
            }

            return GameResponse.Pass();
        }
예제 #49
0
 private void ChangeGamePhase(GamePhase gamePhase)
 {
     GamePhase = gamePhase;
     _waitingForOpponent = false;
 }
예제 #50
0
        private bool InitialBoardSetup()
        {
            Phase = GamePhase.SetUpBoard;
            Board = new GameBoard();
            TurnOrder = new TurnOrder();

            AssignPlayerSeats();
            AssignPlayerColors();
            PassOutPlayerBoards();

            PrepareNewRound();
            ChooseStartPlayer();

            // TODO: "how to solve call back and setting up the board"
            IsThinking = false;
            Phase = GamePhase.PlayersPlacePeople;
            return true;
        }
예제 #51
0
        static void Main( string[] args )
        {
            Bot bot = new Bot();

            while ( myPhase != GamePhase.Done )
            {
                // Read a line, remove leading or trailing white
                // space and make all letters lower case
                String line = Console.ReadLine().Trim().ToLower();

                // If line is empty or commented, skip
                if ( line.Length == 0 || line[ 0 ] == '#' )
                    continue;

                // If we are not currently in an input group
                // then expect to be given a group name
                if( myPhase == GamePhase.None )
                {
                    switch ( line )
                    {
                        case "setup":
                            myPhase = GamePhase.Setup;
                            break;
                        case "turn":
                            myPhase = GamePhase.Turn;
                            GameState.PreTurn();
                            break;
                        case "done":
                            myPhase = GamePhase.Done;
                            break;
                        default:
                            continue;
                    }
                }
                else
                {
                    // Check if current group has ended
                    if ( line == "end" )
                    {
                        switch ( myPhase )
                        {
                            case GamePhase.Setup:
                                GameState.PostSetup();
                                break;
                            case GamePhase.Turn:
                                bot.TakeTurn();
                                break;
                        }

                        myPhase = GamePhase.None;
                    }
                    else
                    {
                        String[] split = line.Split( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries );

                        switch ( myPhase )
                        {
                            case GamePhase.Setup: // Parse setup commands
                                switch ( split[ 0 ] )
                                {
                                    case "width": // Width of map
                                        GameState.MapWidth = int.Parse( split[ 1 ] );
                                        break;
                                    case "height": // Height of map
                                        GameState.MapHeight = int.Parse( split[ 1 ] );
                                        break;
                                    case "seed": // Seed for random number generation
                                        GameState.Random = new Random( int.Parse( split[ 1 ] ) );
                                        break;
                                    case "fow": // Fog of war boolean
                                        GameState.FogOfWar = bool.Parse( split[ 1 ] );
                                        break;
                                    case "vrange": // Agent view range
                                        GameState.ViewRange = float.Parse( split[ 1 ] );
                                        break;
                                    case "teams": // Number of teams
                                        GameState.TeamCount = int.Parse( split[ 1 ] );
                                        break;
                                    case "turns": // Turn limit
                                        GameState.TurnLimit = int.Parse( split[ 1 ] );
                                        break;
                                    case "timeout": // Timeout time in ms
                                        GameState.Timeout = int.Parse( split[ 1 ] );
                                        break;
                                }
                                break;
                            case GamePhase.Turn: // Parse turn commands
                                int team;
                                Position pos;
                                Direction dir;
                                switch ( split[ 0 ] )
                                {
                                    case "t": // Turn number
                                        GameState.Turn = int.Parse( split[ 1 ] );
                                        break;
                                    case "a": // Agent position and rotation
                                        team = int.Parse( split[ 1 ] );
                                        pos = new Position( int.Parse( split[ 2 ] ), int.Parse( split[ 3 ] ) );
                                        dir = Direction.Parse( split[ 4 ] );
                                        GameState.Agents[ team ].Add( new Agent( team, pos, dir ) );
                                        break;
                                    case "d": // Dead agent position and rotation
                                        team = int.Parse( split[ 1 ] );
                                        pos = new Position( int.Parse( split[ 2 ] ), int.Parse( split[ 3 ] ) );
                                        GameState.Dead[ team ].Add( new Agent( team, pos, Direction.None ) );
                                        break;
                                    case "b": // Base position
                                        team = int.Parse( split[ 1 ] );
                                        pos = new Position( int.Parse( split[ 2 ] ), int.Parse( split[ 3 ] ) );
                                        GameState.Bases[ team ].Add( pos );
                                        break;
                                    case "p": // Energy package position
                                        pos = new Position( int.Parse( split[ 1 ] ), int.Parse( split[ 2 ] ) );
                                        GameState.Packages.Add( pos );
                                        break;
                                    case "w": // Wall position
                                        pos = new Position( int.Parse( split[ 1 ] ), int.Parse( split[ 2 ] ) );
                                        GameState.Map[ pos.X, pos.Y ] = Tile.Wall;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
        }
예제 #52
0
	/// <summary>
	/// freezes the local player, pauses game time and broadcasts
	/// the game state
	/// </summary>
	public void StopGame()
	{

		if (!PhotonNetwork.isMasterClient)
			return;

		photonView.RPC("ReceiveFreeze", PhotonTargets.All);

		Phase = GamePhase.BetweenGames;
		vp_MPClock.Set(PauseLength);

		TransmitGameState();

	}
예제 #53
0
	/// <summary>
	/// respawns all players, unfreezes the local player, restarts
	/// the game clock and broadcasts the game state
	/// </summary>
	public void StartGame()
	{

		if (!PhotonNetwork.isMasterClient)
			return;

		vp_MPNetworkPlayer.TransmitRespawnAll();

		vp_MPNetworkPlayer.TransmitUnFreezeAll();

		Phase = GamePhase.Playing;
		vp_MPClock.Set(GameLength);

		TransmitGameState();

		//Debug.Log("StartGame @ " + vp_MPClock.LocalTime + " with end time: " + (vp_MPClock.LocalTime + vp_MPClock.Duration) + ". time left is: " + vp_MPClock.TimeLeft);

	}
예제 #54
0
	/// <summary>
	/// broadcasts a command to load a new level on all clients (master
	/// included) then resets the game which will prompt all player stats
	/// to be reset and players to respawn on new spawnpoints.
	/// NOTES: 1) a scene being loaded must not have a vp_MPConnection
	/// in it. the connection component should be loaded in a startup
	/// scene with 'DontDestroyOnLoad' set to true. 2) the game clock will
	/// be reset as a direct result of loading a new level
	/// </summary>
	public void TransmitLoadLevel(string levelName)
	{

		if (!PhotonNetwork.isMasterClient)
			return;

		vp_MPMaster.Phase = vp_MPMaster.GamePhase.NotStarted;

		photonView.RPC("ReceiveLoadLevel", PhotonTargets.All, levelName);
		
	}
예제 #55
0
	protected virtual void ReceiveGameState(ExitGames.Client.Photon.Hashtable gameState, PhotonMessageInfo info)
	{

		//vp_MPDebug.Log("GOT FULL GAMESTATE!");

		//DumpGameState(gameState);

		if ((info.sender != PhotonNetwork.masterClient) ||
			(info.sender.isLocal))
			return;

		//vp_MPDebug.Log("Gamestate updated @ " + info.timestamp);
		//Debug.Log("Gamestate updated @ " + info.timestamp);

		// -------- extract game phase, game time and duration --------

		// TODO: make generic method 'ExtractStat' that does this
		object phase;
		if ((gameState.TryGetValue("Phase", out phase) && (phase != null)))
			Phase = (GamePhase)phase;

		object timeLeft;
		object duration;
		if ((gameState.TryGetValue("TimeLeft", out timeLeft) && (timeLeft != null))
			&& (gameState.TryGetValue("Duration", out duration) && (duration != null)))
			vp_MPClock.Set((float)timeLeft, (float)duration);

		// -------- instantiate missing player prefabs --------

		vp_MPPlayerSpawner.Instance.InstantiateMissingPlayerPrefabs(gameState);
		
		// -------- refresh stats of all players --------

		ReceivePlayerState(gameState, info);

		// -------- refresh health of all non-player damage handlers --------

		foreach (vp_DamageHandler d in vp_DamageHandler.Instances.Values)
		{
			if (d == null)
				continue;
			if (d is vp_PlayerDamageHandler)
				continue;
			PhotonView p = d.GetComponent<PhotonView>();
			if (p == null)
				continue;
			object currentHealth;
			if (gameState.TryGetValue(-p.viewID, out currentHealth) && (currentHealth != null))
			{
				d.CurrentHealth = (float)currentHealth;
				if (d.CurrentHealth <= 0.0f)
					vp_Utility.Activate(d.gameObject, false);
			}
			else
				vp_MPDebug.Log("Failed to extract health of damage handler " + p.viewID + " from gamestate");
		}

		// -------- disable any pickups noted as currently disabled in the state --------

		//vp_MPDebug.Log("DISABLED PICKUPS: " + vp_MPPickupManager.Instance.Pickups.Keys.Count);

		foreach (int id in vp_MPPickupManager.Instance.Pickups.Keys)
		{

			List<vp_ItemPickup> p;
			vp_MPPickupManager.Instance.Pickups.TryGetValue(id, out p);
			if ((p == null) || (p.Count < 1) || p[0] == null)
				continue;

			object isDisabled;
			if (gameState.TryGetValue(id, out isDisabled) && (isDisabled != null))
				vp_Utility.Activate(p[0].transform.gameObject, false);

		}
		
		// -------- refresh all teams --------

		if(vp_MPTeamManager.Exists)
			vp_MPTeamManager.Instance.RefreshTeams();

	}
 public void SetPhase(GamePhase gamePhase)
 {
     gameState.gamePhase = gamePhase;
 }
예제 #57
0
 public void SetGamePhase(GamePhase gp)
 {
     _CurPhase = gp;
 }
예제 #58
0
        public GameResponse<DiceResult> UseActionOfPeople(Guid playerId, BoardSpace boardSpace)
        {
            if (Phase != GamePhase.UsePeopleActions)
                return GameResponse<DiceResult>.Fail();

            var player = _players.SingleOrDefault(p => p.Id == playerId);
            if (player == null)
                return GameResponse<DiceResult>.Fail();

            if(player != TurnOrder.Current)
                return GameResponse<DiceResult>.Fail();

            var space = Board.Spaces.SingleOrDefault(s => s.BoardSpace == boardSpace);
            if(!space.PlayerPreviouslyPlaced(player))
                return GameResponse<DiceResult>.Fail();

            var diceResult = UseAction(player, space);

            if (player.PlayerBoard.PeopleToPlace == player.PlayerBoard.TotalPeople)
                TurnOrder.Next();

            if (_players.Sum(p => p.PlayerBoard.PeopleToPlace) == _players.Sum(p => p.PlayerBoard.TotalPeople))
            {
                foreach (var playerToChange in _players)
                    playerToChange.NeedsToFeed = true;
                Phase = GamePhase.FeedPeople;
            }

            return GameResponse<DiceResult>.Pass(diceResult);
        }
예제 #59
0
        public GameResponse FeedPeople(Guid playerId, IDictionary<Resource, int> otherResourcesToFeedWith)
        {
            if (Phase != GamePhase.FeedPeople)
                return GameResponse.Fail();

            var player = _players.SingleOrDefault(p => p.Id == playerId);
            if (player == null)
                return GameResponse.Fail();

            var board = player.PlayerBoard;
            var peopleToFeed = Math.Max(0, board.TotalPeople - board.FoodTrack);
            player.PlayerBoard.Food = board.Food - peopleToFeed;

            // TODO: support feeding with resources

            player.NeedsToFeed = false;

            if (!_players.Any(p => p.NeedsToFeed))
            {
                Phase = GamePhase.NewRoundPrep;
                PrepareNewRound();
                Phase = GamePhase.PlayersPlacePeople;
            }

            return GameResponse.Pass();
        }
예제 #60
0
        //this function needs to be fixed up very badly!!
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            borders = new Vector3[4];
            borders[0] = new Vector3(20, 0, 0);
            borders[1] = new Vector3(-20, 0, 0);
            borders[2] = new Vector3(20, 0, -2000);
            borders[3] = new Vector3(-20, 0, -2000);

            map = new FieldMap((int)Math.Abs(borders[0].X - borders[3].X) / squareSize,
                (int)(Math.Abs(borders[0].Z - borders[3].Z) / squareSize));

            if (gameType == GameType.Hide || gameType == GameType.Seek)
            {
                items = new Item[numOfItems];
                for (int i = 0; i < numOfItems; i++)
                {
                    items[i] = new Rock(Game, new Vector3(0, 0, -10 * i), new Vector3(1, 1, 1), 0, this);
                    //tell map that this place is off-limits
                    //this is not correct because we have negative x coordinates!!!
                    map.addBlock((int)items[i].location.X / squareSize, (int)-items[i].location.Z / squareSize);
                    //depending on item size may need to block 2 or more squares?
                }

                hiders = new Hider[numOfHiders];
                for (int i = 0; i < numOfHiders; i++)
                {
                    hiders[i] = new Hider(Game, this);
                    //tell map that this place is off-limits
                    //this is not correct because we have negative x coordinates!!!
                    map.addBlock((int)hiders[i].location.X / squareSize, (int)-hiders[i].location.Z / squareSize);
                }
                gamePhase = GamePhase.Counting;
            }

            else if (gameType == GameType.HidePractice)
            {
                hiders = null;
                items = new Item[1];
                items[0] = new Rock(Game, new Vector3(0, 0, -10), new Vector3(1, 1, 1), 0, this);
            }

            else // gameType == SeekPractice
            {
                hiders = new Hider[1];
                hiders[0] = new Hider(Game, this);
                items = new Item[2];
                items[0] = new Rock(Game, new Vector3(5, 0, -10), new Vector3(1, 1, 1), 0, this);
                items[1] = new Rock(Game, new Vector3(-5, 0, -10), new Vector3(1, 1, 1), 0, this);
            }

            if (gameType == GameType.Hide)
                seeker = new Seeker(Game, this, countNum);
            else
                seeker = null;

            if (gameType == GameType.Hide || gameType == GameType.HidePractice)
            {
                meHider = new MeHider(Game, this);
                meSeeker = null;
            }
            else
            {
                meSeeker = new MeSeeker(Game, this, countNum);
                meHider = null;
            }

            base.Initialize();
        }