示例#1
0
 public GameProject(String projectName, GameEnum.ProjectComplexity complexity, DateTime deadLine, Double penalty, Double reward, int timeOfReward, int[] techDuration)
 {
     this.projectName  = projectName;
     this.complexity   = complexity;
     this.deadLine     = deadLine;
     this.penalty      = penalty;
     this.reward       = reward;
     this.timeOfReward = timeOfReward;
     //technologie są niezmienne i przechowywane razem z enumami w klasie GameEnum
     for (int i = 0; i < GameEnum.technology.Length; i++)
     {
         daysForTechnology.Add(GameEnum.technology[i], techDuration[i]);
     }
 }
示例#2
0
        //Ganerator projektów
        public static GameProject GetRandomGameProject(DateTime now)
        {
            int randFirstSegmentName = rand.Next(0, PROJECT_FIRST_SEGMENT_NAME.Length);
            int randLastSegmentName  = rand.Next(0, PROJECT_LAST_SEGMENT_NAME.Length);

            //int randProjectComplexity = rand.Next(0, PROJECT_COMPLEXITY.Length);

            GameEnum.ProjectComplexity randProjectComplexity = (GameEnum.ProjectComplexity)rand.Next(0, PROJECT_COMPLEXITY.Length);

            int        minDay = 1, maxDay = 2;
            List <int> randTechTime = new List <int>();

            int[,] percentagesForTechnologyTime = { { 50, 100, 50, 0, 40, 40 }, { 100, 100, 100, 40, 70, 100 }, { 100, 100, 100, 50, 100, 100 }, };
            //{timeModyficatorTechnology,dayModyficatorDeadline} w 3 odmianach dla konkretcnych poziomów złożoności projektu}
            int[,] tableOfIntModyficator = { { 0, 16 }, { 2, 8 }, { 4, 4 }, };
            // { penaltyModyficator, rewardModyficator }
            double[,] tableOfDoubleModyficator = { { 50.00, 200.00 }, { 100.00, 400.00 }, { 150.00, 600.00 }, };

            int rowModyficator = 0; //podstawowy modyfikator dla projektów łatwych

            switch (randProjectComplexity)
            {
            case GameEnum.ProjectComplexity.Średni:
                rowModyficator = 1;
                break;

            case GameEnum.ProjectComplexity.Trudny:
                rowModyficator = 2;
                break;
            }

            //generacja czasów poszczególnych technologii procentowo z modyfikatorem
            for (int i = 0; i < 6; i++)
            {
                int randTime        = (rand.Next(minDay, maxDay + 1)) + tableOfIntModyficator[rowModyficator, 0];
                int randTimePercent = (rand.Next(1, 101));
                if (randTimePercent <= percentagesForTechnologyTime[rowModyficator, i])
                {
                    randTechTime.Add(randTime);
                }
                else
                {
                    randTechTime.Add(0);
                }
            }
            //ilość dni na projekt od dnia generacji = min czas projektu + modyfikator
            int dayDeadline = 0;

            foreach (var time in randTechTime)
            {
                dayDeadline += time;
            }
            dayDeadline += tableOfIntModyficator[rowModyficator, 1];
            int forMoney = rand.Next(6, 13);

            int[] randTechDuration = new int[randTechTime.Count];
            for (int i = 0; i < randTechTime.Count; i++)
            {
                int time = randTechTime[i];
                randTechDuration[i] = time;
            }

            return(new GameProject(PROJECT_FIRST_SEGMENT_NAME[randFirstSegmentName] + PROJECT_LAST_SEGMENT_NAME[randLastSegmentName],
                                   randProjectComplexity,
                                   now.AddDays(dayDeadline),
                                   (tableOfDoubleModyficator[rowModyficator, 0] * forMoney),
                                   (tableOfDoubleModyficator[rowModyficator, 1] * forMoney),
                                   (rand.Next(minDay, maxDay + 1)) + tableOfIntModyficator[rowModyficator, 0],
                                   randTechDuration
                                   ));
        }