Exemplo n.º 1
0
        private void SetAvatarImage(GameAvatar avatarID)
        {
            switch (avatarID)
            {
            case GameAvatar.Blue:
                _avatarImageView.SetImageResource(Resource.Mipmap.blue);
                break;

            case GameAvatar.Green:
                _avatarImageView.SetImageResource(Resource.Mipmap.green);
                break;

            case GameAvatar.Milky:
                _avatarImageView.SetImageResource(Resource.Mipmap.milky);
                break;

            case GameAvatar.Sand:
                _avatarImageView.SetImageResource(Resource.Mipmap.sand);
                break;

            case GameAvatar.Wooden1:
                _avatarImageView.SetImageResource(Resource.Mipmap.wooden1);
                break;

            case GameAvatar.Wooden2:
                _avatarImageView.SetImageResource(Resource.Mipmap.wooden2);
                break;
            }
        }
Exemplo n.º 2
0
        public void Save(string name, GameAvatar avatar)
        {
            if (!_players.Keys.Contains(name) && !AvatarIsTaken(avatar))
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    name = GeneratePlayerName();
                }

                var p = new Player(name, avatar);
                _players.Add(name, p);
            }
        }
Exemplo n.º 3
0
        public Player(string name, GameAvatar avatar, IDice dice = null)
        {
            this.Name   = name;
            this.Avatar = avatar;

            if (dice != null)
            {
                this.Dice = dice;
            }
            else
            {
                this.Dice = new Dice();
            }
        }
Exemplo n.º 4
0
    public void SetAvatar(Image imageComponent, string av_name)
    {
        GameAvatar av = null;

        if (Avatars.Count > 0)
        {
            av = Avatars.Find(x => x.image.name.Equals(av_name));
            if (av == null)
            {
                av = Avatars [0];
            }
        }
        if (av != null)
        {
            imageComponent.sprite = av.image;
        }
    }
Exemplo n.º 5
0
        public void OnAvatarImageButtonClick(View gameBoardButtonView)
        {
            GameAvatar gameAvatarValue = GameAvatar.Blue;

            if (gameBoardButtonView != null &&
                (gameBoardButtonView is ImageButton))
            {
                switch (gameBoardButtonView.Id)
                {
                case Resource.Id.avatar0:
                    gameAvatarValue = GameAvatar.Blue;
                    break;

                case Resource.Id.avatar1:
                    gameAvatarValue = GameAvatar.Green;
                    break;

                case Resource.Id.avatar2:
                    gameAvatarValue = GameAvatar.Milky;
                    break;

                case Resource.Id.avatar3:
                    gameAvatarValue = GameAvatar.Sand;
                    break;

                case Resource.Id.avatar4:
                    gameAvatarValue = GameAvatar.Wooden1;
                    break;

                case Resource.Id.avatar5:
                    gameAvatarValue = GameAvatar.Wooden2;
                    break;
                }

                _settingsDB.DeviceAvatarId = (int)gameAvatarValue;

                if (!GameTools._sqLiteDbManager.UpdateSettings(_settingsDB))
                {
                    Toast.MakeText(ApplicationContext, "Zapis obrazka do bazy się nie powiódł!", ToastLength.Short).Show();
                }

                Intent settingsActivityIntent = new Intent(this, typeof(SettingsActivity));
                StartActivity(settingsActivityIntent);
            }
        }
        private void SetAvatarImageNextMove()
        {
            GameAvatar avatarID = 0;

            if (_currentSymbolGamer != _yourSymbolGame)
            {
                avatarID = (GameAvatar)GameTools._sqLiteDbManager.selectSettings().DeviceAvatarId;
            }
            else
            {
                avatarID = (GameAvatar)GameTools._opponentSettingsDB.DeviceAvatarId;
            }

            switch (avatarID)
            {
            case GameAvatar.Blue:
                _avatarImageView.SetImageResource(Resource.Mipmap.blue);
                break;

            case GameAvatar.Green:
                _avatarImageView.SetImageResource(Resource.Mipmap.green);
                break;

            case GameAvatar.Milky:
                _avatarImageView.SetImageResource(Resource.Mipmap.milky);
                break;

            case GameAvatar.Sand:
                _avatarImageView.SetImageResource(Resource.Mipmap.sand);
                break;

            case GameAvatar.Wooden1:
                _avatarImageView.SetImageResource(Resource.Mipmap.wooden1);
                break;

            case GameAvatar.Wooden2:
                _avatarImageView.SetImageResource(Resource.Mipmap.wooden2);
                break;
            }
        }
        private static void OnChangeGameStateMessageReceived(ChangeGameStateMessage message)
        {
            if (GameSessionManager.TryGet(message.SessionId, out GameSession session))
            {
                GameAvatar document = session.GameAvatar;

                switch (message.StateType)
                {
                case GameStateType.HOME:
                    session.DestructGameState();
                    session.LoadGameState(new GameHomeState
                    {
                        PlayerAvatar    = document.LogicClientAvatar,
                        Home            = document.LogicClientHome,
                        SaveTime        = document.SaveTime,
                        MaintenanceTime = document.MaintenanceTime,
                        ServerCommands  = document.ServerCommands,
                        LayoutId        = message.LayoutId,
                        MapId           = message.MapId
                    });
                    break;

                case GameStateType.NPC_ATTACK:
                    session.DestructGameState();
                    session.LoadGameState(new GameNpcAttackState
                    {
                        PlayerAvatar = document.LogicClientAvatar,
                        Home         = GameResourceManager.NpcHomes[message.NpcData.GetInstanceID()],
                        NpcAvatar    = LogicNpcAvatar.GetNpcAvatar(message.NpcData),
                        SaveTime     = -1
                    });
                    break;

                case GameStateType.NPC_DUEL:
                    session.DestructGameState();
                    session.LoadGameState(new GameNpcDuelState
                    {
                        PlayerAvatar = document.LogicClientAvatar,
                        Home         = GameResourceManager.NpcHomes[message.NpcData.GetInstanceID()],
                        NpcAvatar    = LogicNpcAvatar.GetNpcAvatar(message.NpcData),
                        SaveTime     = -1
                    });
                    break;

                case GameStateType.VISIT:
                    ServerRequestManager.Create(new GameAvatarRequestMessage
                    {
                        AccountId = message.HomeId
                    }, ServerManager.GetDocumentSocket(9, message.HomeId), 5).OnComplete = args =>
                    {
                        if (!session.IsDestructed())
                        {
                            if (args.ErrorCode == ServerRequestError.Success && args.ResponseMessage.Success)
                            {
                                GameAvatarResponseMessage gameAvatarResponseMessage = (GameAvatarResponseMessage)args.ResponseMessage;

                                session.DestructGameState();
                                session.LoadGameState(new GameVisitState
                                {
                                    Home            = gameAvatarResponseMessage.Document.LogicClientHome,
                                    HomeOwnerAvatar = gameAvatarResponseMessage.Document.LogicClientAvatar,
                                    SaveTime        = gameAvatarResponseMessage.Document.SaveTime,

                                    PlayerAvatar = session.GameAvatar.LogicClientAvatar
                                });
                            }
                            else
                            {
                                session.SendPiranhaMessage(new VisitFailedMessage(), 1);
                            }
                        }
                    };

                    break;

                case GameStateType.CHALLENGE_ATTACK:
                    session.DestructGameState();

                    LogicLong       liveReplayId    = LiveReplayManager.Create(session, message.ChallengeAllianceId, message.ChallengeStreamId);
                    LogicClientHome logicClientHome = new LogicClientHome();

                    logicClientHome.SetHomeId(message.ChallengeHomeId);
                    logicClientHome.GetCompressibleHomeJSON().Set(message.ChallengeHomeJSON);

                    session.LoadGameState(new GameChallengeAttackState
                    {
                        Home         = logicClientHome,
                        PlayerAvatar = document.LogicClientAvatar,
                        SaveTime     = -1,
                        LiveReplayId = liveReplayId,
                        AllianceId   = message.ChallengeAllianceId,
                        StreamId     = message.ChallengeStreamId,
                        MapId        = message.ChallengeMapId
                    });

                    ServerMessageManager.SendMessage(new AllianceChallengeLiveReplayIdMessage
                    {
                        AccountId    = message.ChallengeStreamId,
                        LiveReplayId = liveReplayId
                    }, 11);

                    break;
                }
            }
        }
Exemplo n.º 8
0
 private bool AvatarIsTaken(GameAvatar avatar)
 {
     return((from x in _players
             where x.Value.Avatar == avatar
             select x).Count() > 0);
 }