Exemplo n.º 1
0
        public static void Reset(int CardCount)
        {
            SingleSelectedNode = 0;
            CurrentCards.Clear();
            TeamSelectedNodes.Clear();
            TeamFloatingSelection.Clear();
            TeamReady.Clear();

            LinkedList <string> TypeList = new LinkedList <string>();

            for (int i = 0; i < CardCount; i++)
            {
                WaveCard newCard = CardLoader.GetRandomCard(WaveManager.CurrentWave);

                int c = 0;
                while (newCard.Used && c++ < 100)
                {
                    newCard = CardLoader.GetRandomCard(WaveManager.CurrentWave);
                }
                CurrentCards.Add(newCard);
                newCard.Used = true;
                //TypeList.AddLast(newCard.Type);
            }

            foreach (int Team in FactionManager.Teams.Keys)
            {
                if (Team != WaveManager.ActiveTeam)
                {
                    TeamSelectedNodes.Add(Team, 0);
                    TeamReady.Add(Team, false);
                    TeamFloatingSelection.Add(Team, 0);
                }
            }
        }
        public override void Enter(AiStateManager Parent)
        {
            float BestScore = 1000;

            Moving    = false;
            PauseTime = 0;

            foreach (WaveCard card in OverCardPicker.CurrentCards)
            {
                float Score = 0;
                foreach (UnitBasic u in FactionManager.SortedUnits[WaveManager.ActiveTeam])
                {
                    if (u.GetType().IsSubclassOf(typeof(UnitTurret)))
                    {
                        UnitTurret t = (UnitTurret)u;
                        if (t.MyCard != null)
                        {
                            if (t.MyCard.StrongVs.Equals(card.Type))
                            {
                                Score += t.GetWeight();
                            }
                        }
                        else if (card.Type.Equals("Heavy"))
                        {
                            Score += t.GetWeight();
                        }
                    }
                }

                if (Score < BestScore)
                {
                    SelectedCard = card;
                    BestScore    = Score;
                }
            }

            base.Enter(Parent);
        }
Exemplo n.º 3
0
        private static void AddCards(LinkedList <string> SourcesFiles)
        {
            StringBuilder stringBuilder = new StringBuilder();
            ProcessStep   processStep   = ProcessStep.Level;
            WaveCard      newCard       = new WaveCard();
            string        UnitName      = "";
            int           UnitCount     = 0;
            float         UnitLevel     = 0;

            foreach (string SourceFile in SourcesFiles)
            {
                foreach (char c in SourceFile)
                {
                    if (c == ';' || c == ',' || c == '!')
                    {
                        switch (processStep)
                        {
                        case ProcessStep.Level:
                            string s = stringBuilder.ToString();
                            newCard.Level = int.Parse(s);
                            processStep   = ProcessStep.MinDiff;
                            break;

                        case ProcessStep.MinDiff:
                            newCard.MinDiff = int.Parse(stringBuilder.ToString());
                            processStep     = ProcessStep.MaxDiff;
                            break;

                        case ProcessStep.MaxDiff:
                            newCard.MaxDiff = int.Parse(stringBuilder.ToString());
                            processStep     = ProcessStep.EnergyCost;
                            break;

                        case ProcessStep.EnergyCost:
                            newCard.EnergyCost = int.Parse(stringBuilder.ToString());
                            processStep        = ProcessStep.Name;
                            break;

                        case ProcessStep.Name:
                            newCard.Name = stringBuilder.ToString();
                            processStep  = ProcessStep.Type;
                            break;

                        case ProcessStep.Type:
                            newCard.SetType(stringBuilder.ToString());
                            processStep = ProcessStep.Description;
                            break;

                        case ProcessStep.Description:
                            newCard.Description = stringBuilder.ToString();
                            processStep         = ProcessStep.Special;
                            break;

                        case ProcessStep.Special:
                            newCard.AddSpecial(stringBuilder.ToString());
                            processStep = c == ',' ? ProcessStep.Special : ProcessStep.PathName;
                            break;

                        case ProcessStep.PathName:
                            newCard.SetImagePath(stringBuilder.ToString());
                            processStep = ProcessStep.UName;
                            break;

                        case ProcessStep.UName:
                            UnitName    = stringBuilder.ToString();
                            processStep = ProcessStep.UCount;
                            break;

                        case ProcessStep.UCount:
                            UnitCount   = int.Parse(stringBuilder.ToString());
                            processStep = ProcessStep.ULevel;
                            break;

                        case ProcessStep.ULevel:
                            UnitLevel = int.Parse(stringBuilder.ToString());
                            newCard.AddUnit(new WaveUnit(FactionCard.GetFactionUnitCard(UnitName), UnitCount, UnitLevel));
                            if (c == ';')
                            {
                                processStep = ProcessStep.UName;
                            }
                            else
                            {
                                processStep = ProcessStep.Level;
                                if (!SortedCardLists.ContainsKey(newCard.Level - 1))
                                {
                                    SortedCardLists.Add(newCard.Level - 1, new List <WaveCard>());
                                }
                                SortedCardLists[newCard.Level - 1].Add(newCard);
                                newCard       = new WaveCard();
                                newCard.Super = FactionCard.SuperMode;
                            }
                            break;
                        }
                        stringBuilder = new StringBuilder();
                    }
                    else if (c != ' ' && c != '\n' && c != '\r')
                    {
                        stringBuilder.Append(c);
                    }
                }
            }
        }