Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        // Subscribe to tile change updates
        WorldEventHandler pmc = new WorldEventHandler(TileUpdated);

        WorldEventHandlerManager.AddListener(worldEventChannels.map, mapChannelEvents.change, pmc);
    }
Ejemplo n.º 2
0
    void Start()
    {
        // Initialize the Domain and MapData
        if (domain == null)
        {
            domain = new Domain();
        }
        N = mapGenerator.GetN();
        domain.mapData = new MapData(N);

        // Load in the tiles
        LoadTiles();

        //Generate the map
        mapGenerator.GenerateMap(domain.mapData);

        // Draw the ground & surface tiles
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                groundTileMap.SetTile(new Vector3Int(i, j, 0), groundTiles[domain.mapData.GetGroundValue(i, j)]);
                if (domain.mapData.GetSurfaceValue(i, j) >= 0)
                {
                    surfaceTileMap.SetTile(new Vector3Int(i, j, 0), surfaceTiles[domain.mapData.GetSurfaceValue(i, j)]);
                }
            }
        }

        // Draw the underground tiles
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                undergroundTileMap.SetTile(new Vector3Int(i, j, 0), undergroundTiles[domain.mapData.GetUndergroundValue(i, j)][domain.mapData.GetStoneValue(i, j)]);
            }
        }
        undergroundTileMap.GetComponent <Renderer>().enabled = false;

        WorldEventHandler pmc = new WorldEventHandler(ProcessMapChange);

        WorldEventHandlerManager.AddListener(worldEventChannels.map, mapChannelEvents.change, pmc);
    }
Ejemplo n.º 3
0
 public void Start()
 {
     this.goalStates   = new List <GoalState>(this.transform.Find("Goals").GetComponentsInChildren <GoalState>());
     worldEventHandler = this.GetComponentInChildren <WorldEventHandler>();
     worldEventHandler.AddEventListener(this.gameObject);
 }
Ejemplo n.º 4
0
 public void UnregisterListener <T>(T listener) where T : IEventListener
 {
     worldEventHandler -= new WorldEventHandler(listener.OnNotification);
 }
 public static void RemoveListener(worldEventChannels evType, Enum ev, WorldEventHandler eventListener)
 {
     ListenerFunctions[evType][ev] -= eventListener;
 }