public override void TmxAssetImported(TmxAssetImportedArgs args)
        {
            var map = args.ImportedSuperMap;
            var navMeshGameObject = CreateNavMeshObject(map);

            navMeshGameObject.transform.parent = map.transform;
        }
 public override void TmxAssetImported(TmxAssetImportedArgs args)
 {
     SuperObject[] superObjects = args.ImportedSuperMap.GetComponentsInChildren <SuperObject>();
     foreach (var item in superObjects)
     {
         SuperCustomProperties props = item.GetComponent <SuperCustomProperties>();
         foreach (var prop in props.m_Properties)
         {
             if (prop.m_Name == "AddComponent")
             {
                 Type componentType = Type.GetType(prop.m_Value + ",Assembly-CSharp");
                 if (componentType != null)
                 {
                     item.gameObject.AddComponent(componentType);
                 }
             }
         }
     }
 }
示例#3
0
        public override void TmxAssetImported(TmxAssetImportedArgs args)
        {
            Debug.Log("Applying import settings");
            var a = args.ImportedSuperMap;

            DisableTilemapRenderer(a.transform.Find("Grid/Solid"));
            DisableTilemapRenderer(a.transform.Find("Grid/Spikes"));

//        Transform transform = a.transform.Find("Grid/Spikes/Collision_Default");
//        if (transform != null)
//        {
//            PolygonCollider2D[] polygonColliders = transform.GetComponent<CompositeCollider2D>()
//                .GetComponentsInChildren<PolygonCollider2D>();
//            foreach (PolygonCollider2D polygonCollider in polygonColliders)
//            {
//                Vector2[] points = polygonCollider.GetPath(0);
//                if (points.Length == 4)
//                {
//                    // assume no rotation
//                    Vector2 max, min;
//                    max = min = points[0];
//                    foreach (Vector2 point in points)
//                    {
//                        max = Vector2.Max(point, max);
//                        min = Vector2.Min(point, min);
//                    }
//
//                    points[0] = new Vector2(min.x + SkinWidth, min.y + SkinWidth);
//                    points[1] = new Vector2(min.x + SkinWidth, max.y - SkinWidth);
//                    points[2] = new Vector2(max.x - SkinWidth, max.y - SkinWidth);
//                    points[3] = new Vector2(max.x - SkinWidth, min.y + SkinWidth);
//                }
//
//                polygonCollider.SetPath(0, points);
//            }
//        }
        }
示例#4
0
    public override void TmxAssetImported(TmxAssetImportedArgs args)
    {
        var map    = args.ImportedSuperMap;
        var tsxMap = map.gameObject.AddComponent <TsxMap>();

        tsxMap.grid = map.gameObject.GetComponentInChildren <Grid>();
        var objectLayer = map.gameObject.GetComponentInChildren <SuperObjectLayer>();

        if (objectLayer == null)
        {
            return;
        }
        tsxMap.objectLayer = objectLayer.gameObject.AddComponent <ObjectLayer>();

        //foreach (var layer in tsxMap.layers) {
        //    layer.GetComponent<TilemapRenderer>().material = materials.BackgroundMaterial;
        //}

        foreach (Transform child in objectLayer.transform)
        {
            if (child.GetComponent <SuperObject>() != null)
            {
                var tmxObject = child.GetComponent <SuperObject>();
                child.gameObject.AddComponent <MapEvent2D>();
                var mapEvent = child.gameObject.GetComponent <MapEvent2D>();
                mapEvent.Size       = new Vector2Int((int)tmxObject.m_Width / Map.PxPerTile, (int)tmxObject.m_Height / Map.PxPerTile);
                mapEvent.Properties = tmxObject.GetComponent <SuperCustomProperties>();
                mapEvent.Position   = new Vector2Int((int)tmxObject.m_X / Map.PxPerTile, (int)tmxObject.m_Y / Map.PxPerTile);

                var appearance = mapEvent.GetProperty(MapEvent.PropertyAppearance);
                if (appearance != null && appearance.Length > 0)
                {
                    CharaEvent chara;
                    Doll       doll;
                    if (mapEvent.GetComponent <FieldSpritesheetComponent>() == null)
                    {
                        mapEvent.gameObject.AddComponent <FieldSpritesheetComponent>();
                    }
                    if (mapEvent.GetComponent <CharaEvent>() == null)
                    {
                        chara = mapEvent.gameObject.AddComponent <CharaEvent>();
                        var dollObject = (GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath <GameObject>(DollPrefabPath));
                        doll = dollObject.GetComponent <Doll>();
                        // doll.Renderer.material = materials.ForegroundMaterial;
                        doll.transform.SetParent(mapEvent.transform);
                        chara.Doll = doll;
                    }
                    else
                    {
                        chara = mapEvent.GetComponent <CharaEvent>();
                        doll  = chara.Doll;
                    }

                    doll.transform.localPosition = Vector3.zero;

                    if (IndexDatabase.Instance().FieldSprites.GetDataOrNull(appearance) != null)
                    {
                        // it's a literal
                        chara.SetAppearanceByTag(appearance);
                    }
                    else
                    {
                        // this should be okay... it's a lua string
                    }

                    var facing = mapEvent.GetProperty("face");
                    if (facing != null && facing.Length > 0)
                    {
                        chara.Facing = OrthoDirExtensions.Parse(facing);
                    }
                }
            }
        }
    }
示例#5
0
 // Invoked when a Tmx asset import is completed (the prefab and all other objects associated with the asset have been constructed)
 public abstract void TmxAssetImported(TmxAssetImportedArgs args);
 public override void TmxAssetImported(TmxAssetImportedArgs args)
 {
     m_ImportedArgs = args;
     InstantiateMovingPlatforms();
 }