コード例 #1
0
ファイル: ResourceManager.cs プロジェクト: Mortup/IsoEngine
        public static PrefabContainer GetWallPrefab(int index, int side)
        {
            string currentWallPrefabPath = string.Format(wallPrefabPath, index);
            string currentWallSpritePath = string.Format(wallSpritePath, index, side);

            if (Resources.Load <GameObject>(wallPrefabPath) != null)
            {
                return(new PrefabContainer(Resources.Load <GameObject>(currentWallSpritePath)));
            }
            if (Resources.Load <Sprite>(currentWallSpritePath) != null)
            {
                PrefabContainer prefabContainer = new PrefabContainer(GetBaseWallPrefab());
                prefabContainer.spriteRenderer.sprite = GetWallSprite(index, side);

                WallOrientableSprite wallOrientableSprite = prefabContainer.gameObject.GetComponent <WallOrientableSprite>();
                wallOrientableSprite.westEastSprite   = GetWallSprite(index, 0);
                wallOrientableSprite.northSouthSprite = GetWallSprite(index, 1);
                wallOrientableSprite.invertedSide     = side == 0 ? false : true;

                return(prefabContainer);
            }

            Debug.LogErrorFormat("Couldn't find resource for wall {0} with path {1}", index, currentWallSpritePath);
            return(null);
        }
コード例 #2
0
ファイル: ResourceManager.cs プロジェクト: Mortup/IsoEngine
        public static PrefabContainer GetItemPrefab(int index, int side)
        {
            string currentItemPrefabPath = string.Format(itemPrefabPath, index);
            string currentItemSpritePath = string.Format(itemSpritePath, index, side);

            if (Resources.Load <GameObject>(currentItemPrefabPath) != null)
            {
                return(new PrefabContainer(Resources.Load <GameObject>(currentItemPrefabPath)));
            }
            if (Resources.Load <Sprite>(currentItemSpritePath) != null)
            {
                PrefabContainer prefabContainer = new PrefabContainer(GetBaseItemPrefab());
                prefabContainer.spriteRenderer.sprite = GetItemSprite(index, side);

                RegularOrientableSprite itemOrientableSprite = prefabContainer.gameObject.GetComponent <RegularOrientableSprite>();
                itemOrientableSprite.localOrientation = (Transformer.Orientation)side;
                int spriteCount = GetItemSpriteCount(index);
                itemOrientableSprite.northSprite = GetItemSprite(index, 0);

                if (spriteCount == 4)
                {
                    itemOrientableSprite.westSprite  = GetItemSprite(index, 1);
                    itemOrientableSprite.southSprite = GetItemSprite(index, 2);
                    itemOrientableSprite.eastSprite  = GetItemSprite(index, 3);
                }
                else if (spriteCount == 2)
                {
                    itemOrientableSprite.westSprite  = GetItemSprite(index, 1);
                    itemOrientableSprite.southSprite = itemOrientableSprite.northSprite;
                    itemOrientableSprite.eastSprite  = itemOrientableSprite.westSprite;
                }
                else
                {
                    itemOrientableSprite.westSprite  = itemOrientableSprite.northSprite;
                    itemOrientableSprite.southSprite = itemOrientableSprite.northSprite;
                    itemOrientableSprite.eastSprite  = itemOrientableSprite.northSprite;
                }
                return(prefabContainer);
            }

            Debug.LogErrorFormat("Couldn't find resource for item {0} with path {1} or {2}", index, currentItemSpritePath, currentItemPrefabPath);
            return(null);
        }
コード例 #3
0
ファイル: ResourceManager.cs プロジェクト: Mortup/IsoEngine
        public static PrefabContainer GetFloorPrefab(int index)
        {
            string loadPath = string.Format(floorPath, index);

            if (Resources.Load <Sprite>(loadPath) != null)
            {
                PrefabContainer prefabContainer = new PrefabContainer(GetBaseFloorPrefab());
                prefabContainer.spriteRenderer.sprite = GetFloorSprite(index);
                SingleOrientableSprite sos = (SingleOrientableSprite)prefabContainer.orientableSprite;
                sos.sprite = GetFloorSprite(index);
                return(prefabContainer);
            }
            if (Resources.Load <GameObject>(loadPath) != null)
            {
                return(new PrefabContainer(Resources.Load <GameObject>(loadPath)));
            }

            Debug.LogErrorFormat("Couldn't find resource for tile {0} with path {1}", index, loadPath);
            return(null);
        }