示例#1
0
        public override void Update(UpdateState state)
        {
            if (_textures == null)
            {
                _textures = new Texture[] {
                    UserInterface.TextureFactory.CreateGumpTexture(_index),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 1),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 2),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 3),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 4),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 5),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 6),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 7),
                    UserInterface.TextureFactory.CreateGumpTexture(_index + 8),
                };

                Vector2 tl;
                UserInterface.TextureFactory.GetGumpSize(_index, out tl);
                Vector2 t;
                UserInterface.TextureFactory.GetGumpSize(_index + 1, out t);
                Vector2 tr;
                UserInterface.TextureFactory.GetGumpSize(_index + 2, out tr);
                Vector2 ml;
                UserInterface.TextureFactory.GetGumpSize(_index + 3, out ml);
                Vector2 m;
                UserInterface.TextureFactory.GetGumpSize(_index + 4, out m);
                Vector2 mr;
                UserInterface.TextureFactory.GetGumpSize(_index + 5, out mr);
                Vector2 bl;
                UserInterface.TextureFactory.GetGumpSize(_index + 6, out bl);
                Vector2 b;
                UserInterface.TextureFactory.GetGumpSize(_index + 7, out b);
                Vector2 br;
                UserInterface.TextureFactory.GetGumpSize(_index + 8, out br);

                _isValid =
                    tl != Vector2.Zero &&
                    t != Vector2.Zero &&
                    tr != Vector2.Zero &&
                    ml != Vector2.Zero &&
                    m != Vector2.Zero &&
                    mr != Vector2.Zero &&
                    bl != Vector2.Zero &&
                    b != Vector2.Zero &&
                    br != Vector2.Zero;

                _textureSizes = new Vector2[]{
                    tl, t, tr,
                    ml, m, mr,
                    bl, b, br
                };
            }

            if (_isDirty && _isValid)
            {
                _isDirty = false;

                Vector2 row1 = Position;
                Vector2 row2 = Position + new Vector2(0, _textureSizes[0].Y);
                Vector2 row3 = Position + new Vector2(0, _size.Y - _textureSizes[6].Y);

                Vector2 col1 = Position;
                Vector2 col2 = Position + new Vector2(_textureSizes[0].X, 0);
                Vector2 col3 = Position + new Vector2(_size.X - _textureSizes[6].X, 0);

                _positions = new Vector2[] {
                    new Vector2(col1.X, row1.Y),
                    new Vector2(col2.X, row1.Y),
                    new Vector2(col3.X, row1.Y),
                    new Vector2(col1.X, row2.Y),
                    new Vector2(col2.X, row2.Y),
                    new Vector2(col3.X, row2.Y),
                    new Vector2(col1.X, row3.Y),
                    new Vector2(col2.X, row3.Y),
                    new Vector2(col3.X, row3.Y),
                };

                float stretchX = col3.X - col2.X;
                float stretchY = row3.Y - row2.Y;

                _sizes = new Vector2[] {
                    _textureSizes[0],
                    new Vector2(stretchX, _textureSizes[1].Y),
                    _textureSizes[2],
                    new Vector2(_textureSizes[3].X, stretchY),
                    new Vector2(stretchX, stretchY),
                    new Vector2(_textureSizes[5].X, stretchY),
                    _textureSizes[6],
                    new Vector2(stretchX, _textureSizes[7].Y),
                    _textureSizes[8]
                };

                _texCoords = new Vector2[] {
                    new Vector2(_sizes[1].X / _textureSizes[1].X, 1f),
                    new Vector2(1f, _sizes[3].Y / _textureSizes[3].Y),
                    new Vector2(_sizes[4].X / _textureSizes[4].X, _sizes[4].Y / _textureSizes[4].Y)
                };
            }
        }
示例#2
0
 public override void Update(UpdateState state)
 {
     if (_texture == null)
         _texture = UserInterface.TextureFactory.CreateGumpTexture(_index);
 }
示例#3
0
 public void Update(UpdateState state)
 {
     foreach (Element element in _elements)
         element.Update(state);
 }
示例#4
0
        public void Update(UpdateState state)
        {
            DateTime now = DateTime.Now;

            if (_lastCacheClean + _cleanInterval >= now)
                return;

            _landCache.Clean();
            _lastCacheClean = now;
        }
示例#5
0
文件: Element.cs 项目: nydehi/openuo
 public abstract void Update(UpdateState state);
示例#6
0
文件: Engine.cs 项目: nydehi/openuo
        public Engine(IKernel kernel)
        {
            _kernel = kernel;
            _resouces = new List<IResourceContainer>();
            _updatables = new List<IUpdatable>();
            _renderables = new List<IRenderable>();

            IDeviceProvider deviceProvider = kernel.Get<IDeviceProvider>();

            _form = deviceProvider.RenderForm;
            _form.ResizeBegin += OnResizeBegin;
            _form.ResizeEnd += OnResizeEnd;
            _form.FormClosed += OnFormClosed;
            _form.Resize += new EventHandler(OnFormResize);
            _form.KeyDown += new KeyEventHandler(_form_KeyDown);

            _device = new DeviceEx(deviceProvider.Device.NativePointer);
            _presentParameters = deviceProvider.PresentParameters;
            _totalGameTime = TimeSpan.Zero;
            _lastFrameElapsedGameTime = TimeSpan.Zero;
            _drawState = new DrawState();
            _updateState = new UpdateState();
            _clock = new GameClock();
        }
示例#7
0
文件: Engine.cs 项目: nydehi/openuo
 private void Update(UpdateState state)
 {
     foreach (IUpdatable updatable in _updatables)
         updatable.Update(state);
 }