Inheritance: ScriptableObject
    public Tile getPlayerNextTile(float playerxPos)
    {
        int nextTileIndex = TileList.IndexOf(getPlayerTile(playerxPos)) + 1;


        return(TileList[nextTileIndex]);
    }
    void replaceTile(float playerxPos)
    {
        int countPassedTile = 0;

        foreach (Tile tile in tileList)
        {
            if (tile.IsPassed == true)
            {
                countPassedTile++;
            }
        }

        if (countPassedTile <= 3)
        {
            return;
        }
        else
        {
            //Debug.Log(TileList[0].Prefeb);
            StartCoroutine(TileList[0].Prefeb.GetComponent <BlockControl>().lateDestroy(TileList[0].EnvironmentCube, tileList[0].Skeleton, tileList[0].Item));
            TileList.RemoveAt(0);
            createTile();


            //---for bullet
            follower.GetComponent <SmoothFollow>().shoot();
        }
    }
示例#3
0
 /// <summary>Create new Hex Board.</summary>
 /// <param name="width">Width of the board.</param>
 /// <param name="height">Height of the board.</param>
 public HexBoard(int width, int height, TileList tileList)
 {
     _boardWidth = width;
     _boardHeight = height;
     _tileList = tileList;
     tiles = new HexTile[_boardWidth * _boardHeight];
 }
示例#4
0
 private void PrivateClear(bool tookTurn)
 {
     this.TookTurn = tookTurn;
     TimeToGetWord = -1;
     TileList.Clear();
     CardUsed = 0;
 }
示例#5
0
    /// <summary>
    /// 일반 타일을 배치합니다.
    /// </summary>
    /// <param name="pivot">기준점</param>
    /// <param name="size">헥사곤 크기</param>
    /// <param name="hexagonSpriteSize">헥사곤 스프라이트 크기</param>
    void PlaceTiles(Vector3 pivot, Vector2 size, Vector2 hexagonSpriteSize)
    {
        Vector2 firstPosition = Vector2.zero - (size * hexagonSpriteSize * 0.5f);
        Vector2 lastPosition  = Vector2.zero + (size * hexagonSpriteSize * 0.5f);
        Vector2 spriteSize    = tilePrefab.GetComponent <SpriteRenderer>().bounds.size;

        int indexX = 0;

        for (float x = firstPosition.x; x <= lastPosition.x; x += spriteSize.x, indexX += 1)
        {
            TileList.Add(new List <GameObject>());

            int indexY = 0;

            for (float y = firstPosition.y; y <= lastPosition.y; y += spriteSize.y, indexY += 1)
            {
                GameObject tile = Instantiate(tilePrefab, transform);

                Vector3 tilePosition = new Vector3(x, y);

                tile.transform.position = tilePosition;

                TileList[indexX].Add(tile);
            }
        }
    }
    private void PositionTile(Vector2Int position, Color color, List <Tile> specificList, TileBase tileBase)
    {
        Tile tile = new Tile(tileBase, (Vector3Int)position);

        specificList.Add(tile);
        TileList.Add(tile);
    }
示例#7
0
    private void DrawVariables()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Grid Anchor");
        gridGameObject = EditorGUILayout.ObjectField(gridGameObject, typeof(GameObject), true) as GameObject;
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Tile List");
        tileList = EditorGUILayout.ObjectField(tileList, typeof(ScriptableObject), false) as TileList;
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Grid Size");
        tileSetSize = EditorGUILayout.IntField(tileSetSize);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Cell Size");
        cellSize = EditorGUILayout.FloatField(cellSize);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Tile Size");
        cellGameObjectSize = EditorGUILayout.Vector3Field("", cellGameObjectSize);
        EditorGUILayout.EndHorizontal();
    }
示例#8
0
 private void ScrollToSelected()
 {
     if (SelectedIndex == -1)
     {
         return;
     }
     TileList.ScrollIntoView(TileList.Items[SelectedIndex]);
 }
示例#9
0
    public IEnumerator BuildFromTemplate(int[,] map, TileList availableTiles)
    {
        int xSize = map.GetLength(0);
        int ySize = map.GetLength(1);

        tiles        = new CustomTile[xSize, ySize];
        blocksVision = new bool[xSize, ySize];
        moveCosts    = new float[xSize, ySize];
        yield return(null);

        tileContainer    = new GameObject("Tiles").transform;
        monsterContainer = new GameObject("Monsters").transform;
        itemContainer    = new GameObject("Items").transform;

        tileContainer.parent    = transform;
        monsterContainer.parent = transform;
        itemContainer.parent    = transform;

        width  = xSize;
        height = ySize;
        for (int j = 0; j < height; j++)
        {
            GameObject row = new GameObject {
                name = $"Row {j}"
            };
            row.transform.parent = tileContainer;
            for (int i = 0; i < width; i++)
            {
                GameObject g = Instantiate(availableTiles.tiles[map[i, j]], row.transform, true);
                g.name = $"Tile ({i}, {j})";
                CustomTile custom = g.GetComponent <CustomTile>();
                if (!custom)
                {
                    Debug.LogError("Tile did not have tile component.");
                }
                g.transform.position = new Vector3(i, j, 0);
                tiles[i, j]          = custom;
                custom.SetMap(this, new Vector2Int(i, j));
                custom.Setup();
                if (i % 33 == 32)
                {
                    yield return(null);
                }
            }
            yield return(null);
        }

        //Now that map data is finished, go rebuild it
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                tiles[i, j].RebuildMapData();
            }
            yield return(null);
        }
    }
示例#10
0
        private void TileList_DoubleClick(object sender, EventArgs e)
        {
            if (m_parent.Status.Path != null)
            {
                m_parent.Status.Path.RemoveRange(0, TileList.SelectedIndex);
            }

            TileList.Refresh();
        }
示例#11
0
 private void AddFleetsToWorldIfTileExists()
 {
     for (int i = 0; i < BufferedFleetList.Count; i++)
     {
         if (TileList.Exists(t => t.Position == BufferedFleetList[i].Position))
         {
             AddBufferedFleetsToWorld(BufferedFleetList[i]);
         }
     }
 }
    public void FindNearestTarget()
    {
        List <GameObject> targets         = GameObject.Find("GameMaster").GetComponent <MapData>().getPlayers();
        GameObject        nearest         = null;
        float             nearestDistance = Mathf.Infinity;

        foreach (GameObject obj in targets)
        {
            //computeAdjacencyList();
            foreach (GameObject resetTile in tiles)
            {
                resetTile.GetComponent <Tile>().distance = -1;
                resetTile.GetComponent <Tile>().visited  = false;
            }
            obj.GetComponent <PlayerMove>().currentTile = getTargetTile(obj);
            Tile     t       = obj.GetComponent <PlayerMove>().currentTile;
            TileList process = new TileList();
            t.distance = 0;
            process.Add(t);
            t.visited = true;

            while (process.Count > 0)
            {
                bool finishLoop = false;
                process.Sort(process.getComparator());
                Tile currentTile = process[0];
                process.RemoveAt(0);
                this.getTargetTile(gameObject);
                if (currentTile.Equals(this.currentTile))
                {
                    finishLoop = true;
                    process.Clear();
                    if (currentTile.distance - currentTile.getMoveCost() + 1 < nearestDistance)
                    {
                        nearest = obj;

                        nearestDistance  = currentTile.distance - currentTile.getMoveCost() + 1;
                        distanceToTarget = nearestDistance;
                    }
                }

                foreach (Tile tile in currentTile.adjacencyList)
                {
                    if (!tile.visited && tile.isWalkable && finishLoop == false)
                    {
                        tile.parent   = currentTile;
                        tile.visited  = true;
                        tile.distance = currentTile.distance + tile.getMoveCost();
                        process.Add(tile);
                    }
                }
            }
        }
        target = nearest;
    }
示例#13
0
 private void Start()
 {
     try
     {
         objects = ((ObjectLayer)metaTileMap.Layers[LayerType.Objects]).Objects;
     }
     catch
     {
         Logger.LogError("CAST ERROR: Make sure everything is in its proper layer type.", Category.Matrix);
     }
 }
示例#14
0
 private void Start()
 {
     metaTileMap = GetComponent <MetaTileMap>();
     try
     {
         objects = ((ObjectLayer)metaTileMap.Layers[LayerType.Objects]).Objects;
     }
     catch
     {
         Debug.LogError("CAST ERROR: Make sure everything is in its proper layer type.");
     }
 }
示例#15
0
    public void DestroyFleet(Fleet fleet)
    {
        var tileOfFleet = TileList.Find(t => t.Fleet == fleet);

        tileOfFleet.Fleet = null;

        Destroy(fleet.FleetParent.gameObject);

        TileManager.ResetHighlightedTile();

        FleetList.Remove(fleet);
    }
    public void BuildPathToTargetTile()
    {
        foreach (GameObject resetTile in tiles)
        {
            resetTile.GetComponent <Tile>().distance = -1;
            resetTile.GetComponent <Tile>().visited  = false;
        }
        TileList process = new TileList();

        currentTile.distance = 0;
        process.Add(currentTile);
        currentTile.visited = true;
        currentTile.parent  = null;

        while (process.Count > 0)
        {
            process.Sort(process.getComparator());
            Tile t = process[0];
            process.RemoveAt(0);
            bool endLoop = false;
            if (t.isWalkable && !endLoop)
            {
                foreach (Tile tile in t.adjacencyList)
                {
                    string tagOn = "";
                    foreach (Collider2D collider in tile.GetOnTopOf())
                    {
                        if (collider.gameObject.tag != null)
                        {
                            if (collider.gameObject.tag == "Player" || collider.gameObject.tag == "Enemy")
                            {
                                tagOn = collider.gameObject.tag;
                            }
                            //Debug.Log(tagOn);
                        }
                    }

                    if (!tile.visited && (tile.walkable || tagOn == gameObject.tag) && t.distance + tile.getMoveCost() <= move && !endLoop)
                    {
                        tile.parent   = t;
                        tile.visited  = true;
                        tile.distance = t.distance + tile.getMoveCost();
                        process.Add(tile);
                    }
                    if (tile.Equals(tileToMoveTo))
                    {
                        endLoop = true;
                    }
                }
            }
        }
    }
示例#17
0
        public static void LoadMap()
        {
            TileList.Clear();
            //ObjectList.Clear();
            string FullFile = File.ReadAllText(@"C:\Users\Alex\Documents\TestMap.fmf");

            string[] TileData = FullFile.Substring(FullFile.IndexOf("<tile>"), FullFile.IndexOf("</tile>")).Replace("<tile>", "").Replace("</tile>", "").Split(';');
            foreach (string s in TileData)
            {
                if (s != "")
                {
                    string[]  TileSplit = s.Split(':');
                    int       X         = Int32.Parse(TileSplit[0]);
                    int       Y         = Int32.Parse(TileSplit[1]);
                    Texture2D tx        = TextureList[TileSplit[2].Replace("_", "")];
                    TileList.Add(new Tile(X, Y, tx));
                }
            }
            int FFA = FullFile.IndexOf("<obj>");
            int FFB = FullFile.IndexOf("</obj>");

            string[] ObjData = FullFile.Split(new string[] { "<obj>" }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("</obj>", "").Split(';');
            foreach (string s in ObjData)
            {
                if (s != "")
                {
                    string[]  TileSplit = s.Split(':');
                    int       X         = Int32.Parse(TileSplit[0]);
                    int       Y         = Int32.Parse(TileSplit[1]);
                    Texture2D tx        = ObjTextureList[TileSplit[2].Replace("_", "").Split('\\')[1]];
                    ObjectList.Add(new WorldObject(X, Y, tx));
                }
            }
            try
            {
                string[] BndData = FullFile.Split(new string[] { "<bound>" }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("</bound>", "").Split(';');
                foreach (string s in BndData)
                {
                    if (s != "")
                    {
                        string[]  TileSplit = s.Split(':');
                        int       X         = Int32.Parse(TileSplit[0]);
                        int       Y         = Int32.Parse(TileSplit[1]);
                        Texture2D tx        = TextureList["bound"];
                        BoundList.Add(new Tile(X, Y, tx));
                    }
                }
            } catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
示例#18
0
 private void Start()
 {
     metaDataLayer = GetComponentInChildren <MetaDataLayer>(true);
     metaTileMap   = GetComponent <MetaTileMap>();
     try
     {
         objects = ((ObjectLayer)metaTileMap.Layers[LayerType.Objects]).Objects;
     }
     catch
     {
         Logger.LogError("CAST ERROR: Make sure everything is in its proper layer type.", Category.Matrix);
     }
 }
示例#19
0
        private void TileList_DoubleClick(object sender, EventArgs e)
        {
            if (m_parent.status.path != null)
            {
                m_parent.status.path.RemoveRange(0, TileList.SelectedIndex);
            }

            m_parent.MoveRobot(m_parent.status.path[0].Position, m_parent.status.position.facing);

            m_parent.DrawFloor();

            TileList.Refresh();
        }
示例#20
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            instance = null;
        }

        instance = this;
        if (TileList.isEmptyImageList())
        {
            TileList.SetSpriteList();
        }
    }
示例#21
0
    private void ShowMovementArea()
    {
        if (CurrentSelectedTile.Fleet.MovementPointsLeft == 0)
        {
            return;
        }

        MoveableTileList = TileList.FindAll(t => Vector3.Distance(CurrentSelectedTile.TileParent.position, t.TileParent.position) <= 2f);

        foreach (var tile in MoveableTileList)
        {
            MoveableTileObjectList.Add(Instantiate(MoveableTileObject, tile.TileParent.position, tile.TileParent.rotation) as Transform);
        }
    }
示例#22
0
        public void Load(int tileX, int tileZ, bool visible)
        {
            if (Thread.CurrentThread.Name != "Loader Process")
            {
                Trace.TraceError("Tiles.Load incorrectly called by {0}; must be Loader Process or crashes will occur.", Thread.CurrentThread.Name);
            }

            var tiles = Tiles;

            // Take the current list of tiles, evict any necessary so the new tile fits, load and add the new
            // tile to the list, and store it all atomically in Tiles.
            var tileList = new List <Tile>(tiles.List);

            while (tileList.Count >= MaximumCachedTiles)
            {
                tileList.RemoveAt(0);
            }

            // Check for 1x1 (or 8x8) tiles.
            TileName.Snap(ref tileX, ref tileZ, Zoom);
            if (tiles.ByXZ.ContainsKey(((uint)tileX << 16) + (uint)tileZ))
            {
                return;
            }

            var newTile = new Tile(FilePath, tileX, tileZ, Zoom, visible);

            if (newTile.Loaded)
            {
                tileList.Add(newTile);
                Tiles = new TileList(tileList);
                return;
            }

            // Check for 2x2 (or 16x16) tiles.
            TileName.Snap(ref tileX, ref tileZ, Zoom - 1);
            if (tiles.ByXZ.ContainsKey(((uint)tileX << 16) + (uint)tileZ))
            {
                return;
            }

            newTile = new Tile(FilePath, tileX, tileZ, Zoom - 1, visible);
            if (newTile.Loaded)
            {
                tileList.Add(newTile);
                Tiles = new TileList(tileList);
                return;
            }
        }
示例#23
0
    private void OnEnable()
    {
        try
        {
            gridGameObject = FindObjectOfType <GridSystem>().gameObject;
        }
        catch (System.NullReferenceException)
        {
            Debug.Log("Could not find Grid System, created a new Grid System");
            gridGameObject = new GameObject("Grid System");
            gridGameObject.AddComponent <GridSystem>();
        }

        tileList = Resources.Load("Tile List") as TileList;
    }
示例#24
0
 public void CreateTileList()
 {
     Tiles = new List <List <Tile> >();
     for (int i = 0; i < 4; i++)
     {
         Tiles.Add(new List <Tile>());
     }
     foreach (var TileList in Tiles)
     {
         for (int i = 0; i < 4; i++)
         {
             TileList.Add(new Tile());
         }
     }
 }
示例#25
0
    private void Start()
    {
        TileList.Init();
        TileHolder.Init();

        Rect          camR     = Utils.CameraRect();
        Rect          listR    = TileList.CalculateWorldRect();
        BoxCollider2D colldier = GetComponent <BoxCollider2D>();

        float width  = TileHolder.Width;
        float height = camR.height - TileHolder.Height;

        transform.position = new Vector3(listR.xMax + width / 2, listR.yMax - height / 2);
        colldier.size      = new Vector2(width, height);
    }
示例#26
0
        /// <summary>
        /// Converts this rectangular array of Tiles into a jagged array, for the purposes
        /// of Data Contract (DC) serialization.
        /// </summary>
        public static TileCollection Jaggedize_DC(this Tile[,] input)
        {
            TileCollection output = new TileCollection();

            output.AddRange(new TileList[input.GetLength(0)].AsEnumerable());
            for (int i = 0; i < input.GetLength(0); i++)
            {
                output[i] = new TileList();
                output[i].AddRange(new Tile[input.GetLength(1)].AsEnumerable());
                for (int j = 0; j < input.GetLength(1); j++)
                {
                    output[i][j] = input[i, j];
                }
            }
            return(output);
        }
示例#27
0
        public void TileList_should_be_ordered_independent_of_initial_order()
        {
            var tiles = new List <Tile>
            {
                new EmptyTile {
                    Location = new Location(0, 1)
                },
                new NumberTile {
                    Location = new Location(0, 0), Value = 2
                }
            };
            var sut = new TileList(Axis.Horizontal, tiles);

            sut.CanMoveTowardsZero(Direction.East).Should().BeTrue();
            sut.CanMoveTowardsZero(Direction.West).Should().BeFalse();
        }
示例#28
0
    private void AddUnitsToFleetIfFleetExists()
    {
        for (int i = 0; i < BufferedUnitList.Count; i++)
        {
            var tile = TileList.Find(t => t.Position == BufferedUnitList[i].FleetPosition);

            if (tile == null)
            {
                return;
            }

            var fleet = tile.Fleet;

            AddBufferedUnitsToFleet(fleet, BufferedUnitList[i]);
        }
    }
示例#29
0
        public void TileList_should_move_east_and_not_move_west()
        {
            var tiles = new List <Tile>
            {
                new NumberTile {
                    Location = new Location(0, 0), Value = 2
                },
                new EmptyTile {
                    Location = new Location(0, 1)
                }
            };
            var sut = new TileList(Axis.Horizontal, tiles);

            sut.CanMoveTowardsZero(Direction.East).Should().BeTrue();
            sut.CanMoveTowardsZero(Direction.West).Should().BeFalse();
        }
示例#30
0
        public void RenderTest()
        {
            var tileString = "11111111111111111303030110B0B0B1133333311B0B0B011303030110B0B0B1133333311B0B0B011303030110B0B0B1111111111111111110202021120202011020202112020201111111111111111110B0B0B1103030311B0B0B011333333110B0B0B1103030311B0B0B011333333110B0B001103030311111111111111111";
            var map        = "1111110001100011000111111";
            var list       = new TileList();

            list.Add(tileString);
            var bitmap = list[1].Render(5);

            bitmap.Save("tile.bmp");

            var mapFactory = new TileMapFactory(list);
            var tileMap    = mapFactory.GetTileMap(map, 5, 5);

            bitmap = tileMap.Render();
            bitmap.Save("map.bmp");
        }
示例#31
0
    private void NetworkMoveFleet(int fleetID, Vector2 targetTilePosition)
    {
        var fleet = FleetList.Find(f => f.ID == fleetID);

        if (fleet == null)
        {
            return;
        }

        var currentTile = TileList.Find(t => t.Fleet == fleet);
        var targetTile  = TileList.Find(t => t.Position == targetTilePosition);

        targetTile.Fleet  = fleet;
        currentTile.Fleet = null;

        fleet.MoveFleet(targetTile.TileParent.position);
    }
示例#32
0
 void Awake()
 {
     boardManager = GetComponent<HexBoardManager>();
     hexInput = GetComponent<HexInput>();
     tileList = GetComponent<TileList>();
 }
        void LoadGrid(TileList<Frostbyte.Tile> t)
        {
            TileMap = t;
            var l = t.Data;
            var tiles = l.Item2;
            foreach (var list in tiles)
            {

            }
        }
示例#34
0
 /// <summary>Set the type of this Tile</summary>
 /// <param name="type">Type of Tile.</param>
 /// <param name="objectPos">Position of Tile in world space.</param>
 /// <param name="tileList">List of Tile Prefabs.</param>
 public void SetTileType(HexTileType type, Vector3 objectPos, TileList tileList)
 {
     switch (type) {
         case HexTileType.Flat:
             SetTileObject(tileList.hexagonFlat, objectPos, true);
             break;
         case HexTileType.FlatSand:
             SetTileObject(tileList.hexagonFlatSand, objectPos, true);
             break;
         case HexTileType.Hill:
             SetTileObject(tileList.hexagonHill, objectPos, false);
             break;
         default:
             tileObject = null; isWalkable = false;
             break;
     }
 }
示例#35
0
 public void Initialize(TileList tileList)
 {
     _tileList = tileList;
     for (int i = 0; i < tiles.Length; i++) {
         if (tiles[i] != null)
             tiles[i].SetTileType(tiles[i].tileType, CalcHexPosition(tiles[i].boardPosition), _tileList);
     }
 }
示例#36
0
 /// <summary>Cache Components.</summary>
 void Awake()
 {
     tileList = GetComponent<TileList>();
     gameManager = GetComponent<GameManager>();
 }
示例#37
0
文件: Map.cs 项目: amarpersaud/Test_1
 /// <summary>
 /// Create a map
 /// </summary>
 /// <param name="tileWidth">Width in pixels of each tile</param>
 /// <param name="tileHeight">Height in pixels of each tile</param>
 /// <param name="width">Width in tiles</param>
 /// <param name="height">Height in tiles</param>
 /// <param name="tileID">Byte array of tile ids for entire map.</param>
 /// <param name="buildings">Array of buildings.</param>
 /// <param name="tileList">Name of tile list (JSON File wiith extension)</param>
 /// <param name="GlobalOffset">Screen location in map</param>
 /// <param name="GlobalZoom">Magnification</param>
 /// <param name="OffsetLimit">Limit offset to prevent moving off of the map</param>
 /// <param name="ZoomLimit">Limit magnification based on screen size to prevent seeing blank space where map should be</param>
 public Map(int tileWidth, int tileHeight, int width, int height, byte[,] tileID, Building[,] buildings, string tileList, Vector2 GlobalOffset, float GlobalZoom, Vector4 OffsetLimit, Vector2 ZoomLimit, Rectangle ViewRect)
 {
     this.tileWidth = tileWidth;
     this.tileHeight = tileHeight;
     this.width = width;
     this.height = height;
     this.tileID = tileID;
     this.Buildings = buildings;
     this.tlname = tileList;
     this.OffsetLimit = OffsetLimit;
     this.GlobalOffset = GlobalOffset;
     this.mapEntities = new Dictionary<int, Entity>();
     this.GlobalZoom = 1;
     TileList = TileList.getTileList(tileList);
     this.ZoomLimit = ZoomLimit;
     this.ViewRect = ViewRect;
 }