상속: Jurassic.Library.ObjectInstance
예제 #1
0
        public Person(string name, SpritesetInstance spriteset, bool destroy)
        {
#if(DEBUG)
            if (_debug1 == null)
                _debug1 = new ColorInstance(Program._engine, Color.Magenta);
            if (_debug2 == null)
                _debug2 = new ColorInstance(Program._engine, Color.Red);
#endif

            Name = name;
            DestroyOnMap = destroy;
            Speed = new Vector2f(1, 1);
            _innerSS = spriteset;

            Data = Program.CreateObject();
            _base = _innerSS.GetBase();

            _sprite = new Sprite(_innerSS.TextureAtlas.Texture);
            Mask = new Color(255, 255, 255);

            Scripts = new FunctionScript[5];

            string d = GetDirectionAt(0);
            if (!String.IsNullOrEmpty(d))
                Direction = d;
        }
예제 #2
0
        public static SpritesetInstance GetSpriteset(string filename, bool clone = false)
        {
            if (!_spritesets.ContainsKey(filename))
            {
                string path = Program.ParseSpherePath(filename, "spritesets");
                _spritesets[filename] = new SpritesetInstance(Program._engine, path);
            }

            if (clone)
                return _spritesets[filename].Clone();
            else
                return _spritesets[filename];
        }
예제 #3
0
 public static void SetPersonSpriteset(string name, SpritesetInstance instance)
 {
     Person value;
     if (PeopleTable.TryGetValue(name, out value))
     {
         value.Spriteset = instance;
     }
 }
예제 #4
0
        public SpritesetInstance Clone()
        {
            SpritesetInstance instance = new SpritesetInstance(Engine);
            instance._version = _version;
            instance._bx1 = _bx1; instance._bx2 = _bx2;
            instance._by1 = _by1; instance._by2 = _by2;
            instance._width = _width;
            instance._height = _height;
            instance._filename = _filename;

            ArrayInstance my_images = this["images"] as ArrayInstance;
            object[] images = new object[my_images.Length];
            for (var i = 0; i < my_images.Length; ++i)
            {
                images[i] = ((ImageInstance)my_images[i]).Clone();
            }
            instance["images"] = Program._engine.Array.New(images);
            instance.TextureAtlas = new TextureAtlas(TextureAtlas);

            ArrayInstance directions = this["directions"] as ArrayInstance;
            object[] dirs = new object[directions.Length];
            for (var i = 0; i < directions.Length; ++i)
            {
                ObjectInstance direction = Program.CreateObject();
                direction["name"] = ((ObjectInstance)directions[i])["name"];
                ArrayInstance frames_array = ((ObjectInstance)directions[i])["frames"] as ArrayInstance;
                object[] frames = new object[frames_array.Length];
                for (var f = 0; f < frames.Length; ++f)
                {
                    ObjectInstance frame = Program.CreateObject();
                    frame["index"] = ((ObjectInstance)frames_array[f])["index"];
                    frame["delay"] = ((ObjectInstance)frames_array[f])["delay"];
                    frames[f] = frame;
                }
                direction["frames"] = Program._engine.Array.New(frames);
                directions[i] = direction;
            }
            instance["directions"] = Program._engine.Array.New(dirs);
            instance["base"] = instance.CreateBase();

            return instance;
        }