private void Awake()
 {
     // Find the tilemap game object and cache the behaviour.
     m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>();
     if (m_tileMap == null)
         Debug.LogError("TileMapBehaviour not found");
 }
Beispiel #2
0
    private void Awake()
    {
        // Find the tilemap game object and cache the behaviour.
        m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>();
        if (m_tileMap == null)
        {
            Debug.LogError("TileMapBehaviour not found");
            return;
        }

        // Rather than hardcode the resolution of a tile, use the size of the first sprite.
        var tileSheet = m_tileMap.TileSheet;
        if (tileSheet.Count == 0)
        {
            Debug.LogError("Add some sprites before running the game");
            return;
        }
        var spriteSize = tileSheet.Get(0).rect;

        // Define and apply the settings for the tilemap.
        var settings = new TileMeshSettings(SizeX, SizeY, (int)spriteSize.width);
        m_tileMap.MeshSettings = settings;

        // Map type of tile to sprite
        m_tiles = new TileEnumMapper<TileType>(m_tileMap);
        m_tiles.Map(TileType.Wall, "Wall2");
        m_tiles.Map(TileType.Floor, "Floor");
        m_tiles.Map(TileType.StairsUp, "StairsUp");
        m_tiles.Map(TileType.StairsDown, "StairsDown");
    }
Beispiel #3
0
    void Awake()
    {
        m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>();

        // TODO add keyboard input, calling UpdateVision after each change in position
        //m_input = GetComponent<KeyboardInputBehaviour>();
    }
 public TileEnumMapper(TileMapBehaviour tileMap)
 {
     if (tileMap == null)
     {
         throw new ArgumentNullException("tileMap");
     }
     m_tileMap = tileMap;
 }
	// Use this for initialization
	void Start () {
        // The TileMapVisibilityBehaviour should be created by the TileMapBehaviour as a child
        m_tileMap = transform.parent.GetComponent<TileMapBehaviour>();

        if (m_tileMap == null)
            throw new InvalidOperationException("TileMapVisibility GameObject is not a child of TileMap, did you create it yourself?");

        AttachToTileMap(m_tileMap);
	}
Beispiel #6
0
 public void Initialize(TileMapBehaviour parent, TileMeshSettings settings)
 {
     if (Initialized)
     {
         throw new InvalidOperationException("Already initialized");
     }
     m_parent    = parent;
     m_settings  = settings;
     Initialized = true;
 }
Beispiel #7
0
 void Start()
 {
     fb.setDirectory(Application.streamingAssetsPath);
     fb.setLayout(1);
     fb.guiSkin           = skins[0];
     fb.fileTexture       = file;
     fb.directoryTexture  = folder;
     fb.backTexture       = back;
     fb.driveTexture      = drive;
     fb.showSearch        = true;
     fb.searchRecursively = true;
     tileMap     = FindObjectOfType <UnityTileMap.TileMapBehaviour>();
     tileMapGame = FindObjectOfType <TileMapGameBahaviour>();
 }
    private void OnEnable()
    {
        m_tileMap = (TileMapBehaviour)target;
        m_tileSheet = m_tileMap.TileSheet;

        var meshSettings = m_tileMap.MeshSettings;
        if (meshSettings != null)
        {
            m_tilesX = meshSettings.TilesX;
            m_tilesY = meshSettings.TilesY;
            m_tileResolution = meshSettings.TileResolution;
            m_tileSize = meshSettings.TileSize;
            m_meshMode = meshSettings.MeshMode;
            m_textureFormat = meshSettings.TextureFormat;
        }
        m_activeInEditMode = m_tileMap.ActiveInEditMode;
    }
    public void AttachToTileMap(TileMapBehaviour tileMap)
    {
        m_tileMap = tileMap;

        // position the visibility graphics to match the tile map
        // TODO doesnt support moving the tile map after visibility has been attached
        transform.position = m_tileMap.transform.position;

        // create the texture that will cover the unseen parts of the map with black, one pixel per tile
        // TODO add support for resizing map after its been attached
        m_texture = new Texture2D(
            m_tileMap.MeshSettings.TilesX,
            m_tileMap.MeshSettings.TilesY,
            TextureFormat.RGBA32,
            false);
        m_texture.name = "TileMapVisibilityTexture";
        m_texture.filterMode = FilterMode.Point; // TODO filter mode selected by user?
//        m_texture.alphaIsTransparency = true;

        // setup the grid to cache status, so we dont draw on the texture when we dont have to
        m_visible = new Grid<bool>();
        m_visible.SetSize(m_texture.width, m_texture.height, true);

        // paint all tiles invisible initially
        for (int x = 0; x < m_texture.width; x++)
            for (int y = 0; y < m_texture.height; y++)
                SetTileVisible(x, y, false);
        m_texture.Apply();

        // create a sprite that will cover the map, upscaling each pixel to cover a tile
        var textureRect = new Rect(0, 0, m_texture.width, m_texture.height);
        var sprite = Sprite.Create(m_texture, textureRect, Vector2.zero);
        sprite.name = "TileMapVisibilitySprite";
        
        m_spriteRenderer.sprite = sprite;

        // scale to cover tilemap
        transform.localScale = new Vector3(100, 100, 0f); // TODO is this because 100 pixels per unit?
        
        // setup the grid to cache status, so we dont draw on the texture when we dont have to
        m_visible = new Grid<bool>();
        m_visible.SetSize(m_texture.width, m_texture.height, false);
    }
Beispiel #10
0
 public TilePainter(TileMapBehaviour tileMap)
 {
     if (tileMap == null)
         throw new ArgumentNullException("tileMap");
     m_tileMap = tileMap;
 }
Beispiel #11
0
    private void Start()
    {
		 


		noMove = true;
		simula = false;
	    syncRunEvent = new AnimationEvent();
		anim = transform.Search ("character_rig").GetComponent<Animator> ();
		 
	 

		effects = transform.Search ("Effects Keen").gameObject;
		 


        var tileMapGameObject = GameObject.Find("TileMap");
        m_tileMap = tileMapGameObject.GetComponent<TileMapBehaviour>();
        if (m_tileMap == null)
            Debug.LogError("TileMapBehaviour not found");
        m_levelBehaviour = tileMapGameObject.GetComponent<LevelBehaviour>();
        if (m_levelBehaviour == null)
            Debug.LogError("LevelBehaviour not found");
        m_sceneFadeInOut = GameObject.Find("SceneFader").GetComponent<SceneFadeInOut>();
        if (m_sceneFadeInOut == null)
            Debug.LogError("SceneFadeInOut not found");

		enemieBehaviourGameObject = GameObject.Find("Enemies");
		if (enemieBehaviourGameObject == null)
			Debug.LogError ("EnemieBehaviour not found");

		itemBehaviourGameObject = GameObject.Find("Itens");
		if (itemBehaviourGameObject == null)
			Debug.LogError ("itens obj not found");

		blocks = GameObject.Find("Blocks");
		
		if (blocks == null)
		{
			Debug.LogError("blocks not found");
			return;
		}
	
		mapPrefab= GameObject.Find("Map");
		
		if (mapPrefab == null)
		{
			Debug.LogError("Map not found");
			return;
		}

		swipeToMove = 10;
		updadeEnemie = false;
		move_slash = false;
		enterDoor = 0;
		haveKey = false;
	
		lifeHitParticle.GetComponent<ParticleSystem> ().enableEmission = false;

		velReal = vel;

    }
Beispiel #12
0
 private void Awake()
 {
     m_tileMapBehaviour = GetComponent<TileMapBehaviour>();
     if (m_tileMapBehaviour == null)
         Debug.LogError("TileMapBehaviour not found");
 }
 void Awake()
 {
     // TODO a general way to find and attach to a tile map
     m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>();
 }
Beispiel #14
0
 // Use this for initialization
 private void Start()
 {
     m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>();
     if (m_tileMap == null)
         Debug.LogError("TileMapBehaviour not found");
 }
 public void Initialize(TileMapBehaviour parent, TileMeshSettings settings)
 {
     if (Initialized)
         throw new InvalidOperationException("Already initialized");
     m_parent = parent;
     m_settings = settings;
     Initialized = true;
 }
Beispiel #16
0
    private void Awake()
    {
 
	 // Find the tilemap game object and cache the behaviour.
        m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>();
        if (m_tileMap == null)
        {
            Debug.LogError("TileMapBehaviour not found");
            return;
        }

	   itens = GameObject.Find("Itens");
		
		if (itens == null)
		{
			Debug.LogError("itens not found");
			return;
		}

		blocks = GameObject.Find("Blocks");
		
		if (blocks == null)
		{
			Debug.LogError("blocks not found");
			return;
		}

		mapPrefab= GameObject.Find("Map");
		
		if (mapPrefab == null)
		{
			Debug.LogError("Map not found");
			return;
		}


		enemies = GameObject.Find ("Enemies");

		if (enemies == null)
		{
			Debug.LogError("Enemies not found");
			return;
		}

 
		tmx_map = GameObject.Find ("TMX - MAP");
		
		if (enemies == null)
		{
			Debug.LogError("tmx map not found");
			return;
		}
		
		// Rather than hardcode the resolution of a tile, use the size of the first sprite.
        var tileSheet = m_tileMap.TileSheet;
        if (tileSheet.Count == 0)
        {
            Debug.LogError("Add some sprites before running the game");
            return;
        }
        var spriteSize = tileSheet.Get(0).rect;

        // Define and apply the settings for the tilemap.
        var settings = new TileMeshSettings(SizeX, SizeY, (int)spriteSize.width);
        m_tileMap.MeshSettings = settings;

        // Map type of tile to sprite
        m_tiles = new TileEnumMapper<TileType>(m_tileMap);
        m_tiles.Map(TileType.Wall, "Wall2");
        m_tiles.Map(TileType.Floor, "Floor");
		m_tiles.Map(TileType.Totem, "Totem");
		m_tiles.Map(TileType.Totem1, "Totem1");
		m_tiles.Map(TileType.Totem2, "Totem2");
		m_tiles.Map(TileType.ALWAYS_CLOSED_DOOR, "ALWAYS_CLOSED_DOOR");
		m_tiles.Map(TileType.ALWAYS_OPEN_DOOR, "ALWAYS_OPEN_DOOR");
		m_tiles.Map(TileType.LOCALLY_CLOSED_DOOR, "LOCALLY_CLOSED_DOOR");
		m_tiles.Map(TileType.KEY_RECQUIRING_DOOR, "KEY_RECQUIRING_DOOR");
		m_tiles.Map(TileType.GEM, "GEM");
		m_tiles.Map(TileType.BIG_CRYSTAL, "BIG_CRYSTAL");
		m_tiles.Map(TileType.SMALL_CRYSTAL, "SMALL_CRYSTAL");
		m_tiles.Map(TileType.CLIPPING, "CLIPPING"); 
		m_tiles.Map(TileType.ONE_HP_REFILL, "ONE_HP_REFILL");
		m_tiles.Map(TileType.ENEMY_INSTANCE, "ENEMY_INSTANCE");	 
		m_tiles.Map(TileType.COLLECTIBLE_INSTANCE, "COLLECTIBLE_INSTANCE");
		m_tiles.Map(TileType.KEY, "KEY");
 
 
    }