Example #1
0
    private void GenerateWorldMap(World world, int scale = 4)
    {
        Scale        = scale;
        WorldMapBase = new Texture2D(World.WorldSize * scale, World.WorldSize * scale);
        for (int x = 0; x < World.WorldSize; x++)
        {
            for (int z = 0; z < World.WorldSize; z++)
            {
                Color c = GetColorFromChunkBase(world.ChunkBases[x, z]);
                for (int x_ = 0; x_ < scale; x_++)
                {
                    for (int z_ = 0; z_ < scale; z_++)
                    {
                        WorldMapBase.SetPixel(x * scale + x_, z * scale + z_, c);
                    }
                }
            }
        }
        WorldMapBase.Apply();

        WorldMapLocations = new List <WorldMapLocation>();

        foreach (KeyValuePair <int, WorldLocation> loc in world.WorldLocations)
        {
            WorldMapLocation wml = new WorldMapLocation(loc.Value.Name, loc.Value.ChunkPos);
            WorldMapLocations.Add(wml);
            loc.Value.SetWorldMapLocation(wml);
        }
    }
 public void SetLocation(WorldMapGUI parent, WorldMapLocation location)
 {
     Text.text = location.Name;
     GetComponent <RectTransform>().anchoredPosition = location.ChunkPosition.AsVector2() * 4;
     Parent           = parent;
     WorldMapLocation = location;
 }
Example #3
0
 public void TeleportToLocation(WorldMapLocation wml)
 {
     if (GameManager.WorldManager.InSubworld)
     {
         return;
     }
     GameManager.PlayerManager.Player.SetPosition(wml.WorldPosition);
 }
Example #4
0
 public void Update()
 {
     if (LocationsToDisplay.Count > 0)
     {
         WorldMapLocation wml = LocationsToDisplay.Dequeue();
         WorldMap.CreateLocationLabel(this, wml);
     }
 }
Example #5
0
    private void OnEnable()
    {
        if (WorldMap == null)
        {
            WorldMap = GameManager.WorldManager.World.WorldMap;
            WorldMapImage.texture = WorldMap.WorldMapBase;



            WorldMapLocation activeLoc = GetActiveQuestWML();
            foreach (WorldMapLocation wml in WorldMap.WorldMapLocations)
            {
                if (wml == null)
                {
                    continue;
                }
                GameObject butObj = Instantiate(WorldMapLocButtonPrefab);
                butObj.transform.SetParent(WorldMapImage.transform, false);
                butObj.transform.localPosition = wml.ChunkPosition.AsVector2() * WorldMap.Scale;
                butObj.GetComponent <WorldMapLocationButton>().SetLocation(this, wml);
                if (activeLoc == wml)
                {
                    butObj.GetComponent <WorldMapLocationButton>().SetActiveQuestButton(true);
                }
                else
                {
                    butObj.GetComponent <WorldMapLocationButton>().SetActiveQuestButton(false);
                }
            }
        }
        else
        {
            WorldMapLocation activeLoc = GetActiveQuestWML();

            //Iterate all world map locations
            foreach (Transform t in WorldMapImage.transform)
            {
                WorldMapLocationButton but = t.gameObject.GetComponent <WorldMapLocationButton>();
                if (but.WorldMapLocation == activeLoc)
                {
                    but.SetActiveQuestButton(true);
                }
                else
                {
                    but.SetActiveQuestButton(false);
                }
            }
        }
    }
Example #6
0
    /// <summary>
    /// Slow tick on quests finds the players chunk, and uses this to check for
    /// 'Go to Location' quest requirements.
    /// </summary>
    private void SlowTickUpdate()
    {
        //Find the players position
        Vec2i        pChunkPos    = World.GetChunkPosition(GameManager.PlayerManager.Player.Position);
        List <Quest> taskComplete = new List <Quest>();

        foreach (Quest q in InProgress)
        {
            if (q.CurrentTask().TaskType == QuestTask.QuestTaskType.GO_TO_LOCATION)
            {
                WorldMapLocation wml = q.CurrentTask().GetLocation();
                if (wml.ChunkPosition == pChunkPos)
                {
                    taskComplete.Add(q);
                }
            }
        }
        foreach (Quest q in taskComplete)
        {
            QuestCurrentTaskComplete(q);
        }
    }
Example #7
0
    private void GenerateWorldMap(World world, int scale = 4)
    {
        Scale        = scale;
        WorldMapBase = new Texture2D(World.WorldSize * scale, World.WorldSize * scale);
        for (int x = 0; x < World.WorldSize; x++)
        {
            for (int z = 0; z < World.WorldSize; z++)
            {
                Color c = GetColorFromChunkBase(world.ChunkBases[x, z]);
                for (int x_ = 0; x_ < scale; x_++)
                {
                    for (int z_ = 0; z_ < scale; z_++)
                    {
                        WorldMapBase.SetPixel(x * scale + x_, z * scale + z_, c);
                    }
                }
            }
        }
        WorldMapBase.Apply();

        WorldMapLocations = new List <WorldMapLocation>();


        foreach (KeyValuePair <int, Settlement> set in world.WorldSettlements)
        {
            WorldMapLocation wml = new WorldMapLocation(set.Value.Name, set.Value.BaseCoord / World.ChunkSize);
            WorldMapLocations.Add(wml);
            set.Value.SetWorldMapLocation(wml);
        }
        foreach (KeyValuePair <int, ChunkStructure> set in world.WorldChunkStructures)
        {
            WorldMapLocation wml = new WorldMapLocation(set.Value.Name, set.Value.Position);
            WorldMapLocations.Add(wml);

            set.Value.SetWorldMapLocation(wml);
        }
    }
Example #8
0
 void AddPoint(WorldMapLocation location)
 {
 }
Example #9
0
 public void SetWorldMapLocation(WorldMapLocation wml)
 {
     WorldMapLocation = wml;
 }
Example #10
0
 void AddPoint(WorldMapLocation location)
 {
 }