示例#1
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        player = (Node2D)GetParent();
        //Grab a refference to the map
        MapInfoRequestEvent mirei = new MapInfoRequestEvent();

        mirei.FireEvent();
        map = mirei.tileMap;
    }
示例#2
0
    //Grab mouse clikced signal from the input manager, might need to assign input manager tot a node 2D in the main scnene itself
    public override void _Ready()
    {
        //random.Seed = 21;
        random.Randomize();
        //Create ne reference for the Simplex noise to be used for map generation
        noise = new OpenSimplexNoise();
        //Generate a random noise patern by using a randomized seed
        noise.Seed    = (int)random.Randi();
        noise.Octaves = 1;
        noise.Period  = 12;
        //noise.Persistence = 0.7f;

        MouseClickEvent.RegisterListener(CheckTileClicked);
        MapInfoRequestEvent.RegisterListener(GetMapInfo);

        //Set the tile map data size
        tileDataMap = new Tile[(int)mapSize.x, (int)mapSize.y];
        //Grab a refference to the tile map node
        tileMap = GetNode <TileMap>("Nav2D/TileMap");
        //Initialize the tile data for every entry in the array
        InitMap();
        //Init test of the tile map generation
        GenerateMap();
    }
示例#3
0
文件: Main.cs 项目: IndieRonin/Blocko
    private void SpawnScenes()
    {
        //----------------------------------
        //NOTE: The scenes instanced first will be at the bottom of the z sorting layer!!!!!!!!
        //----------------------------------

        //Instacne the map
        map      = mapScene.Instance();
        map.Name = "Map";
        //Set the map as a child of the main scene
        AddChild(map);
        //Grab the map info for the spawning of the player
        MapInfoRequestEvent mirei = new MapInfoRequestEvent();

        mirei.FireEvent();
        tileMap = mirei.tileMap;
        mapSize = mirei.mapSize;
        //Spawn the artifact
        SpawnArtifact();
        //Spawn the player in an open tile somewhere in the left uper corner of the map
        SpawnPlayer();
        //Spawn enemies across the map
        SpawnEnemies();
    }
示例#4
0
 public override void _ExitTree()
 {
     MouseClickEvent.UnregisterListener(CheckTileClicked);
     MapInfoRequestEvent.UnregisterListener(GetMapInfo);
 }
示例#5
0
 private void GetMapInfo(MapInfoRequestEvent mirei)
 {
     mirei.mapSize = mapSize;
     mirei.tileMap = tileMap;
 }