예제 #1
0
파일: MapController.cs 프로젝트: fuchs-/MBA
	void Start () {
		//THERE CAN BE ONLY ONE
		if (mapController != null && mapController != this) {
			Destroy (this.gameObject);
			return;
		}
		mapController = this;

		GameObject tileMap_go = transform.FindChild ("TileMap").gameObject;
		if (tileMap_go) {
			tileMap = tileMap_go.GetComponent<TileMapController> ();
		} else {
			Debug.LogError ("TileMap not found");
		}

		GameObject heroes_go = GameObject.Find ("Heroes");
		if (heroes_go) {
			heroes_go.transform.SetParent (this.transform);
			heroes = heroes_go.GetComponent<HeroesController> ();
		} else {
			Debug.LogError ("Heroes GameObject not found");
		}

		tileMap.CreateTileMap ();
		heroes.CreateHeroMap ();

		tileHighlightPrefab = (GameObject) Resources.Load ("UI/TileHighlight");

		pathfinder = new PathfinderDijkstra ();
	}
예제 #2
0
    void Start()
    {
        _fullBrickPrefab = gameObject.GetComponent <GameManager>().AvalableBlocks[0].MyPrefab;

        var y = 0.5f;

        _bricks = new List <BrickPlacement>
        {
            new BrickPlacement(2, y, 1, 0, 0, 0),
            new BrickPlacement(4, y, 1, 0, 0, 0),
            new BrickPlacement(5, y, 1, 0, 90, 0),
            new BrickPlacement(5, y, 3, 0, 90, 0),
            new BrickPlacement(5, y, 5, 0, 0, 0),
            new BrickPlacement(3, y, 5, 0, 0, 0),
            new BrickPlacement(1, y, 5, 0, -90, 0),
            new BrickPlacement(1, y, 3, 0, -90, 0)
        };

        _tileController = TileMapController.instance;
        foreach (var brickPosition in _bricks)
        {
            var newPieceGameObject = Instantiate(_fullBrickPrefab) as GameObject;
            newPieceGameObject.transform.position = brickPosition.GetPostion();
            newPieceGameObject.transform.Rotate(brickPosition.GetRotationEuler(), Space.World);
            newPieceGameObject.transform.parent = HouseOrigin.transform;
            _tileController.AddPiece(newPieceGameObject);
        }
    }
예제 #3
0
    public void Awake()
    {
        tileAStar = new TileAStar();

        _controller = GetComponent <TileMapController>();
        _renderer   = GetComponent <MinimapRenderer_Tile>();
    }
예제 #4
0
    public void Awake()
    {
        waypointAStar = new Minimap_Waypoint();

        _controller = GetComponent <TileMapController>();
        _renderer   = GetComponent <MinimapRenderer_Waypoint>();
    }
예제 #5
0
        void Start()
        {
            var controller = new TileMapController();

            controller.tileMap = tileMapGenerator.tileMap;

            GetComponent <GamepadGeneric>().controller = controller;
        }
예제 #6
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Hello World, motherfuckers!");

        tileMapController = mainTileMap.GetComponent <TileMapController>();

        autoGenButton.onClick.AddListener(() => InitPlayerAndTiles());
    }
예제 #7
0
 public void Awake()
 {
     _controller      = GetComponent <TileMapController>();
     _renderRoot      = new GameObject();
     _renderRoot.name = "Render Root";
     _renderRoot.transform.SetParent(transform);
     _renderRoot.transform.localPosition = new Vector3(0, 0, 200);
     _rTiles = null;
 }
예제 #8
0
    // Use this for initialization
    void Start()
    {
        GameObject        level1 = GameObject.Instantiate(tileMapPrefab, levelsParent, false);
        TileMapController tmc    = level1.GetComponent <TileMapController>();

        tmc.StartTileMap(MatrixReader.GetLevelMatrix("/Level1Background.json"), MatrixReader.GetLevelMatrix("/Level1Roads.json"));
        levels.Add(tmc);
        level1.transform.localPosition = new Vector3(0, 1, 0);
    }
예제 #9
0
 //sets the dimensions of the coridoor
 public void setVariables(int width, int height)
 {
     this.width    = width;
     this.height   = height;
     xCentre       = gameObject.transform.position.x;
     zCentre       = gameObject.transform.position.z;
     size          = width * height;
     tileGenerator = GameObject.Find("LevelManager").GetComponent <TileMapController>();
 }
    void Start()
    {
        finalRooms = new List <GameObject> ();
        map        = GameObject.Find("TileMap").GetComponent <TileMapController> ();
        player     = GameObject.Find("Player");
        player.gameObject.SetActive(false);
        StartCoroutine(CreateRooms(level.roomCount));

        groundDecorations = new GameObject[(int)level.mapSize.x, (int)level.mapSize.y];
    }
예제 #11
0
    public void RegistraVisita(int id)
    {
        RegistraVisitaAux(id, true);
        TileMapController tileController = TileMapController.Instance;

        foreach (Vector2Int neighbour in tileController.neighbourAux)
        {
            tileController.GetTile(pos + neighbour).RegistraVisitaAux(id);
        }
    }
예제 #12
0
 //controls what happens when the player enters the room
 public void OnPlayerEnter()
 {
     //if being entered for the first time
     if (!explored)
     {
         explored       = true;
         tileController = GameObject.Find("LevelManager").GetComponent <TileMapController>();
         tileController.RemoveFog(xCentre, zCentre, width, height);
         GetComponent <RoomController>().AddToMiniMap();
     }
 }
    void Start()
    {
        holder = transform.Find("Holder").gameObject;
//		plate = transform.Find ("Plate").gameObject;
        rock          = transform.Find("Rock").gameObject;
        mapController = GameObject.Find("TileMap").GetComponent <TileMapController>();
        int  minHeightCheck = 4;
        int  maxHeightCheck = 64;
        bool madeTrap       = false;

//		for (int y = Mathf.RoundToInt(transform.position.y) + minHeightCheck; y < Mathf.RoundToInt(transform.position.y) + maxHeightCheck; y++) {
//			TileMapController.TileInfo tile = mapController.GetTileAtPosition (transform.position);
//			if (tile.type == TileMapController.TileType.Empty) {
//				madeTrap = true;
//				SetTopOffset (y - Mathf.RoundToInt(transform.position.y));
//				break;
//			}
//		}
        for (int y = 1; y < maxHeightCheck; y++)
        {
            Vector2 checkPos = gameObject.transform.position;
            checkPos.y += y;
            TileMapController.TileInfo tile = mapController.GetTileAtPosition(checkPos, TileMapController.TileLayer.Floor);
            if (y <= minHeightCheck)
            {
                if (tile.type == TileMapController.TileType.Empty)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            else if (y <= maxHeightCheck)
            {
                if (tile.type == TileMapController.TileType.Wall)
                {
                    madeTrap = true;
                    SetTopOffset(y);
                    break;
                }
            }
        }
        if (!madeTrap)
        {
            print("Trap not made");
            Destroy(gameObject);
        }
        else
        {
            print("Trap made");
        }
    }
예제 #14
0
    public override void OnInspectorGUI()
    {
        TileMapController controller = (TileMapController)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Toggle Tileset"))
        {
            controller.SwapTileset();
        }
    }
예제 #15
0
 //sets the dimensions of the coridoor
 public void setVariables(int width, int height, bool isHorizontal)
 {
     this.width        = width;
     this.height       = height;
     this.isHorizontal = isHorizontal;
     xCentre           = gameObject.transform.position.x;
     zCentre           = gameObject.transform.position.z;
     tileGenerator     = GameObject.Find("LevelManager").GetComponent <TileMapController>();
     tileGenerator.DrawFog(xCentre, zCentre, width, height);
     col      = GetComponent <BoxCollider>();
     col.size = (new Vector3(width, 2f, height));
 }
예제 #16
0
 //controls what happens when the player enters the room
 public void OnPlayerEnter()
 {
     //if being entered for the first time
     if (!explored)
     {
         explored       = true;
         tileController = GameObject.Find("LevelManager").GetComponent <TileMapController>();
         tileController.RemoveFog(xCentre, zCentre, width, height);
         GetComponent <RoomController>().AddToMiniMap();
         enemies = GameObject.Find("EnemiesList").transform;
         Instantiate(generator.bossRoom.mobs[0], transform.position + new Vector3(0f, 1f, 0f), Quaternion.identity, enemies);
     }
 }
예제 #17
0
 //controls what happens when the player enters the room
 public void OnPlayerEnter()
 {
     //if being entered for the first time
     if (!explored)
     {
         explored       = true;
         tileController = GameObject.Find("LevelManager").GetComponent <TileMapController>();
         tileController.RemoveFog(xCentre, zCentre, width, height);
         roomController = gameObject.GetComponent <RoomController>();
         roomController.SpawnMobs(generator.mobRoom.mobs, generator.mobRoom.mobThreatValues, extraThreatValue);
         enemies = GameObject.Find("EnemiesList").transform;
         roomController.LockDoors();
         GetComponent <RoomController>().AddToMiniMap();
     }
 }
예제 #18
0
    private void Awake()
    {
        buildableSprite   = Resources.Load("Map/Buildings/Buildable", typeof(Sprite)) as Sprite;   //刷新图片
        unbuildableSprite = Resources.Load("Map/Buildings/Unbuildable", typeof(Sprite)) as Sprite; //刷新图片
        inBuildMode       = true;

        _Instance = this;

        arableCheckLayer    = FindChild.FindTheChild(GameObject.Find("Map"), "ArableCheckLayer");
        plowLayer           = FindChild.FindTheChild(GameObject.Find("Map"), "PlowLayer");
        wateringLayer       = FindChild.FindTheChild(GameObject.Find("Map"), "WateringLayer");
        cropsLayer          = FindChild.FindTheChild(GameObject.Find("Map"), "CropsLayer");
        BuildableCheckLayer = FindChild.FindTheChild(GameObject.Find("Map"), "BuildableCheckLayer");

        arableTM    = arableCheckLayer.GetComponent <Tilemap>();
        plowTM      = plowLayer.GetComponent <Tilemap>();
        waterTM     = wateringLayer.GetComponent <Tilemap>();
        cropsTM     = cropsLayer.GetComponent <Tilemap>();
        BuildableTM = BuildableCheckLayer.GetComponent <Tilemap>();
    }
예제 #19
0
    static void StartGame()
    {
        //Set the gamestate
        gameState = GameState.Paused;

        //set the TileMapController
        tmc = GameObject.Find("TileMapController").GetComponent <TileMapController> ();
        tmc.StartGame();

        //Find a random square of Beach
        List <Tile> beaches = new List <Tile> ();

        for (int i = 0; i < fullMap.Width; i++)
        {
            for (int j = 0; j < fullMap.Height; j++)
            {
                if (fullMap.GetTile(i, j, 25).Biome == "Beach" && !fullMap.GetTile(i, j, 25).IsBlocked)
                {
                    beaches.Add(fullMap.GetTile(i, j, 25));
                }
            }
        }
        Tile startTile = beaches[Random.Range(0, beaches.Count)];

        startTile.Biome = "Start Location";
        Vector3 tilePos = tileMap.GetTilePosition(startTile.PointX, startTile.PointY);

        tilePos.z = Camera.main.transform.position.z;
        Camera.main.transform.position = tilePos;

        //Initialize the character list
        characters = new List <WorldObject> ();
        WorldObject dwarf = new WorldObject("Dwarf", startTile.PointX, startTile.PointY, 25);

        characters.Add(dwarf);
        //tmc.DrawWorldObj ();
    }
예제 #20
0
 private void Awake()
 {
     Instance = this;
 }
예제 #21
0
 public void Awake()
 {
     controller = GameObject.Find("TileMap").GetComponent <TileMapController> ();
 }
예제 #22
0
 void Awake()
 {
     this.tileMapController       = GameObject.FindObjectOfType <TileMapController>();
     this.triangleColorController = GameObject.FindObjectOfType <TriangleColorController>();
 }
예제 #23
0
 private void Awake()
 {
     Instance = this;
     Tiles    = new Dictionary <Vector2Int, Tile>();
 }
 void Awake()
 {
     instance   = this;
     WorldModel = new TileMapModel(WorldSize.x, WorldSize.y, WorldSize.z);
 }