Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        EventManager.StartListening(GameEvents.BuildTower, BuildTowerTest);
        EventManager.StartListening(GameEvents.CityBoardLoaded, InitPlayerAfterCityIsLoaded);
        EventManager.StartListening(GameEvents.EndGameEvent, EndGame);

        switch (GameController.Instance.currentPlatform)
        {
        case GameController.GamePlatform.PC:
            Debug.Log("THIS IS A PC INSTANCE");
            Instantiate(PCPlayer);
            break;

        case GameController.GamePlatform.Vive:
            Debug.Log("THIS IS A VIVE INSTANCE");
            CmdSpawnVive(gameObject);
            break;

        case GameController.GamePlatform.Android:
            Debug.Log("THIS IS AN ANDROID INSTANCE");
            var aaa = Instantiate(AndroidPlayer);
            android = aaa.GetComponent <AndroidPlayer>();
            break;

        default:
            Debug.Log("THIS IS A DEFAULT INSTANCE");
            break;
        }

        Debug.Log("Init correct player for the correct platform");
        EventManager.TriggerEvent(GameEvents.PlayerInitialized);
    }
Beispiel #2
0
        private string Prompt(PromptType promptType, Dictionary<PromptData, object> data)
        {
            string prompt = "";
            ITrick trick = null;
            IPlayer player = null;
            IPlayer picker = null;
            switch (promptType)
            {
                case PromptType.CardsDealt:
                    PlayerGraphicsDict = new Dictionary<IPlayer, AndroidPlayer>();
                    var blinddata = (IBlind)data[PromptData.Blind];
                    foreach (var addPlayer in _table.Players)
                    {
                        AndroidPlayer hostGraphics = new AndroidPlayer(addPlayer);
                        PlayerGraphicsDict.Add(addPlayer, hostGraphics);
                    }
                    var blindLoc = 250;
                    var blindIndex = 0;
                    foreach (var addBlind in blinddata)
                    {
                        var cardtexture = GameContent.TextureDict[addBlind];
                        var cardGraphics = new AndroidCard(cardtexture, addBlind)
                        {
                            IsBlind = true,
                            Position = new Vector2(blindLoc, ScreenHeight / 4.0f)
                        };
                        BlindList[blindIndex] = cardGraphics;
                        blindIndex++;
                        blindLoc += 500;
                    }
                    foreach (var playerPair in PlayerGraphicsDict)
                    {
                        var playerGraphicsHand = playerPair;
                        var playerHand = playerPair.Key.Hand;
                        var screen = ScreenWidth / 2 - 500;
                        foreach (var card in playerHand)
                        {
                            var cardtexture = GameContent.TextureDict[card];
                            var cardGraphics = new AndroidCard(cardtexture, card)
                            {
                                Position = new Vector2(screen, ScreenHeight - 200)
                            };
                            playerGraphicsHand.Value.AddCardToHand(cardGraphics);
                            screen += 150;
                        }
                    }
                    ChangeState(new AndroidPreGameState(this, _graphics.GraphicsDevice, GameContent));
                    State = StateType.PreGame;
                    
                    break;
                    
                case PromptType.Pick:
                    ChangeState(_blindState);
                    State = StateType.Blind;
                    prompt = _blindState.PickingPrompt();
                    _blindState.Prompt = "";
                    break;

                case PromptType.BotPlayCard:
                    break;

                case PromptType.PlayCard:
                    State = StateType.Playing;                   
                    picker = (IPlayer)data[PromptData.Picker];
                    player = (IPlayer)data[PromptData.Player];
                    trick = (ITrick)data[PromptData.Trick];
                    ChangeState(_playingState);
                    _playingState.SetTrick(trick);
                    _playingState.SetPicker(picker);
                    var cards = (List<ICard>)data[PromptData.Cards];
                    PlayableCards = new List<AndroidCard>();
                    PlayerGraphicsDict.TryGetValue(player, out var playergraphics);
                    foreach (var card in cards)
                    {
                        if (playergraphics == null) continue;
                        foreach (var cardgraphics in playergraphics.PlayableCards)
                        {
                            if (!card.Equals(cardgraphics.Card)) continue;
                            PlayableCards.Add(cardgraphics);
                            cardgraphics.IsPlayable = true;
                            break;
                        }
                    }
                    prompt = _playingState.PickingPrompt();
                    if (prompt != "")
                    {
                        _playingState.IsTrickSet = false;
                        _playingState.LeaderboardSet = false;
                    }

                    break;

                case PromptType.PickBlind:
                    State = StateType.Picking;
                    player = (IPlayer)data[PromptData.Player];
                    var blind = (IBlind)data[PromptData.Blind];
                    _pickingState.AssignBlind(blind);
                    _pickingState.AssignPlayer(player);
                    ChangeState(_pickingState);
                    prompt = _pickingState.PickingPrompt();
                    _pickingState.Prompt = "";
                    break;

                case PromptType.RoundOver:
                    trick = ((IRound)data[PromptData.Round]).Trick;
                    ChangeState(_roundOverState);
                    State = StateType.RoundOver;
                    _roundOverState.SetTrick(trick);
                    prompt = _roundOverState.PickingPrompt();
                    if (prompt != "")
                    {
                       _roundOverState = new AndroidRoundOverState(this, _graphics.GraphicsDevice, GameContent);
                    }
                    break;

                case PromptType.GameOver:
                    ChangeState(_gameOverState);
                    State = StateType.GameOver;
                    var game = (IGame)data[PromptData.Game];
                    _gameOverState.SetGame(game);
                    _gameOverState.SetSharedSheepTable(_table);
                    _gameOverState.SetScoreSheet(_table.ScrSheet);
                    prompt = _gameOverState.PickingPrompt();
                    break;

                case PromptType.TableOver:
                    ChangeState(_tableOverstate);
                    State = StateType.TableOver;
                    _tableOverstate.SetSharedSheepTable(_table);
                    _tableOverstate.SetScoreSheet(_table.ScrSheet);
                    prompt = _tableOverstate.PickingPrompt();
                    if (prompt == "done")
                        this.Exit();
                    else if (prompt == "playAgain")
                    {
                        _titleState = new AndroidTitleScreen(this, _graphics.GraphicsDevice, GameContent);
                        ChangeState(_titleState);
                    }
                    break;

                case PromptType.CallUp:
                    prompt = "Would you like to call up? (yes/no): ";
                    break;

                case PromptType.CalledUp:
                    prompt = string.Format("\nPicker called up to {0}\n", _table.Games.Last().PartnerCard);
                    break;

                default:
                    return "";
            }
            return prompt;
        }