Beispiel #1
0
    public void CheckQuestConditions()
    {
        ColonyController colony = GameMaster.realMaster.colonyController;

        switch (type)
        {
        case QuestType.Progress:
            switch ((ProgressQuestID)subIndex)
            {
            case ProgressQuestID.Progress_HousesToMax:
            {
                float hl  = colony.housingLevel;
                byte  hql = colony.hq.level;
                if (hql > ColonyController.MAX_HOUSING_LEVEL)
                {
                    hql = ColonyController.MAX_HOUSING_LEVEL;
                }
                stepsAddInfo[0] = string.Format("{0:0.##}", hl) + '/' + hql.ToString();
                if (hl >= hql)
                {
                    MakeQuestCompleted();
                }
            }
            break;

            case ProgressQuestID.Progress_2Docks:
                stepsAddInfo[0] = colony.docks.Count.ToString() + "/2";
                if (colony.docks.Count >= 2)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_2Storages:
                stepsAddInfo[0] = (colony.storage.warehouses.Count - 1).ToString() + "/2";
                if (colony.storage.warehouses.Count >= 3)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_Tier2:
                if (colony.hq.level >= 2)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_300Population:
                stepsAddInfo[0] = colony.citizenCount.ToString() + "/300";
                if (colony.citizenCount >= 300)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_OreRefiner:
            {
                List <Building> powerGrid = colony.powerGrid;
                foreach (Building b in powerGrid)
                {
                    if (b == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (b.ID == Structure.ORE_ENRICHER_2_ID)
                        {
                            MakeQuestCompleted();
                            break;
                        }
                    }
                }
            }
            break;

            case ProgressQuestID.Progress_HospitalCoverage:
                stepsAddInfo[0] = string.Format("{0:0.###}", colony.hospitals_coefficient) + " / 1";
                if (colony.hospitals_coefficient >= 1)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_Tier3:
                if (colony.hq.level >= 3)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_4MiniReactors:
            {
                List <Building> powerGrid = colony.powerGrid;
                byte            mrc       = 0;
                foreach (Building b in powerGrid)
                {
                    if (b == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (b.ID == Structure.MINI_GRPH_REACTOR_3_ID)
                        {
                            mrc++;
                        }
                    }
                }
                stepsAddInfo[0] = mrc.ToString() + "/4";
                if (mrc >= 4)
                {
                    MakeQuestCompleted();
                }
            }
            break;

            case ProgressQuestID.Progress_100Fuel:
            {
                int f = (int)colony.storage.standartResources[ResourceType.FUEL_ID];
                stepsAddInfo[0] = f.ToString() + "/100";
                if (f >= 100)
                {
                    MakeQuestCompleted();
                }
            }
            break;

            case ProgressQuestID.Progress_XStation:
                if (XStation.current != null)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_Tier4:
                if (colony.hq.level >= 4)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_CoveredFarm:
            {
                List <Building> powerGrid = colony.powerGrid;
                foreach (Building b in powerGrid)
                {
                    if (b == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (b.ID == Structure.COVERED_FARM | b.ID == Structure.FARM_BLOCK_ID)
                        {
                            MakeQuestCompleted();
                            break;
                        }
                    }
                }
            }
            break;

            case ProgressQuestID.Progress_CoveredLumbermill:
            {
                List <Building> powerGrid = colony.powerGrid;
                foreach (Building b in powerGrid)
                {
                    if (b == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (b.ID == Structure.COVERED_LUMBERMILL | b.ID == Structure.LUMBERMILL_BLOCK_ID)
                        {
                            MakeQuestCompleted();
                            break;
                        }
                    }
                }
            }
            break;

            case ProgressQuestID.Progress_Reactor:
            {
                List <Building> powerGrid = colony.powerGrid;
                foreach (Building b in powerGrid)
                {
                    if (b == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (b.ID == Structure.GRPH_REACTOR_4_ID)
                        {
                            MakeQuestCompleted();
                            break;
                        }
                    }
                }
            }
            break;

            case ProgressQuestID.Progress_FirstExpedition:
            {
                byte completeness = 0;
                int  count        = Crew.crewsList.Count;
                if (count > 0)
                {
                    completeness++;
                    stepsFinished[0] = true;
                    stepsAddInfo[0]  = count.ToString() + "/1";
                }
                else
                {
                    stepsFinished[0] = false;
                    stepsAddInfo[0]  = "0/1";
                }
                // shuttles
                count = Hangar.GetTotalShuttlesCount();
                if (count > 0)
                {
                    completeness++;
                    stepsFinished[1] = true;
                    stepsAddInfo[1]  = count.ToString() + "/1";
                }
                else
                {
                    stepsFinished[1] = false;
                    stepsAddInfo[1]  = "0/1";
                }
                //observatory
                if (Observatory.alreadyBuilt)
                {
                    completeness++;
                    stepsFinished[2] = true;
                }
                else
                {
                    stepsFinished[2] = false;
                }
                //transmitter\
                count = QuantumTransmitter.transmittersList.Count;
                if (count > 0)
                {
                    completeness++;
                    stepsFinished[3] = true;
                    stepsAddInfo[1]  = count.ToString() + "/1";
                }
                else
                {
                    stepsFinished[3] = false;
                    stepsAddInfo[1]  = "0/1";
                }
                // expeditions
                if (Expedition.expeditionsLaunched > 0)
                {
                    completeness++;
                    stepsFinished[4] = true;
                    stepsAddInfo[4]  = Expedition.expeditionsLaunched.ToString() + "/1";
                }
                else
                {
                    stepsFinished[4] = false;
                    stepsAddInfo[4]  = "0/1";
                }
                // expeditions completed
                if (Expedition.expeditionsSucceed >= 1)
                {
                    completeness++;
                    stepsAddInfo[5]  = Expedition.expeditionsSucceed.ToString() + "/1";
                    stepsFinished[5] = true;
                }
                else
                {
                    stepsAddInfo[5]  = "0/1";
                    stepsFinished[5] = false;
                }
                if (completeness == 6)
                {
                    MakeQuestCompleted();
                }
            }
            break;

            case ProgressQuestID.Progress_Tier5:
                if (colony.hq.level >= 5)
                {
                    MakeQuestCompleted();
                }
                break;

            case ProgressQuestID.Progress_FactoryComplex:
            {
                List <Building> powerGrid = colony.powerGrid;
                List <ChunkPos> blocksPositions = new List <ChunkPos>(), factoriesPositions = new List <ChunkPos>();
                foreach (Building b in powerGrid)
                {
                    if (b == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (b.ID == Structure.SMELTERY_BLOCK_ID)
                        {
                            blocksPositions.Add(b.GetBlockPosition());
                        }
                        else
                        {
                            if (b.ID == Structure.SMELTERY_3_ID | b.ID == Structure.SMELTERY_2_ID | b.ID == Structure.SMELTERY_1_ID)
                            {
                                factoriesPositions.Add(b.GetBlockPosition());
                            }
                        }
                    }
                }
                if (blocksPositions.Count != 0 & factoriesPositions.Count != 0)
                {
                    bool founded = false;
                    foreach (ChunkPos cpos in blocksPositions)
                    {
                        foreach (ChunkPos uppos in factoriesPositions)
                        {
                            if (uppos.x == cpos.x && uppos.y == cpos.y + 1 && uppos.z == cpos.z + 1)
                            {
                                MakeQuestCompleted();
                                founded = true;
                                break;
                            }
                            if (founded)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            break;

            case ProgressQuestID.Progress_SecondFloor:
            {
                /*
                 * List<ChunkPos> checkForBuildings = new List<ChunkPos>();
                 * var slist = GameMaster.realMaster.mainChunk.GetSurfacesList();
                 * foreach (Plane sb in slist)
                 * {
                 *  if (sb == null || sb.noEmptySpace == false) continue;
                 *  {
                 *      foreach (Structure s in sb.structures)
                 *      {
                 *          if (!s.isBasement) continue;
                 *          if (s.ID == Structure.COLUMN_ID)
                 *          {
                 *              if (sb.pos.y < Chunk.CHUNK_SIZE) checkForBuildings.Add(new ChunkPos(sb.pos.x, sb.pos.y + 1, sb.pos.z));
                 *          }
                 *      }
                 *  }
                 * }
                 * if (checkForBuildings.Count > 0)
                 * {
                 *  Chunk ch = GameMaster.realMaster.mainChunk;
                 *  foreach (ChunkPos cpos in checkForBuildings)
                 *  {
                 *      Block b = ch.GetBlock(cpos);
                 *      if (b == null) continue;
                 *      else
                 *      {
                 *          Plane sb = b as Plane;
                 *          if (sb == null) continue;
                 *          else
                 *          {
                 *              if (sb.noEmptySpace != false & sb.artificialStructures > 0)
                 *              {
                 *                  MakeQuestCompleted();
                 *                  break;
                 *              }
                 *          }
                 *      }
                 *  }
                 *  stepsFinished[0] = true;
                 * }
                 * else stepsFinished[0] = false;
                 */
            }
            break;

            case ProgressQuestID.Progress_FoodStocks:
            {
                var f   = colony.storage.standartResources[ResourceType.FOOD_ID];
                var fmc = colony.foodMonthConsumption;
                stepsAddInfo[0] = ((int)f).ToString() + '/' + ((int)fmc).ToString();
                if (f >= fmc)
                {
                    MakeQuestCompleted();
                }
                break;
            }
            }
            break;

        case QuestType.Endgame:
            switch ((EndgameQuestID)subIndex)
            {
            case EndgameQuestID.Endgame_TransportHub_step1:
            {
                byte conditionsMet = 0;

                int docksNeeded = 4;
                int docksCount  = colony.docks.Count;
                if (docksCount >= docksNeeded)
                {
                    stepsFinished[0] = true;
                    conditionsMet++;
                }
                else
                {
                    stepsFinished[0] = false;
                }
                stepsAddInfo[0] = docksCount.ToString() + " / " + docksNeeded.ToString();

                if (colony.docksLevel >= 3)
                {
                    stepsFinished[1] = true;
                    conditionsMet++;
                }
                else
                {
                    stepsFinished[1] = false;
                }

                int storagesNeeded = 2;
                int storagesCount  = 0;
                foreach (StorageHouse sh in colony.storage.warehouses)
                {
                    if (sh.level == 5)
                    {
                        storagesCount++;
                    }
                }
                if (storagesCount >= storagesNeeded)
                {
                    stepsFinished[2] = true;
                    conditionsMet++;
                }
                else
                {
                    stepsFinished[2] = false;
                }
                stepsAddInfo[2] = storagesCount.ToString() + " / " + storagesNeeded.ToString();

                if (conditionsMet == 3)
                {
                    MakeQuestCompleted();
                }
            }
            break;

            case EndgameQuestID.Endgame_TransportHub_step2:
            {
                byte conditionsMet = 0;
                //if (ControlCenter.current != null)
                {
                    stepsFinished[0] = true;
                    conditionsMet++;
                }
                // else stepsFinished[0] = false;

                if (ConnectTower.current != null)
                {
                    stepsFinished[1] = true;
                    conditionsMet++;
                }
                else
                {
                    stepsFinished[1] = false;
                }
                if (conditionsMet == 2)
                {
                    MakeQuestCompleted();
                }
                break;
            }

            case EndgameQuestID.Endgame_TransportHub_step3:
            {
                byte conditionsMet = 0;
                foreach (Building b in colony.powerGrid)
                {
                    if (b.ID == Structure.REACTOR_BLOCK_5_ID)
                    {
                        stepsFinished[0] = true;
                        conditionsMet++;
                        break;
                    }
                }
                if (conditionsMet == 0)
                {
                    stepsFinished[0] = false;
                }

                byte housingMastsNeeded = 5, housingMastsCount = 0;
                bool hotelFound = false;
                foreach (Building b in colony.houses)
                {
                    if (b.ID == Structure.HOUSING_MAST_6_ID)
                    {
                        housingMastsCount++;                                                  // можно запихнуть и в проверку выше
                    }
                    else
                    {
                        if (b.ID == Structure.HOTEL_BLOCK_6_ID)
                        {
                            hotelFound = true;
                        }
                    }
                }
                if (housingMastsCount >= housingMastsNeeded)
                {
                    stepsFinished[1] = true;
                    conditionsMet++;
                }
                else
                {
                    stepsFinished[1] = false;
                }
                stepsAddInfo[1]  = housingMastsCount.ToString() + " / " + housingMastsNeeded.ToString();
                stepsFinished[2] = hotelFound;
                if (conditionsMet == 2 & hotelFound)
                {
                    MakeQuestCompleted();
                    GameMaster.realMaster.GameOver(GameEndingType.FoundationRoute);
                }
            }
            break;

            case EndgameQuestID.FoundationEnd:
            {
                int a = colony.citizenCount, b = Knowledge.R_F_QUEST_POPULATION_COND;
                steps[0] = "Текущее население: " + a.ToString() + " / " + b.ToString();
                if (a == b)
                {
                    MakeQuestCompleted();
                    GameMaster.realMaster.GameOver(GameEndingType.FoundationRoute);
                }
                break;
            }
            }
            break;

        case QuestType.Foundation:
            switch ((Knowledge.FoundationRouteBoosters)subIndex)
            {
            case Knowledge.FoundationRouteBoosters.HappinessBoost:
                steps[0] = "Уровень довольства: " + string.Format("{0:0.##}", colony.happiness_coefficient * 100) + '%'
                           + " / " + string.Format("{0:0.##}", Knowledge.R_F_HAPPINESS_COND * 100) + '%';
                break;

            case Knowledge.FoundationRouteBoosters.ImmigrantsBoost:
                steps[0] = "Количество прибывших: " + DockSystem.GetImmigrantsTotalCount().ToString() + " / " + Knowledge.R_F_IMMIGRANTS_CONDITION.ToString();
                break;

            case Knowledge.FoundationRouteBoosters.PopulationBoost:
                steps[0] = "Текущее население: " + colony.citizenCount.ToString() + " / " + Knowledge.R_F_POPULATION_COND.ToString();
                break;
            }
            break;
        }
    }