コード例 #1
0
    static private CardDescription GenerateTrapCard(System.Random random, IHistogram model, ImageGlossary images, CreatureModelIndex creatureModels, NameModel nameModel, CardGenerationFlags flags)
    {
        CardDescription card = ScriptableObject.CreateInstance(typeof(CardDescription)) as CardDescription;

        card.cardType = CardType.TRAP;
        card.manaCost = (int)ProceduralUtils.GetRandomValue <ManaCost>(random, model);

        double powerBudget = PowerBudget.ManaPowerBudgets[card.manaCost];
        double powerMargin = PowerBudget.ManaPowerMargin[card.manaCost];
        double powerLimit  = PowerBudget.ManaPowerLimit[card.manaCost];

        card.cardName = "A trap card";
        //card.name += "(" + powerBudget.ToString() + ")";

        GenerateCardEffects(random, model, creatureModels, card, powerBudget, powerMargin, powerLimit);

        // Revise the mana cost based on what effects we actually did generate
        int revisedMana = PowerBudget.PowerLevelToMana(card.PowerLevel());

        if (revisedMana != card.manaCost)
        {
            Debug.Log("Had to revise the mana cost from " + card.manaCost.ToString() + " to " + revisedMana.ToString());
            card.manaCost = revisedMana;
        }
        card.image = ProceduralUtils.GetRandomTexture(random, images.GetTrapImages());

        CardTags tags = CardTagging.GetCardTags(card);

        card.cardName = nameModel.GenerateName(random, tags);

        return(card);
    }
コード例 #2
0
        private int DoSearchOldName(string keyword, int score)
        {
            string querystring = string.Format("oldName:\"{0}\"", keyword);

            CardDescription[] cards = cardLibrary.Search(querystring);
            if (cards.Length > 0)
            {
                for (int i = 0; i < cards.Length; i++)
                {
                    CardDescription  card = cards[i];
                    DictSearcherNode node = GetSearcherNodeByID(card.ID);
                    string[]         ss   = card.oldName.Split(',');
                    int len = card.oldName.Length;
                    for (int j = 0; j < ss.Length; j++)
                    {
                        if (ss[j].IndexOf(keyword) >= 0 && len > ss[j].Length)
                        {
                            len = ss[j].Length;
                        }
                    }
                    if (score - len > node.Score)
                    {
                        node.Score = score - len;
                    }
                }
            }
            return(cards.Length);
        }
コード例 #3
0
        private void Clearbtn_Click(object sender, EventArgs e)
        {
            CardID.Clear();
            Alias.Text = "0";
            CardFormats.SelectedIndex     = -1;
            SetCodeLst.SelectedIndex      = -1;
            OtherSetCodeLst.SelectedIndex = -1;
            Level.SelectedIndex           = -1;
            Race.SelectedIndex            = -1;
            CardAttribute.SelectedIndex   = -1;
            ATK.Text = "0";
            DEF.Text = "0";
            CardName.Clear();
            CardDescription.Clear();
            EffectList.Items.Clear();

            for (int i = 0; i < CardTypeList.Items.Count; i++)
            {
                CardTypeList.SetItemCheckState(i, CheckState.Unchecked);
            }
            for (int i = 0; i < CategoryList.Items.Count; i++)
            {
                CategoryList.SetItemCheckState(i, CheckState.Unchecked);
            }
            m_loadedCard  = 0;
            CardImg.Image = Resources.unknown;
            m_loadedImage = "";
        }
コード例 #4
0
ファイル: PlayerSystem.cs プロジェクト: TBlauwe/Immunocalypse
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     foreach (GameObject go in _players)
     {
         if (Input.GetKeyDown("s"))
         {
             Player playerComponent = go.GetComponent <Player>();
             string filePath        = Application.dataPath + levelsFolder + this.exportedFileName + ".json";
             string json            = JsonUtility.ToJson(new PlayerDescription(playerComponent));
             Debug.Log(json);
             File.WriteAllText(filePath, json);
         }
         else if (Input.GetKeyDown("l"))
         {
             string            path = Application.dataPath + levelsFolder + this.exportedFileName + ".json";
             PlayerDescription playerDescription = JsonUtility.FromJson <PlayerDescription>(File.ReadAllText(path));
             Player            playerComponent   = go.GetComponent <Player>();
             foreach (GameObject gameObject in playerComponent.globalDeck)
             {
                 GameObjectManager.unbind(gameObject);
                 GameObject.Destroy(gameObject);
             }
             foreach (GameObject gameObject in playerComponent.levelDeck)
             {
                 GameObjectManager.unbind(gameObject);
                 GameObject.Destroy(gameObject);
             }
             playerComponent.globalDeck.Clear();
             playerComponent.levelDeck.Clear();
             playerComponent.globalDeck = CardDescription.getGameObjects(playerDescription.globalDeck, go);
         }
     }
 }
コード例 #5
0
ファイル: CardConstants.cs プロジェクト: MX-H/AIGame-Fork
    public static CardTags GetCardTags(CardDescription cardDesc)
    {
        CardTags tags = GetCardTagsFromCardType(cardDesc.cardType);

        tags |= GetCardTagsFromManaCost(cardDesc.manaCost);
        switch (cardDesc.cardType)
        {
        case CardType.CREATURE:
            CreatureCardDescription creatureDesc = cardDesc as CreatureCardDescription;
            tags |= GetCardTagsFromCreatureType(creatureDesc.creatureType);
            foreach (KeywordAttribute keywords in creatureDesc.GetAttributes())
            {
                tags |= GetCardTagsFromKeywordAttributes(keywords);
            }

            break;

        case CardType.SPELL:
        case CardType.TRAP:
            foreach (CardEffectDescription effect in cardDesc.cardEffects)
            {
                if (effect.GetAlignment() == Alignment.POSITIVE)
                {
                    tags |= GetCardTagsFromTargetType(effect.targettingType);
                }
            }

            break;
        }
        return(tags);
    }
コード例 #6
0
        public CardDescription GetCardByShortName(string shortname)
        {
            int count = Cards.Length;

            for (int i = 0; i < count; i++)
            {
                CardDescription card = Cards[i];

                if (string.Equals(shortname, card.shortName))
                {
                    return(card);
                }

                if (card.shortName.IndexOf(shortname) >= 0)
                {
                    string[] names = card.shortName.Split(',', ',');
                    foreach (string s in names)
                    {
                        if (s.Trim() == shortname.Trim())
                        {
                            return(card);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #7
0
        public CardDescription GetCardByCheatCode(string cheatcode)
        {
            string code = cheatcode.PadLeft(8, '0');

            int count = Cards.Length;

            for (int i = 0; i < count; i++)
            {
                CardDescription card = Cards[i];
                if (card.cheatcode.Equals(code))
                {
                    return(card);
                }
            }

            for (int i = 0; i < count; i++)
            {
                CardDescription card = Cards[i];
                if (card.cheatcode.Contains(code))
                {
                    return(card);
                }
            }

            return(null);
        }
コード例 #8
0
ファイル: Baseball_Panel.cs プロジェクト: p-d-c/RecyclingGame
    // Update is called once per frame
    public void ToggleCard(Sprite cardSprite, string name, string description, Sprite contamination, string rarity, string type)
    {
        // Populate baseball card

        // Get card preview picture
        cardPicture = gameObject.transform.Find("BaseballCard/CardPicture").GetComponent <CardPicture>();
        cardPicture.m_Image.sprite = cardSprite;

        // Get card item name
        cardTitle = gameObject.transform.Find("BaseballCard/CardTitle").GetComponent <CardTitle>();
        cardTitle.m_Title.text = name;

        // Get card item description
        cardDescription = gameObject.transform.Find("BaseballCard/CardDescription").GetComponent <CardDescription>();
        cardDescription.m_Description.text = description;

        // Get card contamination
        cardContamination = gameObject.transform.Find("BaseballCard/Contamination").GetComponent <Quality_Sprite>();
        cardContamination.m_Quality.sprite = contamination;

        // Get card rarity
        cardRarity = gameObject.transform.Find("BaseballCard/Rarity").GetComponent <Quality_Sprite>();
        cardRarity.m_Quality.sprite = Resources.Load <Sprite>(rarity);

        // Get card type
        cardType = gameObject.transform.Find("BaseballCard/Type").GetComponent <Quality_Sprite>();
        cardType.m_Quality.sprite = Resources.Load <Sprite>(type);

        // Show baseball card
        ApparateCard();
    }
コード例 #9
0
        private void ShowDeckList(CardDescription[] Cards, VirtualListView listview)
        {
            ListViewItem[] resultItem = new ListViewItem[Cards.Length];
            for (int i = 0; i < Cards.Length; i++)
            {
                CardDescription card = Cards[i];

                bool largeicon = false;
                if (listViewEx1.View == View.LargeIcon)
                {
                    largeicon = true;
                }

                resultItem[i] = ListViewItemFactory.GetItemByCard(card, largeicon);
            }

            listview.BeginUpdate();
            if (listview.VirtualMode)
            {
                View v = listview.View;
                listview.View            = View.List;
                listview.VirtualListSize = Cards.Length;
                listview.View            = v;
            }
            else
            {
                listview.Items.Clear();
                listview.Items.AddRange(resultItem);
            }
            listview.EndUpdate();
        }
コード例 #10
0
        private void listViewEx1_MouseDown(object sender, MouseEventArgs e)
        {
            VirtualListView listViewEx = CurrentListView();

            if (e.Clicks == 2 && e.Button == MouseButtons.Left)
            {
                ListViewItem item = listViewEx.GetItemAt(e.X, e.Y);
                if (item == null)
                {
                    return;
                }

                int             id   = int.Parse(item.SubItems[8].Text);
                CardDescription card = CardLibrary.GetInstance().GetCardByID(id);

                if (CardDescription.isExtraCard(card))
                {
                    Global.frmDeckEditHolder.AddToFusionDeck(card.ID);
                }
                else
                {
                    Global.frmDeckEditHolder.AddToMainDeck(card.ID);
                }
            }
        }
コード例 #11
0
        protected override void FillInventory()
        {
            inventory[0, 0] = new CardDescription()
            {
                action = CardAction.Damage,
                bonus  = new Bonus()
                {
                    type = BonusType.Poison
                },
                condition = new Condition()
                {
                    type = ConditionType.Min, number = 4
                },
            };

            inventory[1, 0] = new CardDescription()
            {
                action = CardAction.Damage,
                bonus  = new Bonus()
                {
                    type = BonusType.Poison
                },
                condition = new Condition(),
            };
        }
コード例 #12
0
 void initializeALLservants()
 {
     menu = new Menu();
     servants.Add(menu);
     setting = new Setting();
     servants.Add(setting);
     selectDeck = new selectDeck();
     servants.Add(selectDeck);
     room = new Room();
     servants.Add(room);
     cardDescription = new CardDescription();
     deckManager     = new DeckManager();
     servants.Add(deckManager);
     ocgcore = new Ocgcore();
     servants.Add(ocgcore);
     selectServer = new SelectServer();
     servants.Add(selectServer);
     book = new Book();
     servants.Add(book);
     selectReplay = new selectReplay();
     servants.Add(selectReplay);
     puzzleMode = new puzzleMode();
     servants.Add(puzzleMode);
     aiRoom = new AIRoom();
     servants.Add(aiRoom);
 }
コード例 #13
0
ファイル: CardInstance.cs プロジェクト: MX-H/AIGame-Fork
 public CardInstance(PlayerController src, int seed, CardGenerationFlags flags = CardGenerationFlags.NONE)
 {
     srcPlayer = src;
     cardSeed  = seed;
     cardFlags = flags;
     baseCard  = src.cardGenerator.GenerateCard(seed, flags);
     modifiers = new List <IModifier>();
 }
コード例 #14
0
ファイル: frmDict.cs プロジェクト: Crest10086/DeckBuilder2
 public void ShowNoResult()
 {
     CurrentCard = null;
     richTextBox1.Clear();
     richTextBox1.AppendText("对不起,没有找到任何卡片!");
     richTextBox1.Visible    = true;
     panel2.Visible          = true;
     splitContainer1.Visible = false;
 }
コード例 #15
0
        private void buttonItem8_Click(object sender, EventArgs e)
        {
            if (listViewEx1.SelectedIndices == null || listViewEx1.SelectedIndices.Count == 0)
            {
                return;
            }
            CardDescription card = Cards[listViewEx1.SelectedIndices[0]];

            Global.frmDeckEditHolder.AddToTempDeck(card.ID);
        }
コード例 #16
0
ファイル: PlayerSystem.cs プロジェクト: TBlauwe/Immunocalypse
        public GameObject getObject()
        {
            string     name   = "Player" + ((int)(Random.value * 100));
            GameObject go     = new GameObject(name);
            Player     player = go.AddComponent <Player>();

            player.globalDeck = CardDescription.getGameObjects(this.globalDeck, go);
            GameObjectManager.bind(go);
            return(go);
        }
コード例 #17
0
        public CardDescription[] GetCards()
        {
            CardDescription[] cards = new CardDescription[decklist.Count];
            for (int i = 0; i < decklist.Count; i++)
            {
                Card card = (Card)decklist[i];
                cards[i] = cardLibrary.GetCardByID(card.ID);
            }

            return(cards);
        }
コード例 #18
0
        public CardDescription GetCardByEnName(string enname)
        {
            CardDescription card = GetCardByEnName(enname, Cards);

            if (card == null && AllowDIY)
            {
                card = GetCardByEnName(enname, DiyCards);
            }

            return(card);
        }
コード例 #19
0
        public bool isFull(int id)
        {
            CardDescription card  = CardLibrary.GetInstance().GetCardByID(id);
            int             limit = card.limit;
            string          s     = CLConfig.GetInstance().GetSetting("AllowForbiddenCard");

            if (string.Equals(s, "True", StringComparison.OrdinalIgnoreCase))
            {
                limit = 3;
            }
            return(GetCount(id) >= limit);
        }
コード例 #20
0
ファイル: Boss_1.cs プロジェクト: Makcal/DiceyAdventuresAR
 protected override void FillInventory()
 {
     inventory[0, 0] = new CardDescription()
     {
         action    = CardAction.Damage,
         bonus     = new Bonus(),
         condition = new Condition()
         {
             type = ConditionType.Odd
         },
     };
 }
コード例 #21
0
        private static int GetImageIndexByIndex(int index, bool largeicon)
        {
            CardDescription card = CardLibrary.GetInstance().GetCardByIndex(index);

            if (largeicon)
            {
                return(Global.largePicLoader.GetLargeIcoIndex(card.ID));
            }
            else
            {
                return(card.iCardType);
            }
        }
コード例 #22
0
        //废弃的搜索方法

        /*
         * public oldDictSearcher()
         * {
         *  cardLibrary = CardLibrary.GetInstance();
         *  CardDescription[] cards = cardLibrary.GetCards();
         *
         *  nametable = new Hashtable(cards.Length);
         *  japnametable = new Hashtable(cards.Length);
         *  ennametable = new Hashtable(cards.Length);
         *
         *  for (int i = 1; i <= cards.Length; i++)
         *  {
         *      CardDescription card = cards[i - 1];
         *      nametable.Add(card.name, card.ID);
         *      //if (card.japName != "")
         *      //    japnametable.Add(card.japName, i);
         *      //if (card.enName != "")
         *      //    ennametable.Add(card.enName, i);
         *      japnametable[card.japName] = card.ID;
         *      ennametable[card.enName] = card.ID;
         *  }
         * }
         */

        private void AddToResultList(CardDescription card)
        {
            foreach (Object o in resultlist)
            {
                CardDescription c = (CardDescription)o;
                if (c.ID == card.ID)
                {
                    return;
                }
            }

            resultlist.Add(card);
        }
コード例 #23
0
        private void buttonItem30_Click(object sender, EventArgs e)
        {
            VirtualListView listViewEx = CurrentListView();

            CardDescription[] Cards = CurrentCards();
            if (listViewEx.SelectedIndices == null || listViewEx.SelectedIndices.Count == 0)
            {
                return;
            }
            CardDescription card = Cards[listViewEx.SelectedIndices[0]];

            Global.frmDeckEditHolder.AddToTempDeck(card.ID);
        }
コード例 #24
0
        private bool SetLimit(int id, int limit)
        {
            for (int i = 0; i < Cards.Length; i++)
            {
                CardDescription card = Cards[i];
                if (card.ID == id)
                {
                    card.limit = limit;
                    return(true);
                }
            }

            return(false);
        }
コード例 #25
0
        private CardDescription GetCardByName(string name, CardDescription[] cards)
        {
            int count = cards.Length;

            for (int i = 0; i < count; i++)
            {
                CardDescription card = cards[i];
                if (string.Equals(name, card.name))
                {
                    return(card);
                }
            }

            return(null);
        }
コード例 #26
0
        public CardDescription GetCardByEnName(string enname, CardDescription[] cards)
        {
            int count = cards.Length;

            for (int i = 0; i < count; i++)
            {
                CardDescription card = cards[i];
                if (string.Equals(enname, card.enName))
                {
                    return(card);
                }
            }

            return(null);
        }
コード例 #27
0
        public CardDescription[] Search(string queryString, SortField[] sortFields)
        {
            try
            {
                if (queryString != null)
                {
                    queryString = queryString.Trim();
                }


                Query query = null;
                if (queryString == null || queryString == "")
                {
                    query = new MatchAllDocsQuery();
                }
                else
                {
                    QueryParser parser = new MultiFieldQueryParser(MyLucene.GetLuceneVersion(), new string[] { "name", "oldName", "shortName", "japName", "enName", "effect", "effectType", "cardType", "tribe", "element", "level", "atk", "def", "aliasList", "package", "infrequence" }, AnalyzerFactory.GetAnalyzer());
                    query = parser.Parse(queryString);
                }

                TopDocs docs = null;

                if (sortFields == null)
                {
                    docs = searcher.Search(query, null, searcher.MaxDoc());
                }
                else
                {
                    docs = searcher.Search(query, null, searcher.MaxDoc(), new Sort(sortFields));
                }

                ScoreDoc[] sdocs  = docs.scoreDocs;
                int        length = sdocs.Length;

                CardDescription[] cards = new CardDescription[length];
                for (int i = 0; i < length; i++)
                {
                    cards[i] = GetCardByIndex(sdocs[i].doc);
                }

                return(cards);
            }
            catch
            {
                return(new CardDescription[0]);
            }
        }
コード例 #28
0
 protected override void FillInventory()
 {
     inventory[0, 0] = new CardDescription()
     {
         action     = CardAction.Damage,
         slotsCount = true,
         bonus      = new Bonus()
         {
             type = BonusType.Fire
         },
         condition = new Condition()
         {
             type = ConditionType.Doubles
         },
     };
 }
コード例 #29
0
ファイル: PicLoader.cs プロジェクト: Crest10086/DeckBuilder2
        //根据卡片ID返回大图文件名
        public static string GetImagePath(int id)
        {
            //先随便找张卡测试一下图片是以密码名来存的,还是以狐查的序号名来存的
            bool   isCheatCodeMode = false;
            string testfilename    = "92377303.jpg";

            if (File.Exists(PicLoader.commonImagePath + testfilename) || File.Exists(PicLoader.imagePath + testfilename))
            {
                isCheatCodeMode = true;
            }

            if (isCheatCodeMode)
            {
                //如果是密码名保存的,不用尝试OCGSOFT的公用卡图目录,但要考虑多版本卡图的情况
                CardDescription card = CardLibrary.GetInstance().GetCardByID(id);

                string[] ss = card.cheatcode.Split(',');
                foreach (string s in ss)
                {
                    string filename = s.TrimStart(new char[] { '0' }) + ".jpg";
                    string path     = PicLoader.imagePath + filename;
                    if (File.Exists(path))
                    {
                        return(path);
                    }
                }
                return(null);
            }
            else
            {
                //如果是以序号名来存的,优先使用OCGSOFT的公用卡图目录
                string filename = id.ToString() + ".jpg";
                string path     = PicLoader.commonImagePath + filename;
                if (File.Exists(path))
                {
                    return(path);
                }

                path = PicLoader.imagePath + filename;
                if (File.Exists(path))
                {
                    return(path);
                }

                return(null);
            }
        }
コード例 #30
0
        private void buttonItem2_PopupOpen(object sender, DevComponents.DotNetBar.PopupOpenEventArgs e)
        {
            VirtualListView listViewEx = CurrentListView();

            CardDescription[] Cards = CurrentCards();

            if (listViewEx.SelectedIndices == null || listViewEx.SelectedIndices.Count == 0)
            {
                buttonItem28.Enabled = false;
                buttonItem29.Enabled = false;
                buttonItem30.Enabled = false;
            }
            else
            {
                CardDescription card = null;
                try
                {
                    card = Cards[listViewEx.SelectedIndices[0]];
                }
                catch
                {
                    card = null;
                }
                if (card == null)
                {
                    buttonItem6.Enabled = false;
                    buttonItem7.Enabled = false;
                    buttonItem8.Enabled = false;
                    return;
                }

                if (CardDescription.isExtraCard(card))
                {
                    buttonItem28.Text    = "至额外卡组";
                    buttonItem28.Enabled = true;
                    buttonItem29.Enabled = true;
                    buttonItem30.Enabled = true;
                }
                else
                {
                    buttonItem28.Enabled = true;
                    buttonItem29.Enabled = true;
                    buttonItem30.Enabled = true;
                }
            }
        }