Exemple #1
0
    IEnumerator Travel(Island island)
    {
        currentSector = FindSector(currentIsland.point);
        Sector sector = FindSector(island.point);

        if (currentSector != sector)
        {
            sectorName.Show(sector);
        }

        Bridge bridge = FindBridge(currentIsland, island);

        RevealIsland(island);

        // Move towards target
        while (Vector2.Distance(island.transform.localPosition, armyMarker.transform.localPosition) != 0)
        {
            armyMarker.transform.localPosition = Vector2.MoveTowards(armyMarker.transform.localPosition, island.transform.localPosition, Time.deltaTime * armySpeed);
            yield return(null);
        }

        if (bridge.fragile)
        {
            bridges.Remove(bridge);
            bridge.Walk();
            audioSource.PlayOneShot(breakingSound);
            yield return(new WaitForSeconds(bridgeBreakDelay));
        }

        // Update position
        GameData.instance.data.mapPosition = island.point;

        // Add island to visited locations list
        if (!GameData.instance.data.visitedIslands.Contains(currentIsland.point))
        {
            GameData.instance.data.visitedIslands.Add(currentIsland.point);
        }

        // Start event
        if (island.islandEvent != null)
        {
            GameData.instance.data.eventName = island.islandEvent.name;
            eventManager.StartEvent(island.islandEvent);
        }
        else
        {
            SetAdjacentIslands();
            playerControl = true;
        }

        GameData.instance.data.day++;
        mapUI.UpdateDate();

        SaveManager.Save(GameData.instance);
    }