コード例 #1
0
ファイル: Button.cs プロジェクト: egg82/Egg82LibEnhanced
 private void onMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
     {
         if (_state != InteractableState.Down)
         {
             if (_downTexture != null)
             {
                 /*bool update = false;
                  * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
                  *      update = true;
                  * }*/
                 Texture = atlas.GetTexture(_downTexture);
                 //if (update) {
                 _hitBox.X      = 0.0d;
                 _hitBox.Y      = 0.0d;
                 _hitBox.Width  = Width;
                 _hitBox.Height = Height;
                 //}
             }
             _state = InteractableState.Down;
             Pressed?.Invoke(this, EventArgs.Empty);
         }
     }
 }
コード例 #2
0
        public void MultipleTextures_CorrectIndices()
        {
            var atlas = new TextureAtlas();

            var texture0 = atlas.AddTexture();
            var texture1 = atlas.AddTexture();
            var texture2 = atlas.AddTexture();

            Assert.AreEqual(0, texture0.Index);
            Assert.AreEqual(1, texture1.Index);
            Assert.AreEqual(2, texture2.Index);

            Assert.AreEqual(texture0, atlas.GetTexture(0));
            Assert.AreEqual(texture1, atlas.GetTexture(1));
            Assert.AreEqual(texture2, atlas.GetTexture(2));
        }
コード例 #3
0
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        JObject jsonObject = JObject.Load(reader);
        var     properties = jsonObject.Properties().ToList();
        var     path       = (string)properties[0].Value;

        return(_textureAtlas.GetTexture(path, _graphicsDevice));
    }
コード例 #4
0
        public void AddTexture()
        {
            var atlas   = new TextureAtlas();
            var texture = atlas.AddTexture();

            Assert.IsNotNull(texture);
            Assert.AreEqual(atlas, texture.Atlas);
            Assert.AreEqual(0, texture.Index);
            Assert.AreEqual(texture, atlas.GetTexture(0));
        }
コード例 #5
0
    public override GraphicsComponent ReadJson(JsonReader reader, Type objectType, GraphicsComponent existingValue, bool hasExistingValue, JsonSerializer serializer)
    {
        JObject jsonObject = JObject.Load(reader);

        string texturePath = jsonObject["TexturePath"].ToObject <string>();
        var    texture     = _textureAtlas.GetTexture(texturePath, _graphicsDevice);

        //Entity owner = jsonObject["Owner"].ToObject<Entity>();
        GraphicsComponent graphicsComponent = new GraphicsComponent(null)
        {
            Color       = jsonObject["Color"].ToObject <Color>(),
            Dimensions  = jsonObject["Dimensions"].ToObject <Point>(),
            Multiplier  = jsonObject["Multiplier"].ToObject <float>(),
            Texture     = texture,
            TexturePath = texturePath,
        };

        return(graphicsComponent);
    }
コード例 #6
0
ファイル: Button.cs プロジェクト: egg82/Egg82LibEnhanced
        //constructor
        public Button(ref TextureAtlas atlas, string normalTexture, string downTexture = null, string hoverTexture = null)
        {
            if (atlas == null)
            {
                throw new ArgumentNullException("atlas");
            }
            if (normalTexture == null)
            {
                throw new ArgumentNullException("normalTexture");
            }

            inputEngine.MouseDown += onMouseDown;
            inputEngine.MouseUp   += onMouseUp;
            inputEngine.MouseMove += onMouseMove;

            this.atlas     = atlas;
            _normalTexture = normalTexture;
            _downTexture   = downTexture;
            _hoverTexture  = hoverTexture;

            Texture        = atlas.GetTexture(normalTexture);
            _hitBox.Width  = Width;
            _hitBox.Height = Height;
        }
コード例 #7
0
 private void getNewLevel()
 {
     currentDoor.Texture = doorAtlas.GetTexture(doorNames[MathUtil.FairRoundedRandom(0, doorNames.Length - 1)]);
     getRandomStartText();
 }