Example #1
0
        public AllocationManager(Animation anim, StateType type, AllocationManager previous = null)
        {
            this.anim = anim;
            this.type = type;
            RootWidget root = anim.AnimLayer.RootWidget;
            deckCards = new PlayingCardListAllocator(this, root.DeckPlaceholder);
            graveyardCards = new PlayingCardListAllocator(this, root.GraveyardPlaceholder);
            selectionCards = new PlayingCardListAllocator(this, root.SelectionPlaceholder);

            IGame game = ConnectionManager.Game;

            int count = game.Players.Count;
            playerHands = new Dictionary<int, PlayingCardListAllocator>(count);
            playerTables = new Dictionary<int, PlayingCardListAllocator>(count);
            playerLifePoints = new Dictionary<int, LifePointsCardAllocator>(count);
            playerRoles = new Dictionary<int, RoleCardAllocator>(count);
            foreach(IPublicPlayerView player in game.Players)
            {
                int playerId = player.ID;
                playerHands.Add(playerId, new PlayingCardListAllocator(this, root.GetPlayerHandPlaceholder(playerId)));
                playerTables.Add(playerId, new PlayingCardListAllocator(this, root.GetPlayerTablePlaceholder(playerId)));
                playerLifePoints.Add(playerId, new LifePointsCardAllocator(this, root.GetPlayerCharacterPlaceholder(playerId), anim.GetPlayerCharacterAnimator(playerId)));
                playerRoles.Add(playerId, new RoleCardAllocator(this, root.GetPlayerRolePlaceholder(playerId), anim.GetPlayerRoleAnimator(playerId)));
            }
            playingCardZoom = new CardZoomAllocator(this, anim.AnimLayer, anim.GetPlayingCardZoomAnimator());
            roleCardZoom = new CardZoomAllocator(this, anim.AnimLayer, anim.GetRoleCardZoomAnimator());
            characterCardZoom = new CardZoomAllocator(this, anim.AnimLayer, anim.GetCharacterCardZoomAnimator());

            if(previous != null)
            {
                int thisPlayerId = 0;
                if(ConnectionManager.PlayerGameControl != null)
                    thisPlayerId = ConnectionManager.PlayerGameControl.PrivatePlayerView.ID;
                List<PlayingCardAnimator> lastGraveyard = previous.graveyardCards.Animators;
                if(lastGraveyard.Count != 0)
                {
                    PlayingCardAnimator prev = lastGraveyard[lastGraveyard.Count - 1];
                    PlayingCardAnimator a = anim.GetPlayingCardAnimator(prev.ID);
                    a.GetState(type).Update(prev.GetState(previous.type));
                    this.graveyardCards.Animators.Add(a);
                }

                UpdateList(this.selectionCards, previous.selectionCards, previous.type);

                foreach(int id in previous.playerHands.Keys)
                    UpdateList(this.playerHands[id], previous.playerHands[id], previous.type, type == StateType.End && id != thisPlayerId);

                foreach(int id in previous.playerTables.Keys)
                    UpdateList(this.playerTables[id], previous.playerTables[id], previous.type);

                foreach(int id in previous.playerLifePoints.Keys)
                    this.playerLifePoints[id].LifePoints = previous.playerLifePoints[id].LifePoints;

                this.playingCardZoom.Visible = previous.playingCardZoom.Visible;
                this.roleCardZoom.Visible = previous.roleCardZoom.Visible;
                this.characterCardZoom.Visible = previous.characterCardZoom.Visible;
            }
        }
Example #2
0
        public Animation(AnimationLayer layer, Animation lastAnim = null, TimeSpan animLength = default(TimeSpan))
        {
            this.layer = layer;
            if(animLength.Ticks > 0L)
                this.animLength = animLength;
            else
                this.animLength = DefaultAnimDuration;
            onlyEnd = false;
            ended = false;
            sw = new Stopwatch();

            playingCardAnimators = new Dictionary<int, PlayingCardAnimator>();
            playerRoleAnimators = new Dictionary<int, RoleCardAnimator>(8);
            playerCharacterAnimators = new Dictionary<int, CharacterCardAnimator>(8);
            foreach(IPublicPlayerView player in ConnectionManager.Game.Players)
            {
                int id = player.ID;
                playerRoleAnimators[id] = new RoleCardAnimator(this, layer.GetPlayerRoleWidget(id));
                playerCharacterAnimators[id] = new CharacterCardAnimator(this, layer.GetPlayerCharacterWidget(id));
                if(lastAnim != null)
                {
                    RoleCardState lastRoleState = lastAnim.playerRoleAnimators[id].EndState;
                    playerRoleAnimators[id].StartState.Update(lastRoleState);
                    playerRoleAnimators[id].EndState.Update(lastRoleState);

                    CharacterCardState lastCharacterState = lastAnim.playerCharacterAnimators[id].EndState;
                    playerCharacterAnimators[id].StartState.Update(lastCharacterState);
                    playerCharacterAnimators[id].EndState.Update(lastCharacterState);
                }
            }
            playingCardZoomAnimator = new CardZoomAnimator(this, layer.GetPlayingCardZoomWidget());
            roleCardZoomAnimator = new CardZoomAnimator(this, layer.GetRoleCardZoomWidget());
            characterCardZoomAnimator = new CardZoomAnimator(this, layer.GetCharacterCardZoomWidget());

            if(lastAnim != null)
            {
                startAllocManager = new AllocationManager(this, StateType.Start, lastAnim.endAllocManager);
                endAllocManager = new AllocationManager(this, StateType.End, lastAnim.endAllocManager);
            }
            else
            {
                startAllocManager = new AllocationManager(this, StateType.Start);
                endAllocManager = new AllocationManager(this, StateType.End);
                onlyEnd = true;
            }
        }