protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return GetValidBuys(state) .Where(pile => Treasure.Basic.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .First(); }
// 1. List<pos + DateTime (class)> // högre och högre tid på olika pos // 2. bild i ps, rita cirklar dra streck mellan dom.. // 3. bygga på med vinklar (sist, till att börja med kör vi med position) public override void Initialize(GameContext context) { base.Initialize(context); snapShots = new List<Snapshot>(); snapShots.Add(new Snapshot(TimeSpan.FromSeconds(0), new Vector2(487.0f, 585.0f))); snapShots.Add(new Snapshot(TimeSpan.FromSeconds(3), new Vector2(510.0f, 200.0f))); snapShots.Add(new Snapshot(TimeSpan.FromSeconds(7), new Vector2(775.0f, 326.0f))); snapShots.Add(new Snapshot(TimeSpan.FromSeconds(10), new Vector2(1142.0f, 103.0f))); this.spriteBatch = spriteBatch ?? new SpriteBatch(Context.Graphics.Device); time = ""; interpolate = new Vector2(); gameServer = ServiceLocator.Get<IGameServer>(); gameClient = ServiceLocator.Get<IGameClient>(); messageHandler = ServiceLocator.Get<IMessageHandler>(); // Create the connection between the client and server gameServer.Start(); gameClient.Connect(); //sendTimer = new GameTimer(TimeSpan.FromMilliseconds(1000 / 20), SendClientSpatial); Context.Input.Keyboard.ClearMappings(); Context.Input.Keyboard.AddMapping(Keys.F1); Context.Input.Keyboard.AddMapping(Keys.F2); Context.Input.Keyboard.AddMapping(Keys.F3); }
private static void _NotifyRoomLayoutChanged(Room room) { if (room == null) { return; } foreach (var notify in room.Seats) { if (notify.Account != null) { try { IGameClient channel = null; lock (loggedInAccounts) { channel = loggedInAccounts[notify.Account.UserName].CallbackChannel; } Trace.Assert(channel != null); channel.NotifyRoomUpdate(room.Id, room); } catch (Exception) { } } } }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return(GetValidBuys(state) .Where(pile => pile.Is(CardType.Victory)) .OrderByDescending(pile => VictoryCards.Basic.Contains(pile.Name)) .First()); }
public SessionManager(ITimeLogic timer, IGameClient clients) { _id = Guid.NewGuid().ToString(); _clients = clients; _timer = timer; DoReset(); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return GetValidBuys(state) .Where(pile => pile.Is(CardType.Victory)) .OrderByDescending(pile => VictoryCards.Basic.Contains(pile.Name)) .First(); }
/// <summary> /// The human client will take on the race of the first 'opponent' in the gamesettings file. /// </summary> /// <param name="race">Race to play</param> public HumanClient(GameSettings gameSettings, GameSpeed speed = GameSpeed.Faster, ILogger log = null) { _settings = gameSettings; _client = new GameClient(_settings, log); _speed = speed; _log = log; }
public override void Initialize(GameContext context) { base.Initialize(context); globalSettings = ServiceLocator.Get<GlobalSettings>(); gameClient = ServiceLocator.Get<IGameClient>(); }
public void Register(IGameClient client) { foreach (var bot in this.bots) { bot.Register(client); } }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return(GetValidBuys(state) .Where(pile => Treasure.Basic.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .First()); }
public void OnJoined(IGameClient client, int index, GameData.PlayerData playerData) { Node startBlock = GameBoard.FindBlockByName(playerData.currentBlockName); if (connectionViewController != null) { connectionViewController.Dismiss(); } if (startBlock) { PlayerController playerController; if (PhotonNetwork.connectedAndReady) { playerController = PlayerController.createAvatarPlayer(playerData.colorPath, Vector3.zero, Quaternion.identity); } else { playerController = PlayerController.CreateLocalPlayer(playerData.colorPath); } GameBoard.MovePlayerToBlockNode(playerController, startBlock); if (players.ContainsKey(index) == false) { Debug.Log("add player at index: " + index); players.Add(index, new PlayerInfo(playerController, playerData)); } } }
private void InitMainMenu() { PatternProxyInst.Stopcandles(); if (UseFakeNetworClient) { _networkClient = new LocalGameClient(); } else { _networkClient = new GameClient("wss://ggj2016-server.herokuapp.com/room"); } _networkClient.onConnected += ServerConnected; _networkClient.onLevelStarted += ServerLevelStarted; _networkClient.onGameStarted += ServerGameStarted; _networkClient.onEdgeFilled += EdgeFilledByPlayer; _networkClient.onLevelWon += ServerLevelWon; _networkClient.onClientError += ServerHadError; _networkClient.onGameCompleted += ServerCompletedGame; _networkClient.onLevelLost += ServerLostLevel; _networkClient.onNumberOfPlayersChanged += ServerNumberOfPlayersChanged; _networkClient.Connect(); IngameUI.SetActive(false); MainMenuUI.SetActive(true); _currentLevel = -1; SoundManager.Instance.PlayBackgroundMusic(); }
private static void AutoSave(IGameClient client) { if ((DateTime.UtcNow - client.LastSave).TotalSeconds > ServerContext.Config.SaveRate) { client.Save(); } }
public void Attach(IGameClient client) { _client = client; client.GameStateUpdates.ObserveOn(Scheduler.NewThread) //.Delay(TimeSpan.FromMilliseconds(new Random(client.GetHashCode()).Next(500, 1500))) .Subscribe(Respond); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { if(!_enumerator.Current.CanRespond(activity, state)) _enumerator.MoveNext(); _enumerator.Current.Respond(client, activity, state); _enumerator.MoveNext(); }
public PollingDuplexClient(IGameClient gameClient) : base() { PollingDuplexMessageContext context = new PollingDuplexMessageContext(gameClient); context.Faulted += new EventHandler(context_Faulted); this.Context = context; }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var pile = SelectPile(state); TalkSmack(pile, client); var message = new BuyCardMessage(client.PlayerId, pile.Id); client.AcceptMessage(message); }
public void Run(GameMode mode, IGameClient client) { Context.Run(); Model = new GameModel(mode); View.ApplyModel(Model); Client = client; ApplyInitState(); }
public UnityRavenfallClient( ILogger logger, IMessageBus messageBus, IGameClient2 client) { this.logger = logger; this.messageBus = messageBus; messageBus.Subscribe <TwitchUserJoined>(nameof(TwitchUserJoined), OnUserJoined); messageBus.Subscribe <TwitchUserLeft>(nameof(TwitchUserLeft), OnUserLeft); messageBus.Subscribe <TwitchCheer>(nameof(TwitchCheer), OnUserCheer); messageBus.Subscribe <TwitchSubscription>(nameof(TwitchSubscription), OnUserSub); this.client = client; this.client.Connected += Client_OnConnect; this.client.Subscribe("join_failed", OnJoinFailed); this.client.Subscribe("join_success", SendResponseToTwitchChat); this.client.Subscribe("arena_join_success", SendResponseToTwitchChat); this.client.Subscribe("arena_join_failed", SendResponseToTwitchChat); this.client.Subscribe("raid_join_success", SendResponseToTwitchChat); this.client.Subscribe("raid_join_failed", SendResponseToTwitchChat); this.client.Subscribe("raid_start", OnRaidStart); this.client.Subscribe("player_stats", SendResponseToTwitchChat); this.client.Subscribe("player_resources", SendResponseToTwitchChat); this.client.Subscribe("highest_skill", SendResponseToTwitchChat); this.client.Subscribe("kick_success", OnKickPlayerSuccess); this.client.Subscribe("kick_failed", OnKickPlayerFailed); this.client.Subscribe("craft_success", SendResponseToTwitchChat); this.client.Subscribe("craft_failed", SendResponseToTwitchChat); this.client.Subscribe("duel_failed", SendResponseToTwitchChat); this.client.Subscribe("duel_alert", SendResponseToTwitchChat); this.client.Subscribe("duel_accept", SendResponseToTwitchChat); this.client.Subscribe("duel_declined", SendResponseToTwitchChat); this.client.Subscribe("duel_result", SendResponseToTwitchChat); this.client.Subscribe("item_pickup", SendResponseToTwitchChat); this.client.Subscribe("item_trade_result", SendResponseToTwitchChat); this.client.Subscribe("ferry_enter_failed", SendResponseToTwitchChat); this.client.Subscribe("ferry_leave_failed", SendResponseToTwitchChat); this.client.Subscribe("ferry_travel_failed", SendResponseToTwitchChat); this.client.Subscribe("train_failed", SendResponseToTwitchChat); this.client.Subscribe("ferry_success", SendResponseToTwitchChat); this.client.Subscribe("train_info", SendResponseToTwitchChat); this.client.Subscribe("island_info", SendResponseToTwitchChat); this.client.Subscribe("message", SendResponseToTwitchChat); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var idsToTrash = state.Hand.Where(c => c.Is<Curse>() || c.Is<Copper>() || c.Is<Estate>()) .Select(c => c.Id) .Take(activity.ParseNumberOfCardsToSelect()) .ToArray(); client.AcceptMessage(new SelectCardsMessage(client.PlayerId, idsToTrash)); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var idsToTrash = state.Hand.Where(c => c.Is <Curse>() || c.Is <Copper>() || c.Is <Estate>()) .Select(c => c.Id) .Take(activity.ParseNumberOfCardsToSelect()) .ToArray(); client.AcceptMessage(new SelectCardsMessage(client.PlayerId, idsToTrash)); }
private static void Pulse(TimeSpan elapsedTime, IGameClient client) { if (client?.Aisling != null) { ObjectComponent.UpdateClientObjects(client.Aisling); } client?.Update(elapsedTime); }
public static SurrogateForIGameClient Convert(IGameClient value) { if (value == null) { return(null); } return(new SurrogateForIGameClient { Target = ((GameClientRef)value).Target }); }
protected override void TalkSmack(CardPileViewModel pile, IGameClient client) { base.TalkSmack(pile, client); if (pile.Name == "Province") client.SendChatMessage("Province muthafucka!"); if (pile.Name == "Colony") client.SendChatMessage("COLONY! SUCK IT!"); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { while (!_enumerator.Current.CanRespond(activity, state)) { _enumerator.MoveNext(); } _enumerator.Current.Respond(client, activity, state); _enumerator.MoveNext(); }
public MainLogic(IGameClient clients) { Logger.Trace("MainLogic"); _clients = clients; _session = new SessionManager(timer: this, clients: _clients); CreateAuxLogics(); InitSessionManager(); }
public void OnGameEnded(IGameClient game) { Debug.Log("Game Ended"); ClearPlayers(); ShowHud(false); //UINavigationController.PushBackground("/MainBackground"); //UINavigationController.PushController("/GameOver"); }
public void SetGameClientPlugin(IGameClient gameClient) { if (GameClientPlugin != gameClient) { GameData.Load(); var dataSlot = GameData.current.GetCurrentDataSlot(); GameClientPlugin = gameClient; GameClientPlugin.Initialize(this, dataSlot); } }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { var options = GetValidBuys(state).Where(c => _distribution.Contains(c.Name)); var exactValueOptions = options .Where(pile => pile.Cost.ToString() == state.Status.AvailableSpend.DisplayValue); return(exactValueOptions.Any() ? _distribution.RandomItem(exactValueOptions, c => c.Name) : _distribution.RandomItem(options, c => c.Name)); }
public bool Withdraw(IGameClient client, string itemName) { if (!Items.ContainsKey(itemName)) { return(false); } var itemObj = Items[itemName].Pop(); return(itemObj?.GiveTo(client.Aisling) ?? false); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { var options = GetValidBuys(state).Where(c => _distribution.Contains(c.Name)); var exactValueOptions = options .Where(pile => pile.Cost.ToString() == state.Status.AvailableSpend.DisplayValue); return exactValueOptions.Any() ? _distribution.RandomItem(exactValueOptions, c => c.Name) : _distribution.RandomItem(options, c => c.Name); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var options = activity.ParseOptions(); Choice choice = options.First(); if (options.Contains(Choice.Yes)) choice = Choice.Yes; client.AcceptMessage(new ChoiceMessage(client.PlayerId, choice.ToString())); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var decklist = client.GetDecklist(); if (state.Results.Winner == client.PlayerName) { foreach (var card in decklist.Where(c => _distribution.Contains(c.Name))) { _distribution.IncreaseLikelihood(card.Name); } } }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { int count = activity.ParseNumberOfCardsToSelect(); var ids = PrioritiseCards(state, activity) .Take(count) .Select(c => c.Id) .ToArray(); var message = new SelectCardsMessage(client.PlayerId, ids); client.AcceptMessage(message); }
public GameViewModel GetGameState(IGameClient client) { _lock.EnterReadLock(); try { return(new GameViewModel(_game, _players[client])); } finally { _lock.ExitReadLock(); } }
public UnityBabyYodaClient( ILogger logger, IMessageBus messageBus, IGameClient2 client) { this.logger = logger; this.messageBus = messageBus; this.client = client; this.client.Connected += Client_OnConnect; this.client.Subscribe("message", SendResponseToTwitchChat); }
public GameViewModel GetGameState(IGameClient client) { _lock.EnterReadLock(); try { return new GameViewModel(_game, _players[client]); } finally { _lock.ExitReadLock(); } }
public void Attach(IGameClient client) { if (_client != null) _subscription.Dispose(); _lastGameStateVersionHandled = 0; _lastActivityHandled = Guid.Empty; _client = client; _subscription = client.GameStateUpdates.ObserveOn(Scheduler.NewThread) .Subscribe(Respond); }
private void RefreshTarget(IGameClient client) { if (client.Aisling.Dead) { ClearTarget(); } if (client.Aisling.Invisible) { ClearTarget(); } }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var action = state.Hand .Where(c => c.Is(CardType.Action)) .Where(c => AISupportedActions.All.Contains(c.Name)) .OrderByDescending(c => AISupportedActions.PlusActions.Contains(c.Name)) .ThenByDescending(c => c.Cost) .First(); var message = new PlayCardMessage(client.PlayerId, action.Id); client.AcceptMessage(message); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { var options = GetValidBuys(state) .Where(pile => AISupportedActions.All.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .ThenBy(pile => _random.Next(100)) .ToList(); var message = string.Format("I considered {0}.", string.Join(", ", options.Select(x => x.Name).ToArray())); client.SendChatMessage(message); return options.FirstOrDefault(); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var options = activity.ParseOptions(); Choice choice = options.First(); if (options.Contains(Choice.Yes)) { choice = Choice.Yes; } client.AcceptMessage(new ChoiceMessage(client.PlayerId, choice.ToString())); }
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { var options = GetValidBuys(state) .Where(pile => AISupportedActions.All.Contains(pile.Name)) .OrderByDescending(pile => pile.Cost) .ThenBy(pile => _random.Next(100)) .ToList(); var message = string.Format("I considered {0}.", string.Join(", ", options.Select(x => x.Name).ToArray())); client.SendChatMessage(message); return(options.FirstOrDefault()); }
protected override void TalkSmack(CardPileViewModel pile, IGameClient client) { base.TalkSmack(pile, client); if (pile.Name == "Province") { client.SendChatMessage("Province muthafucka!"); } if (pile.Name == "Colony") { client.SendChatMessage("COLONY! SUCK IT!"); } }
public void Attach(IGameClient client) { if (_client != null) { _subscription.Dispose(); } _lastGameStateVersionHandled = 0; _lastActivityHandled = Guid.Empty; _client = client; _subscription = client.GameStateUpdates.ObserveOn(Scheduler.NewThread) .Subscribe(Respond); }
public override void Initialize(GameContext context) { base.Initialize(context); stringBuilder = new StringBuilder(100, 500); gameServer = ServiceLocator.Get<IGameServer>(); gameClient = ServiceLocator.Get<IGameClient>(); // Create the connection between the client and server gameServer.Start(); gameClient.Connect(); startedLoading = false; hasRenderedContent = false; }
public bool Init(Log.on_log on_log, ISockCallee callee) { Log.SetLogCallBack(on_log); m_gameClient = new GameClient(); if (m_localClient == null) { m_localClient = new GameClient(); } m_gameSock = new GameSock(); if (!m_gameSock.Init(callee)) { return(false); } ((GameReceiver)m_gameSock.GetGameReceiver()).SetGameClient((GameClient)m_gameClient); return(true); }
// Use this for initialization void Start () { if (url.StartsWith ("local")) { gameClient = new LocalGameClient (); } else { gameClient = new GameClient (url); } gameClient.onConnected += GameClient_onConnected; gameClient.onLevelWon += GameClient_onLevelWon; gameClient.onEdgeFilled += GameClient_onEdgeFilled; gameClient.onNumberOfPlayersChanged += GameClient_onNumberOfPlayersChanged; gameClient.onClientError += GameClient_onClientError; gameClient.onLevelStarted += GameClient_onLevelStarted; gameClient.onLevelLost += GameClient_onLevelLost; gameClient.onGameCompleted += GameClient_onGameCompleted; gameClient.onGameStarted += GameClient_onGameStarted; Debug.Log ("Calling load"); gameClient.Connect (); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var pile = SelectPile(state, client); TalkSmack(pile, client); IGameActionMessage message = null; if (activity.ParseType() == ActivityType.DoBuys) { message = new BuyCardMessage(client.PlayerId, pile.Id); } else if (activity.ParseType() == ActivityType.SelectPile) { message = new ChooseAPileMessage(client.PlayerId, pile == null ? Guid.Empty : pile.Id); } client.AcceptMessage(message); }
public IList<CardViewModel> GetDecklist(IGameClient client) { _lock.EnterReadLock(); try { var player = _players[client]; var cards = new List<ICard>(); cards.AddRange(player.Deck.Contents); cards.AddRange(player.Discards); cards.AddRange(player.Hand); cards.AddRange(player.PlayArea); return cards .Select(c => new CardViewModel(c)) .OrderBy(c => c.Name) .ToList(); } finally { _lock.ExitReadLock(); } }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var selected = state.Revealed.First(); client.AcceptMessage(new SelectCardsMessage(client.PlayerId, new[] { selected.Id })); }
public void Respond(IGameClient client, ActivityModel activity, GameViewModel state) { var message = new MoveToBuyStepMessage(client.PlayerId); client.AcceptMessage(message); }
protected abstract CardPileViewModel SelectPile(GameViewModel state, IGameClient client);
protected override CardPileViewModel SelectPile(GameViewModel state, IGameClient client) { return state.Bank.Single(p => p.Is<Potion>()); }
public string GetPlayerName(IGameClient client) { return client == FirstClient ? FirstGamerName : SecondGamerName; }
public IGameClient GetOpponent(IGameClient gameClient) { if (_clients.Contains(gameClient)) return _clients.FirstOrDefault(x => x != gameClient); else throw new Exception("Critical error! Opponent wasn't found!"); }
protected virtual void TalkSmack(CardPileViewModel pile, IGameClient client) { }