コード例 #1
0
ファイル: TileMap.cs プロジェクト: Meruem/Game02
 public Tile(int x, int y, MapGenerator.TileType tileType)
 {
     X         = x;
     Y         = y;
     TileType  = tileType;
     IsVisible = true;
 }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        SerializedObject obj = new SerializedObject(targetSet);

        obj.Update();
        EditorGUILayout.BeginVertical();
        {
            Dictionary <MapGenerator.TileType, Sprite> dictCopy = new Dictionary <MapGenerator.TileType, Sprite>(targetSet.sprites);

            foreach (var v in dictCopy)
            {
                targetSet.sprites[v.Key] = (Sprite)EditorGUILayout.ObjectField(v.Key.ToString(), v.Value, typeof(Sprite), false);
            }
        }

        if (GUILayout.Button("Create keys"))
        {
            //loop through all valid types of TileTypes
            for (int i = 1; i < (int)MapGenerator.TileType.MAX; i++)
            {
                MapGenerator.TileType t = (MapGenerator.TileType)i;

                if (!targetSet.sprites.ContainsKey(t))
                {
                    targetSet.sprites.Add(t, null);
                }
            }
        }

        obj.Update();
        EditorGUILayout.EndVertical();
    }
コード例 #3
0
    public void AddTile(Sprite sprite, MapGenerator.TileType type)
    {
        GameObject go = new GameObject("Tile " + nextX + " : " + nextY);

        tiles[nextX, nextY] = go.AddComponent <Tile>();
        tiles[nextX, nextY].SetType(type);

        SpriteRenderer sr = go.AddComponent <SpriteRenderer>();

        sr.sprite       = sprite;
        sr.sortingOrder = 0;

        go.transform.parent = transform;

        float posX = 2 - nextX;

        if (nextY % 2 == 1)
        {
            posX -= .5f;
        }

        float posY = (2 - nextY) * yPerPosition;

        go.transform.position = new Vector3(posX, posY, 0);

        NextTileStep();
    }
コード例 #4
0
 public void SetType(MapGenerator.TileType type)
 {
     this.type = type;
 }