Esempio n. 1
0
        protected override void OnPlayerTurnStart(VEntity entity)
        {
            PlayerHandComponent playerHandComponent = entity.GetVComponent <PlayerHandComponent>();

            ecsManager.CreateEvent("StartTurnDraw", component: new CardDrawEvent {
                numCards = playerHandComponent.startTurnDrawCount
            });
        }
Esempio n. 2
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            CardDrawEvent         cardDraw            = entity.GetVComponent <CardDrawEvent>();
            CardZoneDataComponent zoneData            = ecsManager.GetVSingletonComponent <CardZoneDataComponent>();
            PlayerHandComponent   PlayerHandComponent = ecsManager.GetVSingletonComponent <PlayerHandComponent>();

            for (int cardDrawIndex = 0; cardDrawIndex < cardDraw.numCards; ++cardDrawIndex)
            {
                // get top card of deck
                //If deck is empty, shuffle discard into deck
                if (zoneData.zones[Zone.DECK].Count == 0)
                {
                    //If there is no discard pile, draw fizzles.
                    if (zoneData.zones[Zone.DISCARD].Count == 0)
                    {
                        return;
                    }
                    for (int i = zoneData.zones[Zone.DISCARD].Count - 1; i >= 0; i--)
                    {
                        ecsManager.ExecuteImmediateEvent("moveZone", component: new CardZoneMoveEvent {
                            source      = Zone.DISCARD,
                            destination = Zone.DECK,
                            card        = zoneData.zones[Zone.DISCARD][i]
                        });
                    }
                    DeckHelper.Shuffle(zoneData.zones[Zone.DECK]);
                }

                string cardToDraw = zoneData.zones[Zone.DECK][0];
                //If there's space, draw, else discard.
                if (zoneData.zones[Zone.HAND].Count < PlayerHandComponent.maxHandSize)
                {
                    ecsManager.ExecuteImmediateEvent("moveZone", component: new CardZoneMoveEvent {
                        source      = Zone.DECK,
                        destination = Zone.HAND,
                        card        = cardToDraw
                    });
                }
                else
                {
                    ecsManager.ExecuteImmediateEvent("moveZone", component: new CardZoneMoveEvent {
                        source      = Zone.DECK,
                        destination = Zone.DISCARD,
                        card        = cardToDraw
                    });
                }
            }
        }
Esempio n. 3
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            CardDiscardEvent      discardedCards      = entity.GetVComponent <CardDiscardEvent>();
            CardZoneDataComponent zoneData            = ecsManager.GetVSingletonComponent <CardZoneDataComponent>();
            PlayerHandComponent   PlayerHandComponent = ecsManager.GetVSingletonComponent <PlayerHandComponent>();

            foreach (string cardToDiscard in zoneData.zones[Zone.HAND].ToArray())
            {
                if (Array.IndexOf(discardedCards.cardIds, cardToDiscard) >= 0)
                {
                    ecsManager.ExecuteImmediateEvent("moveZone", component: new CardZoneMoveEvent {
                        source      = Zone.HAND,
                        destination = Zone.DISCARD,
                        card        = cardToDiscard
                    });
                }
            }
        }