public AnimationLayer(RootWidget rootWidget) { root = rootWidget; animQueue = new Queue<Animation>(); playingCardWidgets = new Dictionary<int, PlayingCardWidget>(); playerRoleWidgets = new Dictionary<int, RoleCardWidget>(8); playerCharacterWidgets = new Dictionary<int, CharacterCardWidget>(8); playingCardZoomWidget = new PlayingCardWidget(); roleCardZoomWidget = new RoleCardWidget(); characterCardZoomWidget = new CharacterCardWidget(); playingCardZoomWidget.OnLClick += (w) => UnsetCardZoomWidget(); playingCardZoomWidget.OnRClick += (w) => UnsetCardZoomWidget(); roleCardZoomWidget.OnLClick += (w) => UnsetCardZoomWidget(); roleCardZoomWidget.OnRClick += (w) => UnsetCardZoomWidget(); characterCardZoomWidget.OnLClick += (w) => UnsetCardZoomWidget(); characterCardZoomWidget.OnRClick += (w) => UnsetCardZoomWidget(); timerThread = new Thread(RunTimer); timerThread.IsBackground = true; timerThread.Start(); listener = new EventListener(this); ConnectionManager.SessionEventListener.AddListener((IPlayerSessionEventListener)listener); ConnectionManager.SessionEventListener.AddListener((ISpectatorSessionEventListener)listener); ConnectionManager.OnSessionDisconnected += () => { Gdk.Threads.Enter(); Clear(); Gdk.Threads.Leave(); }; }
public void SetCardZoomWidget(RoleCardWidget cardWidget) { lock(animLock) { if(cardZoomWidgetSet) return; roleCardZoomWidget.Update(cardWidget); cardZoomWidgetSet = true; if(animQueue.Count == 0) { Animation anim = new Animation(this, current, new TimeSpan(0, 0, 0, 0, 500)); anim.EndAllocManager.SetRoleCardZoomVisible(true); EnqueueAnimation(anim); } else { bool first = true; foreach(Animation anim in animQueue) { if(first) first = false; else anim.StartAllocManager.SetRoleCardZoomVisible(true); anim.EndAllocManager.SetRoleCardZoomVisible(true); } } } }
/// <summary> /// Updates the animation layer. /// </summary> /// <remarks> /// This method is used to update the animation layer for a new game. /// </remarks> private void Update() { lock(animLock) { Clear(); int thisPlayerId = 0; if(ConnectionManager.PlayerGameControl != null) thisPlayerId = ConnectionManager.PlayerGameControl.PrivatePlayerView.ID; foreach(IPublicPlayerView player in ConnectionManager.Game.Players) { int id = player.ID; playerRoleWidgets[id] = new RoleCardWidget(player.Role); playerRoleWidgets[id].OnRClick += (w) => SetCardZoomWidget((RoleCardWidget)w); playerCharacterWidgets[id] = new CharacterCardWidget(player.CharacterType); if(id == thisPlayerId) playerCharacterWidgets[id].OnLClick += (w) => { System.Threading.ThreadPool.QueueUserWorkItem((state) => { IPlayerControl control = ConnectionManager.PlayerGameControl; if(control == null) return; try { control.RespondUseAbility(); Gdk.Threads.Enter(); root.SetResponseType(Catalog.GetString("Use Ability")); } catch(GameException e) { Gdk.Threads.Enter(); root.SetResponseType(Catalog.GetString("Use Ability"), e); } RequestRedraw(); Gdk.Threads.Leave(); }); }; playerCharacterWidgets[id].OnRClick += (w) => SetCardZoomWidget((CharacterCardWidget)w); } } }
public void Update(RoleCardWidget other) { role = other.role; Card = other.Card; }