コード例 #1
0
        public VEntity GetPlayerUnitByClass(CardType type)
        {
            UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>();

            string unitId = unitsList.unitIds.Find((id) => {
                CharacterClassComponent characterClassComponent = ecsManager.GetVComponent <CharacterClassComponent>(id);
                return(characterClassComponent != null && characterClassComponent.cardType == type);
            });

            return(ecsManager.GetVEntityById(unitId));
        }
コード例 #2
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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
 void HandleLeftClick()
 {
     if (State == InputState.SELECTCARD)
     {
         if (cardHovering != null)
         {
             //cardController.AttemptPlayCard(cardHovering);
             if (cardController.IsPlayable(cardHovering.cardEntityId))
             {
                 cardSelected = cardHovering;
                 cardMover.ClickCard(cardSelected);
                 State = InputState.SELECTSPACE;
                 cardController.MyHandState = HandState.SELECTED;
             }
         }
     }
     else if (State == InputState.SELECTSPACE)
     {
         IEnumerable <VEntity> playableUnitIds = boardState.GetSystem <UnitFinderSystem>().GetAllPlayerUnits();
         if (boardSpaceHovering != Coord.nullCoord)
         {
             Debug.Log("Clicking space");
             int             belongs       = 0;
             IList <VEntity> belongingList = new List <VEntity>();
             foreach (VEntity v in playableUnitIds)
             {
                 if (boardState.GetAnimationSystem <PlayCardSystem>().IsSpaceInRange(boardSpaceHovering, v.id))
                 {
                     belongs++;
                     belongingList.Add(v);
                 }
             }
             Debug.Log(belongs);
             if (belongs == 0)
             {
                 //invalid space
             }
             else
             {
                 spaceSelected = boardSpaceHovering;
                 if (belongs > 1)
                 {
                     State = InputState.CONFLICTRESOLUTION;
                 }
                 else if (belongs == 1)
                 {
                     FinishPlayingCard(cardSelected, spaceSelected, belongingList[0]);
                 }
             }
         }
     }
     else if (State == InputState.CONFLICTRESOLUTION)
     {
         if (boardSpaceHovering != Coord.nullCoord)
         {
             VEntity selectedChar = boardState.GetSystem <UnitFinderSystem>().GetUnitAtCoord(boardSpaceHovering);
             if (selectedChar != null)
             {
                 CharacterClassComponent charClass = selectedChar.GetVComponent <CharacterClassComponent>();
                 if (charClass != null)
                 {
                     FinishPlayingCard(cardSelected, spaceSelected, selectedChar);
                 }
             }
         }
     }
 }