Пример #1
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            DeathEventComponent ecDeath     = VEntityComponentSystemManager.GetVComponent <DeathEventComponent>(entity);
            VEntity             dyingEntity = ecsManager.GetVEntityById(ecDeath.id);

            if (dyingEntity != null)
            {
                HealthComponent h = dyingEntity.GetVComponent <HealthComponent>();
                if (h != null && h.currHealth > 0)
                {
                    return;
                }

                ecsManager.MarkRemovalEntity(dyingEntity);

                // remove the entity from all relevant things
                UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>();
                unitsList.unitIds.Remove(dyingEntity.id);
                PositionTrackSystem positionTrackSystem = ecsManager.GetSystem <PositionTrackSystem>();
                positionTrackSystem.Untrack(dyingEntity.id);

                ecsManager.QueueAnimationEvent("DeathAnimation", component: new DeathAnimationEvent {
                    deathTransform = dyingEntity.GetVComponent <PositionDisplayComponent>().mainTransform,
                    dyingEntityId  = dyingEntity.id
                });
            }
        }
Пример #2
0
        protected override void OnBeforeEvent(VEntity entity)
        {
            LowLevelDealDamageEvent dealDamage = entity.GetVComponent <LowLevelDealDamageEvent>();
            VEntity blockingEntity             = ecsManager.GetVEntityById(dealDamage.receiverId);

            BlockBuffComponent block = blockingEntity.GetVComponent <BlockBuffComponent>();

            if (block != null)
            {
                int blockDeduct = Math.Min(block.blockAmount, dealDamage.damageAmount);

                block.blockAmount       -= blockDeduct;
                dealDamage.damageAmount -= blockDeduct;

                if (blockingEntity.HasVComponent <BlockDisplayComponent>())
                {
                    int newBlockAmount = block.blockAmount;
                    NumberedIconDisplay blockDisplay = blockingEntity.GetVComponent <BlockDisplayComponent>().blockDisplay;
                    ecsManager.QueueAnimationEvent("blockRemoveEvent", component: new GenericBlockingAnimationEvent {
                        a = (passedEcsManager) => {
                            blockDisplay.transform.DOShakePosition(.5f, .1f);
                            blockDisplay.SetValue(newBlockAmount);
                        },
                        duration = 0.5f
                    });
                }
            }
        }
Пример #3
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            LowLevelDealDamageEvent damageEvent = entity.GetVComponent <LowLevelDealDamageEvent>();

            if (damageEvent.damageAmount <= 0)
            {
                return;
            }

            VEntity         damageDealtEntity = ecsManager.GetVEntityById(damageEvent.receiverId);
            HealthComponent h = VEntityComponentSystemManager.GetVComponent <HealthComponent>(damageDealtEntity);

            h.currHealth -= damageEvent.damageAmount;

            if (h.currHealth <= 0)
            {
                h.currHealth = 0;
                ecsManager.CreateEvent("unitDeath", component: new DeathEventComponent {
                    id = damageDealtEntity.id
                });
            }

            ecsManager.QueueAnimationEvent("setHealth", components: new VComponent[] {
                new HealthSetAnimationEvent {
                    targetEntity = damageDealtEntity.id,
                    currHealth   = h.currHealth,
                    maxHealth    = h.maxHealth
                },
                new UnitDamagedAnimationEvent {
                    targetEntity = damageDealtEntity.id
                }
            });
        }
Пример #4
0
        public override void DoImmediateAnimation(VEntity entity)
        {
            VEntity targetEntity = ecsManager.GetVEntityByIdIncludingRemoved(entity.GetVComponent <EntityAppearEvent>().entityId);
            HealthDisplayComponent healthDisplay = ecsManager.GetVEntityById(entity.GetVComponent <EntityAppearEvent>().entityId).GetVComponent <HealthDisplayComponent>();

            healthDisplay.healthBarDisplay = HealthBarDisplay.Instantiate(healthBarDisplayPrefab);
            HealthComponent h = targetEntity.GetVComponent <HealthComponent>();

            Assert.IsNotNull(h);
            healthDisplay.healthBarDisplay.Init(h.maxHealth);
            healthDisplay.healthBarDisplay.SetValue(h.currHealth);

            var positionDisplay = targetEntity.GetVComponent <PositionDisplayComponent>();

            healthDisplay.healthBarDisplay.transform.position = positionDisplay.mainTransform.position;
            healthDisplay.healthBarDisplay.transform.SetParent(positionDisplay.mainTransform);
        }
Пример #5
0
        protected override void OnPlayerTurnStart(VEntity entity)
        {
            PlayerHandComponent playerHandComponent = entity.GetVComponent <PlayerHandComponent>();

            ecsManager.CreateEvent("StartTurnDraw", component: new CardDrawEvent {
                numCards = playerHandComponent.startTurnDrawCount
            });
        }
Пример #6
0
        public override IEnumerator StartAnimation(VEntity entity, Action yieldAnimation)
        {
            MovementAnimationEvent moveEvent = entity.GetVComponent <MovementAnimationEvent>();
            Tween myTween = ecsManager.GetVEntityById(moveEvent.entityToMove).GetVComponent <PositionDisplayComponent>().mainTransform.DOMove(ecsManager.GetSystem <PositionWorldConversionSystem>().GetTransformFromCoord(moveEvent.to), 0.5f);

            yield return(myTween.WaitForCompletion());

            yieldAnimation();
        }
Пример #7
0
        public override IEnumerator StartAnimation(VEntity entity, Action yieldAnimation)
        {
            GenericBlockingAnimationEvent genericAnim = entity.GetVComponent <GenericBlockingAnimationEvent>();

            genericAnim.a(ecsManager);
            yield return(new WaitForSeconds(genericAnim.duration));

            yieldAnimation();
        }
Пример #8
0
        private void UpdateBoardForSelectCardState()
        {
            if (currTargetingState.cardHoveringId != prevTargetingState.cardHoveringId || currTargetingState.state != prevTargetingState.state)
            {
                // ClearCellMarks(VCellSelectedState.GREEN);
                //Un-outline all cells.
                //Remove all ValidSpace marks.
                //Remove all GroupTarget marks.
                ecsManager.GetAnimationSystem <HighlightDisplaySystem>().Remove(null, new string[] {
                    "Outline",
                    "ValidSpace",
                    "GroupTarget"
                });
                IEnumerable <VEntity> characters = ecsManager.GetSystem <UnitFinderSystem>().GetAllPlayerUnits();

                foreach (VEntity c in characters)
                {
                    GetList(targetingSpaces, c.id).Clear();
                }
                if (currTargetingState.cardHoveringId != "")
                {
                    VEntity            card         = ecsManager.GetVEntityById(currTargetingState.cardHoveringId);
                    CardClassComponent cardClass    = card.GetVComponent <CardClassComponent>();
                    TargetingComponent cardTargeter = card.GetVComponent <TargetingComponent>();
                    foreach (VEntity character in characters)
                    {
                        CharacterClassComponent characterClass    = character.GetVComponent <CharacterClassComponent>();
                        PositionComponent       characterPosition = character.GetVComponent <PositionComponent>();
                        if (cardClass.cardType == characterClass.cardType || cardClass.cardType == CardType.NEUTRAL)
                        {
                            foreach (TargetingMethod targetingMethod in cardTargeter.targetingMethods)
                            {
                                List <Coord> newCoords = targetingMethod.SelectCoords(characterPosition.position, ecsManager);
                                foreach (Coord coord in newCoords)
                                {
                                    ProcessCoord(character, coord, cardTargeter);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #9
0
        public override bool ValidateCoord(Coord loc, VEntityComponentSystemManager boardState)
        {
            VEntity unit = boardState.GetSystem <UnitFinderSystem>().GetUnitAtCoord(loc);

            if (unit != null)
            {
                return(unit.GetVComponent <TeamComponent>().team == team);
            }

            return(false);
        }
Пример #10
0
        public override void DoImmediateAnimation(VEntity entity)
        {
            HealthSetAnimationEvent healthSetEvent = entity.GetVComponent <HealthSetAnimationEvent>();
            VEntity targetEntity = ecsManager.GetVEntityByIdIncludingRemoved(healthSetEvent.targetEntity);

            HealthDisplayComponent healthDisplay = targetEntity.GetVComponent <HealthDisplayComponent>();

            if (healthDisplay != null)
            {
                healthDisplay.healthBarDisplay.SetValue(healthSetEvent.currHealth);
            }
        }
Пример #11
0
        public void InitializeFromEntity(VEntity entity)
        {
            cardEntityId = entity.id;
            cost         = entity.GetVComponent <ManaCostComponent>().cost;
            effect       = entity.GetVComponent <EffectTextComponent>().effect;
            cardType     = entity.GetVComponent <CardClassComponent>().cardType;

            nameText.text   = entity.GetVComponent <CardNameComponent>().name;
            costText.text   = cost.ToString();
            effectText.text = effect;
            classText.text  = StringUtils.ClassEnumToString(cardType);

            cardBacks.Add(CardType.NEUTRAL, neutralQuad);
            cardBacks.Add(CardType.ORION, orionQuad);
            cardBacks.Add(CardType.OPHELIA, opheliaQuad);
            foreach (CardType t in cardBacks.Keys)
            {
                cardBacks[t].SetActive(false);
            }
            cardBacks[cardType].SetActive(true);
        }
Пример #12
0
        public override void DoImmediateAnimation(VEntity entity)
        {
            UnitDamagedAnimationEvent unitDamagedEvent = entity.GetVComponent <UnitDamagedAnimationEvent>();
            VEntity targetEntity = ecsManager.GetVEntityByIdIncludingRemoved(unitDamagedEvent.targetEntity);

            UnitDisplayComponent unitDisplay = targetEntity.GetVComponent <UnitDisplayComponent>();

            if (unitDisplay != null)
            {
                var tween = unitDisplay.unitDisplayGameObject.GetSpriteRenderer().DOColor(Color.red, 0.1f).SetLoops(4, LoopType.Yoyo);
            }
        }
Пример #13
0
        protected override void OnBeforeEvent(VEntity eventEntity)
        {
            CardPlayEvent cardPlayEvent = eventEntity.GetVComponent <CardPlayEvent>();
            VEntity       card          = ecsManager.GetVEntityById(cardPlayEvent.cardId);

            //ecsManager.ExecuteImmediateEvent("cardMoveInPlay", component: new CardZoneMoveEvent
            //{
            //    source = Zone.HAND,
            //    destination = Zone.INPLAY,
            //    card = card.id,
            //});
        }
Пример #14
0
        protected override void OnPlayerTurnStart(VEntity entity)
        {
            PlayerManaComponent playerMana = entity.GetVComponent <PlayerManaComponent>();
            int oldMana = playerMana.currMana;

            playerMana.currMana = playerMana.maxMana;

            ecsManager.QueueAnimationEvent("ManaAnimation", component: new PlayerManaSetAnimation {
                oldMana = oldMana,
                newMana = playerMana.currMana,
                maxMana = playerMana.maxMana
            });
        }
Пример #15
0
        protected override void OnBeforeEvent(VEntity eventEntity)
        {
            CardPlayEvent       cardPlayEvent = eventEntity.GetVComponent <CardPlayEvent>();
            VEntity             card          = ecsManager.GetVEntityById(cardPlayEvent.cardId);
            PlayerManaComponent playerMana    = ecsManager.GetVSingletonComponent <PlayerManaComponent>();
            int prevMana = playerMana.currMana;

            playerMana.currMana -= card.GetVComponent <ManaCostComponent>().cost;
            ecsManager.QueueAnimationEvent("cardPlayedManaDrain", component: new PlayerManaSetAnimation {
                maxMana = playerMana.maxMana,
                newMana = playerMana.currMana,
                oldMana = prevMana,
            });
        }
Пример #16
0
        public override void DoImmediateAnimation(VEntity entity)
        {
            DeathAnimationEvent deathAnimationEvent = entity.GetVComponent <DeathAnimationEvent>();

            if (deathAnimationEvent.deathTransform != null)
            {
                deathAnimationEvent.deathTransform.gameObject.SetActive(false);
                GameObject.Destroy(deathAnimationEvent.deathTransform.gameObject);
            }

            ecsManager.GetAnimationSystem <HighlightDisplaySystem>().Remove(null, new string[] {
                deathAnimationEvent.dyingEntityId
            });
        }
Пример #17
0
        protected override void OnExecuteEvent(VEntity eventEntity)
        {
            BlockApplyEffectEvent blockEvent = eventEntity.GetVComponent <BlockApplyEffectEvent>();
            VEntity blockingEntity           = ecsManager.GetVEntityById(blockEvent.sourceId);

            if (!blockingEntity.HasVComponent <BlockBuffComponent>())
            {
                ecsManager.AddComponent(blockingEntity, new BlockBuffComponent {
                });
                ecsManager.AddComponent(blockingEntity, new BlockDisplayComponent {
                    blockDisplay = NumberedIconDisplay.Instantiate(iconDisplayPrefab)
                });

                NumberedIconDisplay blockDisplayForAppear = blockingEntity.GetVComponent <BlockDisplayComponent>().blockDisplay;
                blockDisplayForAppear.gameObject.transform.SetParent(blockingEntity.GetVComponent <PositionDisplayComponent>().mainTransform);
                blockDisplayForAppear.gameObject.transform.localPosition = new Vector3(.1f, .1f, 0.0f);

                ecsManager.QueueAnimationEvent("blockAppearAnim", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        blockDisplayForAppear.Appear();
                    }
                });
            }

            BlockBuffComponent blockComponent = blockingEntity.GetVComponent <BlockBuffComponent>();

            blockComponent.blockAmount += (blockEvent.blockAmount);

            string blockAmountString         = blockComponent.blockAmount.ToString();
            NumberedIconDisplay blockDisplay = blockingEntity.GetVComponent <BlockDisplayComponent>().blockDisplay;

            ecsManager.QueueAnimationEvent("blockIncrement", component: new GenericImmediateAnimationEvent {
                a = (passedEcsManager) => {
                    blockDisplay.SetValue(blockAmountString);
                }
            });
        }
Пример #18
0
        protected override void OnEnemyActionsResolve(VEntity entity)
        {
            QueuedActionComponent queuedAction        = entity.GetVComponent <QueuedActionComponent>();
            List <VComponent>     effectComponentList = ecsManager.CloneComponents(queuedAction.effects.Cast <VComponent>().ToList());
            PositionComponent     entityPosition      = entity.GetVComponent <PositionComponent>();

            Coord[] targetedCoords = Coord.ResolveRelativeCoords(queuedAction.relativeTargetedCoords, entityPosition.position);
            // fill in the components with the right data
            foreach (VComponent component in effectComponentList)
            {
                if (component is CardEffectComponent c)
                {
                    c.sourceId          = entity.id;
                    c.targetCoord       = Coord.nullCoord;
                    c.groupTargetCoords = new List <Coord>(targetedCoords);
                }
            }

            ecsManager.ExecuteImmediateEvent("CardEffect", components: effectComponentList);

            ecsManager.RemoveComponent <QueuedActionComponent>(entity);

            //handle de highlight animation
            ecsManager.QueueAnimationEvent("wait", component: new GenericBlockingAnimationEvent {
                a        = (passedEcsManager) => { },
                duration = 0.5f,
            });

            ecsManager.QueueAnimationEvent("dehighlight", component: new GenericImmediateAnimationEvent {
                a = (passedEcsManager) => {
                    passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().Remove(targetedCoords, new List <string> {
                        entity.id
                    });
                }
            });
        }
Пример #19
0
        protected override void OnEnemyActionsEnd(VEntity entity)
        {
            ecsManager.RemoveComponent <BlockBuffComponent>(entity);

            if (entity.HasVComponent <BlockDisplayComponent>())
            {
                NumberedIconDisplay blockDisplay = entity.GetVComponent <BlockDisplayComponent>().blockDisplay;
                ecsManager.RemoveComponent <BlockDisplayComponent>(entity);
                ecsManager.QueueAnimationEvent("blockRemoveEvent", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        blockDisplay.Break();
                    }
                });
            }
        }
Пример #20
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
                    });
                }
            }
        }
Пример #21
0
        private void UpdateBoardForSelectSpaceState()
        {
            if (currTargetingState.boardSpaceHovering != prevTargetingState.boardSpaceHovering || currTargetingState.state != prevTargetingState.state)
            {
                IEnumerable <VEntity> characters = ecsManager.GetSystem <UnitFinderSystem>().GetAllPlayerUnits();
                foreach (VEntity c in characters)
                {
                    GetList(groupTargetingSpaces, c.id).Clear();
                }

                //Re-enable all ValidSpace marks.
                ecsManager.GetAnimationSystem <HighlightDisplaySystem>().SetEnable(null, new string[] {
                    "ValidSpace"
                }, true);
                //Remove all GroupTarget marks.
                ecsManager.GetAnimationSystem <HighlightDisplaySystem>().Remove(null, new string[] {
                    "GroupTarget"
                });

                if (currTargetingState.boardSpaceHovering != Coord.nullCoord)
                {
                    foreach (VEntity character in characters)
                    {
                        PositionComponent characterPosition = character.GetVComponent <PositionComponent>();
                        if (GetList(targetingSpaces, character.id).Contains(currTargetingState.boardSpaceHovering))
                        {
                            VEntity card = ecsManager.GetVEntityById(currTargetingState.cardSelectedId);
                            foreach (GroupTargetingMethod groupTargeting in card.GetVComponent <TargetingComponent>().groupTargetingMethods)
                            {
                                List <Coord> newCoords = groupTargeting.SelectGroupCoords(currTargetingState.boardSpaceHovering, characterPosition.position, ecsManager);
                                Debug.Log("Group Targeting Method Coords: " + newCoords.Count);
                                GetList(groupTargetingSpaces, character.id).AddRange(newCoords);
                                //Highlight c. Tag it with GroupTarget, color based on the effectType
                                //Disable ValidSpace mark, if it has one.
                                ecsManager.GetAnimationSystem <HighlightDisplaySystem>().CreateHighlightsWithTags(newCoords, new string[] {
                                    "GroupTarget"
                                }, ColorFromEffectType(groupTargeting.effectType));
                                //Debug.Log(ColorFromEffectType(groupTargeting.effectType));
                                ecsManager.GetAnimationSystem <HighlightDisplaySystem>().SetEnable(GetList(groupTargetingSpaces, character.id), new string[] {
                                    "ValidSpace"
                                }, false);
                            }
                        }
                    }
                }
            }
        }
Пример #22
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            DamageEffectEventComponent damageComponent = VEntityComponentSystemManager.GetVComponent <DamageEffectEventComponent>(entity);
            VEntity damageDealingEnitty = ecsManager.GetVEntityById(damageComponent.sourceId);

            foreach (Coord c in damageComponent.groupTargetCoords)
            {
                VEntity damageDealtEntity = ecsManager.GetSystem <UnitFinderSystem>().GetUnitAtCoord(c);
                if (damageDealtEntity != null && damageDealtEntity.GetVComponent <TeamComponent>().team != damageDealingEnitty.GetVComponent <TeamComponent>().team)
                {
                    ecsManager.ExecuteImmediateEvent("lowLevelDamageEvent", component: new LowLevelDealDamageEvent {
                        damageAmount = damageComponent.damageAmount,
                        sourceId     = damageComponent.sourceId,
                        receiverId   = damageDealtEntity.id
                    });
                }
            }
        }
Пример #23
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
                    });
                }
            }
        }
Пример #24
0
        protected override void OnExecuteEvent(VEntity eventEntity)
        {
            CardPlayEvent cardPlayEvent = eventEntity.GetVComponent <CardPlayEvent>();
            VEntity       caster        = ecsManager.GetVEntityById(cardPlayEvent.casterId);
            VEntity       card          = ecsManager.GetVEntityById(cardPlayEvent.cardId);
            Coord         dest          = cardPlayEvent.targetSpace;
            Dictionary <CardEffectType, List <Coord> > groupTargetCoords = cardPlayEvent.groupTargetingSpaces;

            foreach (CardEffectType t in groupTargetCoords.Keys)
            {
                Debug.Log("Type Key: " + t);
            }

            // create a new event entity with all the card actions
            GameplayEffectComponent effects = card.GetVComponent <GameplayEffectComponent>();

            List <VComponent> effectComponentList = ecsManager.CloneComponents(effects.effectEvents.Cast <VComponent>().ToList());

            // fill in the components with the right data
            foreach (VComponent component in effectComponentList)
            {
                if (component is CardEffectComponent c)
                {
                    c.sourceId          = caster.id;
                    c.targetCoord       = dest;
                    c.groupTargetCoords = groupTargetCoords[EffectComponentToEffectTypeHelper(c)];

                    if (c is DamageEffectEventComponent d)
                    {
                        Debug.Log("Doing damage to " + c.groupTargetCoords.Count + " spaces.");
                    }
                }
            }

            ecsManager.ExecuteImmediateEvent("CardEffect", components: effectComponentList);

            // move the card from the hand to the deck.
            ecsManager.ExecuteImmediateEvent("cardMoveToDiscard", component: new CardZoneMoveEvent {
                source      = Zone.HAND,
                destination = Zone.DISCARD,
                card        = card.id,
            });
        }
Пример #25
0
        void FinishPlayingCard(CardGameObject card, Coord space, VEntity caster)
        {
            Debug.Log("Finish playing card");
            cardSelected.locked = false;
            cardSelected        = null;

            VEntity            cardPlayed = boardState.GetVEntityById(card.cardEntityId);
            TargetingComponent targeting  = VEntityComponentSystemManager.GetVComponent <TargetingComponent>(cardPlayed);
            Dictionary <CardEffectType, List <Coord> > mapping = new Dictionary <CardEffectType, List <Coord> >();

            foreach (GroupTargetingMethod m in targeting.groupTargetingMethods)
            {
                if (!mapping.ContainsKey(m.effectType))
                {
                    mapping[m.effectType] = new List <Coord>();
                }
                mapping[m.effectType].AddRange(m.SelectGroupCoords(space, caster.GetVComponent <PositionComponent>().position, boardState));
            }
            foreach (CardEffectType t in mapping.Keys)
            {
                Debug.Log("Type Key: " + t);
            }

            boardState.CreateEvent("playCard", component: new CardPlayEvent {
                cardId               = card.cardEntityId,
                targetSpace          = space,
                casterId             = caster.id,
                groupTargetingSpaces = mapping
            });

            if (card.cantrip)
            {
                boardState.CreateEvent("cantripUsed", component: new CantripUseEvent
                {
                });
            }

            spaceSelected = Coord.nullCoord;
            State         = InputState.SELECTCARD;
            cardController.MyHandState = HandState.IDLE;
        }
Пример #26
0
        protected override void OnAfterEvent(VEntity eventEntity)
        {
            MovementEvent         movement     = eventEntity.GetVComponent <MovementEvent>();
            VEntity               movedEntity  = ecsManager.GetVEntityById(movement.sourceId);
            QueuedActionComponent queuedAction = movedEntity.GetVComponent <QueuedActionComponent>();

            if (queuedAction != null)
            {
                // update the view with animation event
                Coord[] targetedCoords = Coord.ResolveRelativeCoords(queuedAction.relativeTargetedCoords, movedEntity.GetVComponent <PositionComponent>().position);

                ecsManager.QueueAnimationEvent("highlight", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().CreateHighlightsWithTags(targetedCoords, new List <string> {
                            "EnemyAttack",
                            movedEntity.id
                        }, passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().redColor);
                    }
                });
            }
        }
Пример #27
0
        protected override void OnBeforeEvent(VEntity eventEntity)
        {
            MovementEvent         movement     = eventEntity.GetVComponent <MovementEvent>();
            VEntity               movedEntity  = ecsManager.GetVEntityById(movement.sourceId);
            QueuedActionComponent queuedAction = movedEntity.GetVComponent <QueuedActionComponent>();

            if (queuedAction != null)
            {
                Debug.Log("removing old highlights");
                // update the view with animation event
                Coord[] targetedCoords = Coord.ResolveRelativeCoords(queuedAction.relativeTargetedCoords, movedEntity.GetVComponent <PositionComponent>().position);

                ecsManager.QueueAnimationEvent("highlight", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().Remove(null, new List <string> {
                            movedEntity.id
                        });
                    }
                });
            }
        }
Пример #28
0
        protected override void OnExecuteEvent(VEntity eventEntity)
        {
            QueueActionEvent queueActionEvent = eventEntity.GetVComponent <QueueActionEvent>();
            VEntity          queuer           = ecsManager.GetVEntityById(queueActionEvent.entityId);

            ecsManager.AddComponent(queuer, new QueuedActionComponent {
                relativeTargetedCoords = Coord.cardinalCoords,
                effects = new List <CardEffectComponent> {
                    new DamageEffectEventComponent {
                        damageAmount = 5
                    }
                }
            });

            Coord[] targetedCoords = Coord.ResolveRelativeCoords(queuer.GetVComponent <QueuedActionComponent>().relativeTargetedCoords, queuer.GetVComponent <PositionComponent>().position);
            ecsManager.QueueAnimationEvent("highlight", component: new GenericImmediateAnimationEvent {
                a = (passedEcsManager) => {
                    passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().CreateHighlightsWithTags(targetedCoords, new List <string> {
                        "EnemyAttack",
                        queuer.id
                    }, passedEcsManager.GetAnimationSystem <HighlightDisplaySystem>().redColor);
                }
            });
        }
Пример #29
0
        public Coord Resolve(RelativePositionComponent cRelativePosition)
        {
            VEntity eOrigin = ecsManager.GetVEntityById(cRelativePosition.relativeEntityId);

            return(eOrigin.GetVComponent <PositionComponent>().position + cRelativePosition.delta);
        }
Пример #30
0
        public override bool ShouldOperate(VEntity entity)
        {
            EntityAppearEvent e = entity.GetVComponent <EntityAppearEvent>();

            return(e != null && (ecsManager.GetVEntityById(e.entityId).GetVComponent <UnitDisplayComponent>() != null));
        }