コード例 #1
0
        public static Block Instantiate(BlockType type, Coor position)
        {
            var data = BlockDB._.Find(type);
            if (data == null)
            {
                Debug.LogError("Block for type not exists: " + type);
                return null;
            }

            var obj = (GameObject)GameObject.Instantiate(data.Prefab.gameObject, position.ToVector2(), Quaternion.identity);
            return obj.GetComponent<Block>();
        }
コード例 #2
0
        public static Block Instantiate(BlockType type, Coor position)
        {
            var data = BlockDB._.Find(type);

            if (data == null)
            {
                Debug.LogError("Block for type not exists: " + type);
                return(null);
            }

            var obj = (GameObject)GameObject.Instantiate(data.Prefab.gameObject, position.ToVector2(), Quaternion.identity);

            return(obj.GetComponent <Block>());
        }
コード例 #3
0
        public void Load(TiledSharp.Map map)
        {
            foreach (var tile in map.Layers[0].Tiles)
            {
                var        coor = new Coor(tile.X, MapHeight - tile.Y);
                GameObject go   = null;

                switch (tile.Gid)
                {
                case StartGid:
                    StartPoisition = coor;
                    break;

                case StarGid:
                {
                    var star = MapFactory.InstantiateStar(coor);
                    Stars.Add(star);
                    go = star.gameObject;
                    break;
                }

                default:
                {
                    var gid = MapHelper.MapGidToBlockType(tile.Gid);
                    if (gid.HasValue)
                    {
                        var block = MapFactory.Instantiate(gid.Value, coor);
                        go = block.gameObject;
                    }
                    break;
                }
                }

                if (go != null)
                {
                    go.transform.SetParent(transform, false);
                }
            }
        }
コード例 #4
0
        public void Load(TiledSharp.Map map)
        {
            foreach (var tile in map.Layers[0].Tiles)
            {
                var coor = new Coor(tile.X, MapHeight - tile.Y);
                GameObject go = null;

                switch (tile.Gid)
                {
                    case StartGid:
                        StartPoisition = coor;
                        break;

                    case StarGid:
                    {
                        var star = MapFactory.InstantiateStar(coor);
                        Stars.Add(star);
                        go = star.gameObject;
                        break;
                    }

                    default:
                    {
                        var gid = MapHelper.MapGidToBlockType(tile.Gid);
                        if (gid.HasValue)
                        {
                            var block = MapFactory.Instantiate(gid.Value, coor);
                            go = block.gameObject;
                        }
                        break;
                    }
                }

                if (go != null)
                {
                    go.transform.SetParent(transform, false);
                }
            }
        }
コード例 #5
0
        public static Ball InstantiateBall(Coor position)
        {
            var go = (GameObject)GameObject.Instantiate(LevelDB._.Ball.gameObject, position.ToVector2(), Quaternion.identity);

            return(go.GetComponent <Ball>());
        }
コード例 #6
0
        public static Star InstantiateStar(Coor position)
        {
            var go = (GameObject)GameObject.Instantiate(LevelDB._.Star.gameObject, position.ToVector2(), Quaternion.identity);

            return(go.GetComponent <Star>());
        }
コード例 #7
0
 public static Star InstantiateStar(Coor position)
 {
     var go = (GameObject)GameObject.Instantiate(LevelDB._.Star.gameObject, position.ToVector2(), Quaternion.identity);
     return go.GetComponent<Star>();
 }
コード例 #8
0
 public static Ball InstantiateBall(Coor position)
 {
     var go = (GameObject)GameObject.Instantiate(LevelDB._.Ball.gameObject, position.ToVector2(), Quaternion.identity);
     return go.GetComponent<Ball>();
 }