Ejemplo n.º 1
0
    void ShowPossibleDroplocations()
    {
        SimpleCords origin = originLocation;
        GameObject  GOo    = GameObject.Instantiate(ResourceLibrary.GetPrefabByName("prop_TileHighlightOrigin"));

        GOo.transform.position = origin;
        possiblePositionsGO    = new List <GameObject>();
        possiblePositions      = new List <SimpleCords>();
        possiblePositionsGO.Add(GOo);
        possiblePositions.Add(origin);

        //TODO: change it to whatever we want
        Offset[] miniOffsets = new Offset[]
        {
            new Offset(1, 0),
            new Offset(-1, 0),
            new Offset(0, 1),
            new Offset(0, -1),
        };

        foreach (var item in miniOffsets)
        {
            SimpleCords pos = origin;
            pos = pos.OffsetBy(item);
            Tile currCheck;
            while ((currCheck = space.Map.SaveGet(pos.x, pos.z)).occupation == TileOccupation.Empty)
            {
                GameObject tmp = GameObject.Instantiate(ResourceLibrary.GetPrefabByName("prop_TileHighlightGood"));
                tmp.transform.position = pos;
                possiblePositions.Add(pos);
                possiblePositionsGO.Add(tmp);
                pos = pos.OffsetBy(item);
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// use this with unplaced Objects
    /// </summary>
    /// <param name="building">the building</param>
    /// <param name="location">position of placement</param>
    public void SpawnBuilding(BaseBuilding building, SimpleCords location, int orientation)
    {
        Map[location.x, location.z].Building   = building;
        Map[location.x, location.z].occupation = TileOccupation.Building;

        foreach (var item in building.occupying)
        {
            Debug.Log("Spawn Building with orientation: " + orientation);
            SimpleCords c = location.OffsetBy(item.Rotate(orientation));
            Map[c.x, c.z].Building   = building;
            Map[c.x, c.z].occupation = TileOccupation.Building;
        }

        building.CenterLocation = location;
        building.PlaceWithOrientation(orientation, location);
        Buildings.Add(building);
    }