コード例 #1
0
        public override bool IsActionPossible(CardSlot source, CardSlot target)
        {
            var actionPoints = source.Card.GetComponent <ActionPointsComponent>();

            if (actionPoints != null && actionPoints.CurrentActionPoints < Cost)
            {
                Utilities.SpawnFloatingText("Insufficient action points!", Color.red, source.Card.transform);
                return(false);
            }
            var targetHealthComponent = target.Card.GetComponent <HealthComponent>();

            if (targetHealthComponent == null)
            {
                Utilities.SpawnFloatingText("Invalid target!", Color.red, source.Card.transform);
                return(false);
            }
            var rowManager = source.transform.parent.GetComponent <RowManager>();

            if (rowManager != target.transform.parent.GetComponent <RowManager>())
            {
                Utilities.SpawnFloatingText("Invalid row!", Color.red, source.Card.transform);
                return(false);
            }
            if (IsTargetOutsideRange(rowManager, source, target))
            {
                Utilities.SpawnFloatingText("Outside range!", Color.red, source.Card.transform);
                return(false);
            }
            return(true);
        }
コード例 #2
0
 public int GetDistanceBetweenCards(CardSlot slot1, CardSlot slot2)
 {
     Assert.IsNotNull(slot1);
     Assert.IsNotNull(slot2);
     Assert.IsFalse(slot1 == slot2);
     return(Mathf.Abs(currentCardSlots.IndexOf(slot1) - currentCardSlots.IndexOf(slot2)));
 }
コード例 #3
0
        public override bool IsActionPossible(CardSlot source, CardSlot target)
        {
            var actionPoints = source.Card.GetComponent <ActionPointsComponent>();

            if (actionPoints != null && actionPoints.CurrentActionPoints < Cost)
            {
                Utilities.SpawnFloatingText("Insufficient action points!", Color.red, source.Card.transform);
                return(false);
            }
            var rowManager = source.transform.parent.GetComponent <RowManager>();

            if (rowManager != target.transform.parent.GetComponent <RowManager>())
            {
                Utilities.SpawnFloatingText("Invalid row!", Color.red, source.Card.transform);
                return(false);
            }
            int selectedIndex = rowManager.GetIndexOfCard(source.Card);
            int otherIndex    = rowManager.GetIndexOfCard(target.Card);

            if (Mathf.Abs(selectedIndex - otherIndex) == 1)
            {
                return(true);
            }
            else
            {
                Utilities.SpawnFloatingText("Outside range!", Color.red, source.Card.transform);
                return(false);
            }
        }
コード例 #4
0
 private void OnCardSlotSelectionChange(CardSlot previous, CardSlot current)
 {
     if (InputManager.Instance != null)
     {
         var availableActions = InputManager.Instance.GetAvailableActions();
         if (availableActions.Count > 0)
         {
             for (int i = 0; i < buttons.Length; ++i)
             {
                 if (i >= availableActions.Count)
                 {
                     buttons[i].SetActionIndex(-1);
                 }
                 else
                 {
                     buttons[i].SetActionIndex(i);
                 }
             }
             GetComponent <Image>().enabled = true;
         }
         else
         {
             for (int i = 0; i < buttons.Length; ++i)
             {
                 buttons[i].SetActionIndex(-1);
             }
             GetComponent <Image>().enabled = false;
         }
     }
 }
コード例 #5
0
 public void RemoveCard(CardSlot slotWithCard)
 {
     Assert.IsTrue(currentCardSlots.Contains(slotWithCard));
     slotWithCard.RemoveCard();
     currentCardSlots.Remove(slotWithCard);
     slotWithCard.LifecycleComponent.OnLifecycleComponentDestroyed -= OnSlotDestroyed;
     Destroy(slotWithCard.gameObject);
 }
コード例 #6
0
 private void OnSlotSelected(CardSlot previous, CardSlot current)
 {
     if (current == this)
     {
         button.colors = selectedColorBlock;
     }
     else
     {
         button.colors = defaultColorBlock;
     }
 }
コード例 #7
0
        private void ProcessAction(CardSlot otherSlot)
        {
            var selectedCard    = SelectedCardSlot.Card;
            var playerOwnedCard = selectedCard as IActionProvider;

            Assert.IsNotNull(playerOwnedCard);
            var availableActions = playerOwnedCard.GetAvailableActions();

            Assert.IsTrue(SelectedActionIndex >= 0 && SelectedActionIndex < availableActions.Count);
            availableActions[SelectedActionIndex].ExecuteAction(SelectedCardSlot, otherSlot);
            SelectedCardSlot = selectedCard.GetComponentInParent <CardSlot>();
        }
コード例 #8
0
        private bool IsTargetOutsideRange(RowManager rowManager, CardSlot source, CardSlot target)
        {
            int selectedIndex = rowManager.GetIndexOfCard(source.Card);
            int otherIndex    = rowManager.GetIndexOfCard(target.Card);
            int distance      = Mathf.Abs(selectedIndex - otherIndex);

            if (distance >= MinRange && distance <= MaxRange)
            {
                return(false);
            }
            return(true);
        }
コード例 #9
0
 public override void ExecuteAction(CardSlot source, CardSlot target)
 {
     if (IsActionPossible(source, target))
     {
         var actionPoints = source.Card.GetComponent <ActionPointsComponent>();
         if (actionPoints != null)
         {
             actionPoints.Spend(Cost);
         }
         var targetHealthComponent = target.Card.GetComponent <HealthComponent>();
         targetHealthComponent.Damage(Damage);
         Utilities.SpawnFloatingText(Name, Color.grey, source.Card.transform);
         LogManager.Instance.AddMessage(source.Card.CardName + " attacked " + target.Card.CardName + " with " + Name + " for " + Damage.ToString() + " damage");
         AudioManager.Instance.PlaySound(Name);
     }
 }
コード例 #10
0
 public override void ExecuteAction(CardSlot source, CardSlot target)
 {
     if (IsActionPossible(source, target))
     {
         var actionPoints = source.Card.GetComponent <ActionPointsComponent>();
         if (actionPoints != null)
         {
             actionPoints.Spend(Cost);
         }
         var rowManager  = source.transform.parent.GetComponent <RowManager>();
         int sourceIndex = rowManager.GetIndexOfCard(source.Card);
         int targetIndex = rowManager.GetIndexOfCard(target.Card);
         Utilities.SpawnFloatingText("Move", Color.grey, source.Card.transform);
         if (sourceIndex < targetIndex)
         {
             rowManager.MoveCardRight(source);
         }
         else if (sourceIndex > targetIndex)
         {
             rowManager.MoveCardLeft(source);
         }
     }
 }
コード例 #11
0
 public override void ExecuteAction(CardSlot source, CardSlot target)
 {
     if (IsActionPossible(source, target))
     {
         var actionPoints = source.Card.GetComponent <ActionPointsComponent>();
         Utilities.SpawnFloatingText("Switch row", Color.grey, source.Card.transform);
         if (actionPoints != null)
         {
             actionPoints.Spend(Cost);
         }
         var targetRowManager = target.transform.parent.GetComponent <RowManager>();
         int targetIndex      = targetRowManager.GetIndexOfCard(target.Card);
         if (targetIndex == 0)
         {
             targetRowManager.AddCardToRowOnLeft(source.Card);
         }
         else
         {
             targetRowManager.AddCardToRowOnRight(source.Card);
         }
         source.transform.parent.GetComponent <RowManager>().RemoveCard(source);
     }
 }
コード例 #12
0
 private void CardSlotClicked(CardSlot cardSlot)
 {
     Assert.IsNotNull(cardSlot);
     if (inputBlockade)
     {
         return;
     }
     inputBlockade = true;
     if (SelectedCardSlot == cardSlot)
     {
         SelectedCardSlot = null;
     }
     else
     {
         if (SelectedActionIndex != NO_ACTION)
         {
             ProcessAction(cardSlot);
         }
         else
         {
             SelectedCardSlot = cardSlot;
         }
     }
 }
コード例 #13
0
 public void MoveCardToIndex(CardSlot slotWithCard, int destinationIndex)
 {
     Assert.IsTrue(currentCardSlots.Contains(slotWithCard));
     MoveCardToIndex(currentCardSlots.IndexOf(slotWithCard), destinationIndex);
 }
コード例 #14
0
 public void MoveCardRight(CardSlot slotWithCard)
 {
     Assert.IsTrue(currentCardSlots.Contains(slotWithCard));
     MoveCardRight(currentCardSlots.IndexOf(slotWithCard));
 }
コード例 #15
0
 private void OnSelectedCardDestroyed(LifecycleComponent lifecycleComponent)
 {
     SelectedCardSlot = null;
 }
コード例 #16
0
 private void OnTurnEnd()
 {
     SelectedCardSlot = null;
 }