public void Teardown()
 {
     Object.DestroyImmediate(unitWithoutCard.gameObject);
     Object.DestroyImmediate(unit1.gameObject);
     Object.DestroyImmediate(unit2.gameObject);
     cardUnit = null;
 }
예제 #2
0
 public void InitCard(CardUnit unit, Hand ownerHand, Player owner)
 {
     portrait.sprite = unit.portrait;
     this.owner      = owner;
     this.ownerHand  = ownerHand;
     this.unit       = unit;
 }
 private void UnitDataAvailableHandler(CardUnit unit)
 {
     nameText.SetText(unit.cardName);
     troopCountText.SetText("Troops: " + unit.baseTroopCount.ToString());
     statsText.SetText("Attack: " + unit.baseAttack.ToString() + ", Speed: " + unit.baseSpeed.ToString() + ", Cost: " + unit.deployCost);
     descriptionText.SetText(unit.description);
 }
예제 #4
0
 private void EnableDeployMode(CardUnit unit)
 {
     if (parentController.GetCurrentPhase() == Phase.PREP)
     {
         SetSubPhase(SubPhase.DEPLOYMENT);
     }
 }
예제 #5
0
    // Removes the top card of the active deck
    public CardUnit Pop()
    {
        CardUnit unitCard = deckClone[deckClone.Count - 1];

        deckClone.RemoveAt(deckClone.Count - 1);
        return(unitCard);
    }
예제 #6
0
 /*
  * Applies the data from a card onto the zone.
  * A card in hand can be deployed onto a zone during the deployment subphase
  */
 public void SetZoneData(Card cardData)
 {
     zoneData         = (CardUnit)cardData;
     troopCount.text  = zoneData.baseTroopCount.ToString();
     portrait.sprite  = zoneData.portrait;
     classIcon.sprite = zoneData.getUnitRoleIcon();
 }
예제 #7
0
 public void Setup()
 {
     player       = PlayerUTests.CreateTestPlayer();
     cardUnit     = CardUnitUTests.CreateTestCardUnit();
     cardBuilding = CardBuildingUTests.CreateTestCardBuilding();
     cardResource = CardResourceUTests.CreateTestFoodCardResource();
 }
 public void Setup()
 {
     unitWithoutCard = UnitUTests.CreateTestUnit();
     unit1           = CreateTestUnitWithCard();
     unit2           = CreateTestUnitWithCard();
     cardUnit        = CardUnitUTests.CreateTestCardUnit();
 }
예제 #9
0
 public void Teardown()
 {
     cardUnit     = null;
     cardBuilding = null;
     cardResource = null;
     C.Destroy(player.gameObject);
 }
예제 #10
0
        public void LoadsTestCardUnit()
        {
            CardUnit newCard = LoadTestUnitCard();

            Assert.IsNotNull(newCard);
            Assert.AreEqual(newCard.cardName, "Wizard");
            Assert.AreEqual(newCard.speed, 2);
        }
예제 #11
0
        // Create test card unit
        public static CardUnitDisplay CreateTestCardUnitDisplay()
        {
            CardUnit        cardUnit        = CardUnitUTests.CreateTestCardUnit();
            CardUnitDisplay cardUnitDisplay = CardUnitDisplayUTests.CreateTestCardUnitDisplay();

            cardUnitDisplay.SetCard(cardUnit);
            return(cardUnitDisplay);
        }
        // Create test unit with card
        public static Unit CreateTestUnitWithCard()
        {
            CardUnit cardUnit = CardUnitUTests.CreateTestCardUnit();
            Unit     unit     = UnitUTests.CreateTestUnit();

            unit.SetCard(cardUnit);
            return(unit);
        }
예제 #13
0
 // Set card
 public override void SetCard(Card card)
 {
     if (card is CardUnit)
     {
         CardUnit cardUnit = (CardUnit)card;
         this.cardUnit = cardUnit;
         Initialize();
     }
 }
예제 #14
0
 // Set card
 public override void SetCard(CardPiece cardPiece)
 {
     if (cardPiece is CardUnit)
     {
         CardUnit cardUnit = (CardUnit)cardPiece;
         this.cardUnit = cardUnit;
         pieceType     = PieceType.Unit;
         SetCardStats();
     }
 }
예제 #15
0
 public void Setup()
 {
     player    = PlayerUTests.CreateTestPlayer();
     cardUnit1 = CardUnitUTests.CreateTestCardUnit();
     cardUnit2 = CardUnitUTests.CreateTestCardUnit();
     player.DrawCard(cardUnit1);
     cardUnitDisplay1 = player.cardPieceDisplays[0];
     Sprite[] cardBackgrounds = Resources.LoadAll <Sprite>("Art/Cards/Card Backgrounds");
     playableBorder    = cardBackgrounds[1];
     unplayableBorder  = Resources.Load <Sprite>(ENV.CARD_UNPLAYABLE_BORDER_RESOURCE_PATH);
     highlightedBorder = Resources.Load <Sprite>(ENV.CARD_HIGHLIGHTED_BORDER_RESOURCE_PATH);
 }
예제 #16
0
        /**
         *
         */
        public void CreateNewContext(CardUnit unit, Vector3 pos)
        {
            ClearOptionPrompt();

            ContextButton newButton = Instantiate(button, transform.position, transform.rotation, transform);

            newButton.SetOption(new DeployOption(unit));
            //optionList.Add(newButton);

            pos.z = 0;
            GetComponent <RectTransform>().localPosition = pos;
        }
예제 #17
0
    /*
     * Shuffles a deck based on the Fisher-Yates algorithm
     */
    public void Shuffle()
    {
        int length = deckClone.Count;

        for (int i = length; i > 1; i--)
        {
            int randomIdx = Random.Range(0, i);

            CardUnit unit = deckClone[randomIdx];
            deckClone[randomIdx] = deckClone[i - 1];
            deckClone[i - 1]     = unit;
        }
    }
예제 #18
0
 /**
  * Function is dependent on the panel area parent having bottom left pivot and position for local position to correctly calculate
  */
 private void DisplayOptionPrompt(CardUnit unit, Vector3 pos)
 {
     /*
      * ClearOptionPrompt();
      *
      * ContextButton newButton = Instantiate(button, transform.position, transform.rotation, transform);
      * newButton.SetOption(new DeployOption(unit));
      * optionList.Add(newButton);
      *
      * pos.z = 0;
      * GetComponent<RectTransform>().localPosition = pos;
      */
 }
    // Start is called before the first frame update
    void Start()
    {
        // Create unit
        unitPrefab = Instantiate(unitPrefab);
        unit       = unitPrefab.GetComponent <Unit>();
        cardUnit   = CardUnit.LoadTestCardUnit();
        unit.SetCard(cardUnit);

        // Create building
        buildingPrefab = Instantiate(buildingPrefab);
        building       = buildingPrefab.GetComponent <Building>();
        cardBuilding   = CardBuilding.LoadTestCardBuilding();
        building.SetCard(cardBuilding);
    }
예제 #20
0
        private void LoadContent()
        {
            IEnumerable <Card> cards;

            var cardsList = numberDBLevel.DbLevelRecord.Cards.ToList();

            cardsList = new ListShuffle <Card>().Shuffle(cardsList);

            for (int i = 0; i < cardsList.Count; i++)
            {
                CardUnit c = new CardUnit(this, cardsList[i], Settings.GetInstance().CardSize);
                UnitsCol.AddUnit(c);
            }
        }
예제 #21
0
    public void ShowParty(List <MasterUnitParam> _masterList, List <DataUnitParam> _list)
    {
        foreach (DataUnitParam param in _list)
        {
            GameObject obj = Instantiate(m_prefPartyCard, m_goRootPartyCard.transform);
            obj.SetActive(true);
            CardUnit card = obj.GetComponent <CardUnit>();

            MasterUnitParam master = _masterList.Find(p => p.unit_id == param.unit_id);

            card.Initialize(param, master);
            card.SetPosition();
            cardUnitList.Add(card);
        }
    }
예제 #22
0
 void OnMouseDown()
 {
     //If current sub-phase is in DEPLOYMENT
     if (subPhase == SubPhase.DEPLOYMENT)
     {
         //Alert that a focused card has been played, so it can be removed
         GameEvents.instance.CardInHandPlayed();
         SetZoneData(pendingUnitData);
         GameEvents.instance.UnitDeployed(zoneData);
         pendingUnitData = null;
     }
     else
     {
         Debug.Log("Test Click on Deployed Card");
     }
     //StartCoroutine(OnDoubleClick());
 }
예제 #23
0
 private void InstanceLoadAllCard()//创建所有牌
 {
     for (int i = 0; i < (int)mjCards.tiao_Num; i++)
     {
         int initionalNum = 0;
         if ((mjCards)i == mjCards.Nodefine)
         {
             initionalNum = 108;
         }
         else
         {
             initionalNum = 4;
         }
         CardUnit cardUnit = new CardUnit();
         cardUnit.initial(CardsType[i], (mjCards)i, initionalNum);
         Cardunits[i] = cardUnit;
     }
 }
예제 #24
0
    // Load test card unit
    public static CardUnit LoadTestCardUnit()
    {
        CardUnit newCard = Resources.Load <CardUnit>(ENV.CARD_UNIT_TEST_RESOURCE_PATH);

        return(newCard);
    }
예제 #25
0
        private void AddTypeProperties(CardTypes cardType)
        {
            card.CardTypeId = cardType;

            switch (cardType)
            {
            case CardTypes.Unit:
                var cardUnit = new CardUnit();
                if (card.Units.Any())
                {
                    cardUnit = card.Units.FirstOrDefault();
                }
                else
                {
                    card.Units.Add(cardUnit);
                }

                cardUnit.Attack    = GetStat(txtAttack);
                cardUnit.Health    = GetStat(txtHealth);
                cardUnit.Range     = GetStat(txtRange);
                cardUnit.Speed     = GetStat(txtSpeed);
                cardUnit.Protected = GetStat(txtProtected);
                cardUnit.Empowered = GetStat(txtEmpowered);
                cardUnit.UnitTag   = txtUnitTag.Text;

                var abilityIds = lstAbilities.Items.Cast <SelectListItem>().Select(x => x.Id).ToList();
                foreach (var abilityId in abilityIds)
                {
                    var ability = _context.Abilities.FirstOrDefault(x => x.Id == abilityId);
                    ability.Card = cardUnit;
                    cardUnit.Abilities.Add(ability);
                }

                var keywordIds = lstKeywords.Items.Cast <SelectListItem>().Select(x => x.Id).ToList();
                foreach (var keywordId in keywordIds)
                {
                    var unitKeyword = Id.HasValue ? cardUnit.UnitKeywords.SingleOrDefault(x => x.KeywordId == (Keywords)keywordId) : null;
                    if (unitKeyword == null)
                    {
                        _context.UnitKeywords.Add(new UnitKeyword {
                            CardUnit = cardUnit, KeywordId = (Keywords)keywordId
                        });
                    }
                }
                if (Id.HasValue)
                {
                    //var cardTags = _context.CardTags.Where(x => x.CardId == Id.Value && !cardTagIDs.Contains(x.TagId));
                    var unitKeywords = cardUnit.UnitKeywords.Where(x => !keywordIds.Contains((int)x.KeywordId));
                    _context.UnitKeywords.RemoveRange(unitKeywords);
                }

                break;

            case CardTypes.Spell:
                var cardSpell = new CardSpell();
                if (card.Spells.Any())
                {
                    cardSpell = card.Spells.FirstOrDefault();
                }
                else
                {
                    card.Spells.Add(cardSpell);
                }

                cardSpell.Range     = GetStat(txtSpellRange);
                cardSpell.SpellType = txtSpellType.Text;

                break;

            case CardTypes.Item:
                var cardItem = new CardItem();
                if (card.Items.Any())
                {
                    cardItem = card.Items.FirstOrDefault();
                }
                else
                {
                    card.Items.Add(cardItem);
                }

                cardItem.Durability = GetStat(txtDurability);
                cardItem.ItemTag    = txtItemTag.Text;

                break;

            default:
            case CardTypes.Default:
                break;
            }
        }
예제 #26
0
    // 유닛카드 초기화
    private void initUnit(CardUnit card)
    {
        cardSupporterList = new List<CardSupporter>();
        conditionList = new List<Modifier>();
        abilityList = new List<Ability>();
        stat = new Dictionary<string, int>();
        record = new Dictionary<string, int>();

        stat.Add("shield", 0);
        stat.Add("attackAvailableCount", 1);
        stat.Add("moveAvailableCount", 1);

        stat.Add("healthRegen", card.healthRegen);
        stat.Add("manaRegen", card.manaRegen);
        stat.Add("attack", card.attack);
        stat.Add("defense", card.defense);
        stat.Add("spell", card.spell);
        stat.Add("mobility", card.mobility);
        stat.Add("range",card.range);
        stat.Add("healthMax", card.health);
        stat.Add("healthCurrent", card.health);
        stat.Add("manaMax", card.mana);
        stat.Add("manaCurrent", card.mana);
        stat.Add("type", card.type);
        stat.Add("species", card.species);
        record.Add("moveCount",0);
        record.Add("moveAmount",0);
        record.Add("attackCount",0);
        record.Add("attackAmount",0);
        record.Add("spellCount",0);
        record.Add("damagedCount",0);
        record.Add("damagedAmount",0);

        cardName = card.cardName;
        cardID = card.cardID;
        description = card.description;
        cardTexture = card.cardTexture;

        abilityList = card.abilityList;

        Debug.Log(card.abilityList[0]);
    }
 public void Teardown()
 {
     cardUnit = null;
 }
예제 #28
0
 public DeployOption(CardUnit unit)
 {
     unitToDeploy = unit;
 }
예제 #29
0
 public void DeployModeRequested(CardUnit unit)
 {
     onDeployModeRequested?.Invoke(unit);
 }
예제 #30
0
 public void UnitDeployed(CardUnit unit)
 {
     onUnitDeployed?.Invoke(unit);
 }
예제 #31
0
 private void SetPendingUnitData(CardUnit unit)
 {
     pendingUnitData = unit;
 }