コード例 #1
0
 public Quest(QuestGoalType goal, int typeId, int goalNum, int rewardCoins)
 {
     GoalType    = goal;
     TypeId      = typeId;
     GoalNumber  = goalNum;
     RewardCoins = rewardCoins;
 }
コード例 #2
0
        public static Quest Random(User user)
        {
            QuestGoalType goalType   = Enum.GetValues(typeof(QuestGoalType)).Cast <QuestGoalType>().ToList().Random();
            int           numGoal    = 0;
            int           coinReward = 0;
            int           typeId     = 0;

            switch (goalType)
            {
            case QuestGoalType.BeatLevels:
                numGoal    = Utilities.Rand.Next(LEVELCOMPLETE_MIN, LEVELCOMPLETE_MAX + 1);
                coinReward = (int)(numGoal * LEVELCOMPLETE_COINS);
                break;

            case QuestGoalType.BuyMaterials:
                numGoal = Utilities.Rand.Next(BUYMATERIAL_MIN / GOAL_NUM_FACTOR,
                                              BUYMATERIAL_MAX / GOAL_NUM_FACTOR + 1) * GOAL_NUM_FACTOR;
                coinReward = (int)(numGoal * MATERIALBUY_COINS);
                int materials = Enum.GetValues(typeof(Material)).Cast <Material>().Count();
                typeId = Utilities.Rand.Next(0, materials);
                break;

            case QuestGoalType.CraftProjectiles:
                numGoal = Utilities.Rand.Next(PROJCRAFT_MIN / GOAL_NUM_FACTOR,
                                              PROJCRAFT_MAX / GOAL_NUM_FACTOR + 1) * GOAL_NUM_FACTOR;
                coinReward = (int)(numGoal * PROJCRAFT_COINS);
                List <ProjectileType> allProjectiles = GameInfo.ProjectilesAllowed;
                ProjectileType        type           = allProjectiles
                                                       .Where(x => GameInfo.CanSee(user, x))
                                                       .ToList()
                                                       .Exclude(ProjectileType.None)
                                                       .Random();
                typeId = Utilities.Rand.Next(0, allProjectiles.IndexOf(type));
                break;

            case QuestGoalType.FireProjectiles:
                numGoal = Utilities.Rand.Next(PROJFIRE_MIN / GOAL_NUM_FACTOR,
                                              PROJFIRE_MAX / GOAL_NUM_FACTOR + 1) * GOAL_NUM_FACTOR;
                coinReward     = (int)(numGoal * PROJFIRE_COINS);
                allProjectiles = GameInfo.ProjectilesAllowed;
                type           = allProjectiles
                                 .Where(x => GameInfo.CanSee(user, x))
                                 .ToList()
                                 .Exclude(ProjectileType.None)
                                 .Random();
                typeId = Utilities.Rand.Next(0, allProjectiles.IndexOf(type));
                break;

            case QuestGoalType.KillAliens:
                numGoal = Utilities.Rand.Next(ALIENKILL_MIN / GOAL_NUM_FACTOR,
                                              ALIENKILL_MAX / GOAL_NUM_FACTOR + 1) * GOAL_NUM_FACTOR;
                coinReward = (int)(numGoal * ALIENKILL_COINS);
                List <BasicAlienTypes> allAliens = Enum.GetValues(typeof(BasicAlienTypes)).Cast <BasicAlienTypes>().ToList();
                BasicAlienTypes        alienType = allAliens
                                                   .Where(x => GameInfo.CanSee(user, x))
                                                   .ToList()
                                                   .Exclude(BasicAlienTypes.Boss)
                                                   .Random();
                typeId = Utilities.Rand.Next(0, allAliens.IndexOf(alienType));
                break;

            case QuestGoalType.ObtainCoins:
                numGoal = Utilities.Rand.Next(COINGET_MIN / GOAL_NUM_FACTOR,
                                              COINGET_MAX / GOAL_NUM_FACTOR + 1) * GOAL_NUM_FACTOR;
                coinReward = (int)(numGoal * COINGET_COINS);
                break;

            case QuestGoalType.SpendCoins:
                numGoal = Utilities.Rand.Next(COINSPEND_MIN / GOAL_NUM_FACTOR,
                                              COINSPEND_MAX / GOAL_NUM_FACTOR + 1) * GOAL_NUM_FACTOR;
                coinReward = (int)(numGoal * COINSPEND_COINS);
                break;
            }
            return(new Quest(goalType, typeId, numGoal, coinReward));
        }