private void ProcessCoord(VEntity character, Coord coord, TargetingComponent cardTargeter) { //Outline cell c (by toggling each edge). ecsManager.GetAnimationSystem <HighlightDisplaySystem>().CreateGreyHighlightWithTags(new Coord[] { coord }, new string[] { "Outline" }); bool passes = true; foreach (ValidTargetingMethod validTargetingMethod in cardTargeter.validTargetingMethods) { if (!validTargetingMethod.ValidateCoord(coord, ecsManager)) { passes = false; } } if (passes) { GetList(targetingSpaces, character.id).Add(coord); //Highlight the cell according to validTargetingMethod.effectType. Tag it with ValidSpace ecsManager.GetAnimationSystem <HighlightDisplaySystem>().CreateHighlightsWithTags(new List <Coord> { coord }, new List <string> { "ValidSpace" }, ecsManager.GetAnimationSystem <HighlightDisplaySystem>().lightGreenColor); } }
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); } } } } } } }
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; }