Esempio n. 1
0
 public static void SaveRecruitmentCamps(List <RecruitmentCamp> camps)
 {
     recruitmentCamps = new List <SavedCamp>();
     for (int i = 0; i < camps.Count; i++)
     {
         SavedCamp camp = new SavedCamp {
             gamePosition = camps[i].gamePosition,
             max          = camps[i].max,
             current      = camps[i].current
         };
         recruitmentCamps.Add(camp);
     }
 }
Esempio n. 2
0
    void Start()
    {
        state = State.Playing;

        Creatures.PrepareCreatures();

        playerArmies = new List <Army>();
        if (PersistentData.state == PersistentData.State.ExitingCombat)
        {
            MonsterGroup pa = PersistentData.playerArmy;
            for (int i = 0; i < pa.armyCount; i++)
            {
                AddSoldiers(pa.armies[i].count);
            }
            ;
        }
        else
        {
            AddSoldiers(5);
            AddSoldiers(5);
            AddSoldiers(5);
        }

        recruitmentCamps = new List <RecruitmentCamp>();

        if (PersistentData.state == PersistentData.State.ExitingCombat)
        {
            monsterGroups     = PersistentData.monsterGroups.ToArray();
            monsterGroupCount = PersistentData.monsterGroups.Count;
        }
        else
        {
            PrepareMonsterGroups();
        }

        GenerateMap();

        if (PersistentData.state == PersistentData.State.ExitingCombat)
        {
            List <SavedCamp> camps = PersistentData.recruitmentCamps;

            for (int i = 0; i < camps.Count; i++)
            {
                SavedCamp       camp  = camps[i];
                RecruitmentCamp rCamp = Instantiate(recruitmentCampPrefab, tileContainer[camp.gamePosition.y + mapDY, camp.gamePosition.x + mapDX].transform);
                rCamp.transform.position = tileContainer[camp.gamePosition.y + mapDY, camp.gamePosition.x + mapDX].transform.position;
                rCamp.SetMax(camp.max);
                rCamp.SetCurrent(camp.current);
                rCamp.gamePosition = camp.gamePosition;
                recruitmentCamps.Add(rCamp);
            }

            for (int i = 0; i < monsterGroupCount; i++)
            {
                MonsterGroup group    = monsterGroups[i];
                int          count    = group.GetGroupCount();
                GameObject   mgPrefab = GetMonsterGroupPrefab(count);
                GameObject   mgIcon   = Instantiate(mgPrefab, tileContainer[group.gamePosition.y + mapDY, group.gamePosition.x + mapDX].transform);
                mgIcon.transform.localScale = new Vector3(1.0f, 10.0f, 1.0f);
                tileContainer[group.gamePosition.y + mapDY, group.gamePosition.x + mapDX].hasMonsters = true;
            }
        }

        mainCamera = Camera.main.gameObject.GetComponent <CameraController>();
        mainCamera.SetConstraint(
            -mapWidth / 2 * tilePrefab.transform.localScale.x + 4,
            mapWidth / 2 * tilePrefab.transform.localScale.x + 4,
            5,
            5,
            -mapHeight / 2 * tilePrefab.transform.localScale.z - 3,
            mapHeight / 2 * tilePrefab.transform.localScale.z - 3
            );

        if (PersistentData.state == PersistentData.State.ExitingCombat)
        {
            Vector2i position = PersistentData.playerPosition;
            player.SetPosition(position.x, position.y);
        }
        else
        {
            player.SetPosition(3, -4);
        }

        pathfinder = new Pathfinder();
        pathfinder.SetTerrain(terrainPassable);

        if (PersistentData.state == PersistentData.State.ExitingCombat)
        {
            currentDay   = PersistentData.day;
            currentWeek  = PersistentData.week;
            currentMonth = PersistentData.month;
        }
        else
        {
            currentDay   = 1;
            currentWeek  = 1;
            currentMonth = 1;
        }

        if (PersistentData.state == PersistentData.State.ExitingCombat)
        {
            SetPlayerMovement(PersistentData.movementPoints);
        }
        else
        {
            SetPlayerMovement(6);
        }

        monthValue.text   = currentMonth.ToString();
        weekValue.text    = currentWeek.ToString();
        dayValue.text     = currentDay.ToString();
        weekdayValue.text = ((WeekDay)currentDay).ToString();

        if (monsterGroupCount == 0)
        {
            victory.gameObject.SetActive(true);
        }

        PersistentData.state = PersistentData.State.WorldMap;

#if UNITY_EDITOR
        DynamicGI.UpdateEnvironment();
#endif
    }