Example #1
0
		public void CreateTrigger()
		{
			var trigger = new Sprite(material, new Rectangle(Vector2D.Zero, (Size)Vector2D.One))
			{
				Color = Color.Red
			};
			trigger.Add(new TimeTrigger.Data(Color.Red, Color.Gray, 1));
			trigger.Start<CollisionTrigger>().Add(new CollisionTrigger.Data(Color.White, Color.Red));
			Assert.AreEqual(Vector2D.Zero, trigger.Get<Rectangle>().TopLeft);
			Assert.AreEqual(Vector2D.One, trigger.Get<Rectangle>().BottomRight);
		}
Example #2
0
		private bool HasSomethingToRender(Sprite sprite)
		{
			var data = sprite.Get<RenderingData>();
			if (data == null)
				return false; //ncrunch: no coverage, only happens with broken material data in the Editor
			drawArea = data.DrawArea;
			uv = data.AtlasUV;
			isAtlasRotated = data.IsAtlasRotated;
			screen = ScreenSpace.Current;
			rotation = sprite.Get<float>();
			return data.HasSomethingToRender;
		}
Example #3
0
        public void CreateTrigger()
        {
            var trigger = new Sprite(material, new Rectangle(Vector2D.Zero, (Size)Vector2D.One))
            {
                Color = Color.Red
            };

            trigger.Add(new TimeTrigger.Data(Color.Red, Color.Gray, 1));
            trigger.Start <CollisionTrigger>().Add(new CollisionTrigger.Data(Color.White, Color.Red));
            Assert.AreEqual(Vector2D.Zero, trigger.Get <Rectangle>().TopLeft);
            Assert.AreEqual(Vector2D.One, trigger.Get <Rectangle>().BottomRight);
        }
Example #4
0
        public void SpriteTest()
        {
            var sprite = new Sprite(8, 8);

            sprite.Set(5, 5);
            Assert.IsTrue(sprite.Data[5, 5] == (byte)Palette.Black, "Colour was not set");

            sprite.Set(6, 6);
            Assert.IsTrue(sprite.Get(6, 6) == Palette.Black, "Colour was not set");

            sprite.Set(7, 7, Palette.Red);
            Assert.IsTrue(sprite.Get(7, 7) != Palette.Black, "Colour was set to black instead of red");
            Assert.IsTrue(sprite.Get(7, 7) == Palette.Red, "Colour was not set");
        }
Example #5
0
		public void ChangeColorIfTwoRectanglesCollide()
		{
			var sprite = new Sprite(material, new Rectangle(0.25f, 0.2f, 0.5f, 0.5f));
			sprite.Start<CollisionTrigger>().Add(new CollisionTrigger.Data(Color.Yellow, Color.Blue));
			sprite.Get<CollisionTrigger.Data>().SearchTags.Add("Creep");
			var sprite2 = new Sprite(material, new Rectangle(0.5f, 0.2f, 0.1f, 0.5f));
			sprite2.AddTag("Creep");
		}
Example #6
0
 public void MakeSecret()
 {
     this.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     //this.StickerImage.Source = Sprite.Get("unknown").Source;
     this.StickerImage.Source = (this.Entity.IsCustom) ? Sprite.Get("unknown")?.Source : this.Entity.Sprite?.DarkenedSource;
     this.StickerName.Content = this.Entity.Name;
     //this.StickerName.Content = String.Concat(Enumerable.Repeat("?", Entity.Name.Length));
     this.StickerName.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
 }
Example #7
0
 public void ChangingDrawAreaWhenPausedDrawsCorrectly()
 {
     Time.IsPaused = true;
     var sprite = new Sprite(logoMaterial, new Rectangle(0.1f, 0.1f, 0.2f, 0.2f));
     sprite.Center = new Vector2D(0.6f, 0.6f);
     AdvanceTimeAndUpdateEntities();
     Assert.AreEqual(new Vector2D(0.6f, 0.6f), sprite.Get<RenderingData>().DrawArea.Center);
     Time.IsPaused = false;
 }
 public StickerRegister_Creature()
 {
     InitializeComponent();
     StickerNewSticker.StickerImage.Source = Sprite.Get("unknown").Source;
     //StickerNewStricker.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     ComboBoxRarity.ItemsSource   = rarityOptions.Keys;
     ComboBoxGender.ItemsSource   = genderOptions.Keys;
     ComboBoxRarity.SelectedIndex = ComboBoxGender.SelectedIndex = 0;
 }
Example #9
0
        private void ComboBoxRarity_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Rarity rarity;

            if (rarityOptions.TryGetValue(ComboBoxRarity.SelectedItem.ToString(), out rarity))
            {
                StickerNewStricker.StickerFrame.Source = Sprite.Get(rarity).Source;
            }
        }
Example #10
0
        public void ChangeColorIfTwoRectanglesCollide()
        {
            var sprite = new Sprite(material, new Rectangle(0.25f, 0.2f, 0.5f, 0.5f));

            sprite.Start <CollisionTrigger>().Add(new CollisionTrigger.Data(Color.Yellow, Color.Blue));
            sprite.Get <CollisionTrigger.Data>().SearchTags.Add("Creep");
            var sprite2 = new Sprite(material, new Rectangle(0.5f, 0.2f, 0.1f, 0.5f));

            sprite2.AddTag("Creep");
        }
Example #11
0
        public void SetDrawAreaWithoutInterpolation()
        {
            var sprite = new Sprite("DeltaEngineLogoAlpha", Rectangle.Zero);

            sprite.SetWithoutInterpolation(Rectangle.One);
            sprite.SetWithoutInterpolation(sprite.renderingData);
            Assert.AreEqual(Rectangle.One, sprite.DrawArea);
            Assert.AreEqual(Rectangle.One, sprite.LastDrawArea);
            Assert.AreEqual(sprite.renderingData, sprite.Get <RenderingData>());
        }
Example #12
0
        public void ChangingDrawAreaWhenPausedDrawsCorrectly()
        {
            Time.IsPaused = true;
            var sprite = new Sprite(logoMaterial, new Rectangle(0.1f, 0.1f, 0.2f, 0.2f));

            sprite.Center = new Vector2D(0.6f, 0.6f);
            AdvanceTimeAndUpdateEntities();
            Assert.AreEqual(new Vector2D(0.6f, 0.6f), sprite.Get <RenderingData>().DrawArea.Center);
            Time.IsPaused = false;
        }         //ncrunch: no coverage end
 public PlayerInventory()
 {
     InitializeComponent();
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         SetAntiAliasing();
         TrashBin.Source = Sprite.Get("trashbin").Source;
         CoinIcon.Source = Sprite.Get("coin").Source;
         Setup();
     }
 }
Example #14
0
 public StickerRegister_Semigod()
 {
     InitializeComponent();
     God.GetAll().ForEach(x => name_x_id.Add(x.Name, x.ID));
     StickerNewStricker.StickerImage.Source = Sprite.Get("unknown").Source;
     //StickerNewStricker.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     ComboBoxRarity.ItemsSource     = rarityOptions.Keys;
     ComboBoxGender.ItemsSource     = genderOptions.Keys;
     ComboBoxRelatedGod.ItemsSource = name_x_id.Keys;
     ComboBoxRarity.SelectedIndex   = ComboBoxRelatedGod.SelectedIndex = ComboBoxGender.SelectedIndex = 0;
 }
        private void SpinButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.SpinButton.Source = Sprite.Get("redbutton_pressed").Source;
            var player = GameMaster.Player;

            if (!IsSpinning && player.Coins > 0)
            {
                IsSpinning    = true;
                player.Coins -= 1;
                Refresh();
                Spin();
            }
        }
 public StickerRegister_Titan()
 {
     InitializeComponent();
     Titan.GetAll().GetMales().ForEach(x => fatherName_x_id.Add(x.Name, x.ID));
     Titan.GetAll().GetFemales().ForEach(x => motherName_x_id.Add(x.Name, x.ID));
     StickerNewStricker.StickerImage.Source = Sprite.Get("unknown").Source;
     //StickerNewStricker.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     ComboBoxRarity.ItemsSource   = rarityOptions.Keys;
     ComboBoxGender.ItemsSource   = genderOptions.Keys;
     ComboBoxFather.ItemsSource   = fatherName_x_id.Keys;
     ComboBoxMother.ItemsSource   = motherName_x_id.Keys;
     ComboBoxRarity.SelectedIndex = ComboBoxFather.SelectedIndex = ComboBoxGender.SelectedIndex = ComboBoxMother.SelectedIndex = 0;
 }
 public Client()
 {
     GameMaster.LoadAll();
     Cache.Load();
     //Cache.DumpLog();
     InitializeComponent();
     App.ClientWindow.SetCurrentPage(new Homepage());
     this.Background = new ImageBrush(Sprite.Get("bg_oldpaper").Source);
     if (!SoundTrack.Get("st_main").IsPlaying)
     {
         SoundPlayer.StopAll("st_blacksmith");
         SoundPlayer.Instance.Play(SoundTrack.Get("st_main"), loop: true);
     }
     //TestUtil.RunAllTests();
 }
Example #18
0
 public FilterSidepanel()
 {
     FilterSettings = new FilterSettings();
     InitializeComponent();
     SetDefaultFilterSettings();
     ResetAllCheckboxes();
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         try {
             FilterChanged    += new FilterChangedEventHandler(OnFilterChanged);
             SearchIcon.Source = Sprite.Get(IconType.Search).Source;
         } catch (Exception e) {
             DebugUtils.LogError(e.Message);
         }
     }
 }
        public SlotMinigame()
        {
            InitializeComponent();
            Spins = 0;
            Slot0.FinishedSpin += Slot_FinishedSpin;
            Slot1.FinishedSpin += Slot_FinishedSpin;
            Slot2.FinishedSpin += Slot_FinishedSpin;
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                this.SpinButton.Source = Sprite.Get("redbutton_released").Source;
                this.CoinIcon.Source   = Sprite.Get("coin").Source;
                Refresh();
            }

            if (!SoundTrack.Get("st_main").IsPlaying)
            {
                SoundPlayer.StopAll("st_blacksmith");
                SoundPlayer.Instance.Play(SoundTrack.Get("st_main"), loop: true);
            }
        }
Example #20
0
        public void SpriteTestString()
        {
            var s = new Sprite(4, 4);

            s.Set(0, 0); s.Set(3, 0);
            s.Set(1, 1); s.Set(2, 1);
            s.Set(2, 2); s.Set(1, 2);
            s.Set(3, 3); s.Set(0, 3);

            var s2 = new Sprite(4, 4);

            s2.FromString(s.ToString());

            for (byte x = 0; x < 4; x++)
            {
                for (byte y = 0; y < 4; y++)
                {
                    Assert.AreEqual(s.Get(x, y), s2.Get(x, y));
                }
            }
        }
Example #21
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            ChangeState(ControlState.Compact);
            HomeButton.SetText("Home");
            QuitButton.SetText("Sair");
            AlbumButton.SetText("Álbum");
            MinigameButton.SetText("Minigame");
            SettingsButton.SetText("Configurações");
            //ShopButton.SetText("Loja de Figurinhas");
            NewStickerButton.SetText("Forja de Figurinhas");
            SaveButton.SetText("Salvar");
            GiftButton.SetText("Recompensa Diária!");

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }
            QuitButton.SetIcon(Sprite.Get(IconType.Exit));
            HomeButton.SetIcon(Sprite.Get(IconType.Home));
            MinigameButton.SetIcon(Sprite.Get(IconType.Gamepad));
            SettingsButton.SetIcon(Sprite.Get(IconType.Settings));
            NewStickerButton.SetIcon(Sprite.Get(IconType.AddItem));
            //ShopButton.SetIcon(Sprite.Get(IconType.ShoppingBasket, IconColor.White));
            AlbumButton.SetIcon(Sprite.Get(IconType.StickerCollection));
            SaveButton.SetIcon(Sprite.Get(IconType.Save));
            GiftButton.SetIcon(Sprite.Get(IconType.NewWarning));

            if (DateTime.Today > GameMaster.Player.LastGift)
            {
                GiftButton.Visibility = Visibility.Visible;
            }
            else
            {
                GiftButton.Visibility = Visibility.Hidden;
            }
        }
Example #22
0
        public void SetEntity(Entity e, Boolean overrideValidation = false)
        {
            this.Entity = e;

            if (this.Entity.IsUnlocked || overrideValidation)
            {
                this.BackgroundImage.Source = e.Background?.Source;
                this.StickerFrame.Source    = Sprite.Get(e.Rarity)?.Source;
                this.StickerImage.Source    = e.Sprite?.Source;
                this.StickerName.Content    = e.Name;
                this.StickerName.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            }
            else
            {
                this.MakeSecret();
            }
            if (this.Entity.IsCustom)
            {
                this.StickerImage.Stretch          = Stretch.Fill;
                this.StickerImage.StretchDirection = StretchDirection.Both;
                this.StickerImage.Width            = this.StickerFrame.ActualWidth;
                this.StickerImage.Height           = this.StickerFrame.ActualHeight;
            }
        }
 private void SpinButton_MouseUp(object sender, MouseButtonEventArgs e)
 {
     this.SpinButton.Source = Sprite.Get("redbutton_released").Source;
 }
        private void ButtonRegister_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Console.WriteLine("-- FLAG --");
            bool hasError = false;

            if (TextBoxName.Text == null || TextBoxName.Text == "")
            {
                TextBoxName.Background = pinkBg;
                hasError = true;
            }
            else
            {
                TextBoxName.Background = normalBg;
            }
            if (TextBoxDescription.Text == null || TextBoxDescription.Text == "")
            {
                TextBoxDescription.Background = pinkBg;
                hasError = true;
            }
            else
            {
                TextBoxDescription.Background = normalBg;
            }
            if (StickerNewSticker.StickerImage.Source == Sprite.Get("unknown").Source)
            {
                LabelTip.Foreground = redBg;
                hasError            = true;
            }
            else
            {
                LabelTip.Foreground = new SolidColorBrush(Colors.Black);
            }
            if (TextBoxDangerLevel.Text == null || TextBoxDangerLevel.Text == "")
            {
                TextBoxDangerLevel.Background = pinkBg;
                hasError = true;
            }
            else
            {
                TextBoxDangerLevel.Background = normalBg;
            }
            if (hasError)
            {
                return;
            }

            String imgGuid = Guid.NewGuid().ToString();

            File.Copy(dlg.FileName, Path.Combine(Paths.CustomSpritesDirectory, imgGuid));
            Generics.LinkedList <Sprite> spritesMetadata = JsonConvert.DeserializeObject <Generics.LinkedList <Sprite> >(File.ReadAllText(Paths.CustomSpritesMetadata));
            spritesMetadata.Add(new Sprite()
            {
                ID       = imgGuid,
                Path     = imgGuid,
                IsCustom = true
            });
            File.WriteAllText(Paths.CustomSpritesMetadata, JsonConvert.SerializeObject(spritesMetadata, Formatting.Indented));

            Generics.LinkedList <Creature> customCreatures = Creature.GetAll().Where(x => x.IsCustom).ToLinkedList();

            Creature newCustomCreature = new Creature()
            {
                Name        = TextBoxName.Text,
                Description = TextBoxDescription.Text,
                ID          = Guid.NewGuid().ToString(),
                SpriteID    = imgGuid,
                IsCustom    = true,
                DangerLevel = Int16.Parse(TextBoxDangerLevel.Text)
            };

            rarityOptions.TryGetValue(ComboBoxRarity.Text, out newCustomCreature.Rarity);
            genderOptions.TryGetValue(ComboBoxGender.Text, out newCustomCreature.Gender);

            customCreatures.Add(newCustomCreature);

            File.WriteAllText(Paths.CustomCreaturesMetadata, JsonConvert.SerializeObject(customCreatures, Formatting.Indented));
            Cache.Clear();
            Cache.Load();
            Cache.DumpLog();
            Game.GameMaster.Player.Inventory.Add(new SimpleSticker()
            {
                ItemID = newCustomCreature.ID
            });
            Game.GameMaster.SaveAll();
            App.ClientWindow.SetCurrentPage(new StickerRegister_Finished(StickerNewSticker));
        }
Example #25
0
        private void ButtonRegister_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try {
                bool hasError = false;
                if (TextBoxName.Text == null || TextBoxName.Text == "")
                {
                    TextBoxName.Background = pinkBg;
                    hasError = true;
                }
                else
                {
                    TextBoxName.Background = normalBg;
                }
                if (TextBoxDescription.Text == null || TextBoxDescription.Text == "")
                {
                    TextBoxDescription.Background = pinkBg;
                    hasError = true;
                }
                else
                {
                    TextBoxDescription.Background = normalBg;
                }
                if (StickerNewStricker.StickerImage.Source == Sprite.Get("unknown").Source)
                {
                    LabelTip.Foreground = redBg;
                    hasError            = true;
                }
                else
                {
                    LabelTip.Foreground = new SolidColorBrush(Colors.Black);
                }
                if (hasError)
                {
                    return;
                }
                String imgGuid = Guid.NewGuid().ToString();
                File.Copy(dlg.FileName, Path.Combine(Paths.CustomSpritesDirectory, imgGuid));
                Generics.LinkedList <Sprite> spritesMetadata = JsonConvert.DeserializeObject <Generics.LinkedList <Sprite> >(File.ReadAllText(Paths.CustomSpritesMetadata));
                spritesMetadata.Add(new Sprite()
                {
                    ID       = imgGuid,
                    Path     = imgGuid,
                    IsCustom = true
                });
                File.WriteAllText(Paths.CustomSpritesMetadata, JsonConvert.SerializeObject(spritesMetadata, Formatting.Indented));

                Generics.LinkedList <God> customGods = God.GetAll().Where(x => x.IsCustom).ToLinkedList();

                God newCustomGod = new God()
                {
                    Name        = TextBoxName.Text,
                    Description = TextBoxDescription.Text,
                    ID          = Guid.NewGuid().ToString(),
                    SpriteID    = imgGuid,
                    IsCustom    = true
                };

                fatherName_x_id.TryGetValue(ComboBoxFather.Text, out newCustomGod.FatherID);
                motherName_x_id.TryGetValue(ComboBoxMother.Text, out newCustomGod.MotherID);
                rarityOptions.TryGetValue(ComboBoxRarity.Text, out newCustomGod.Rarity);
                genderOptions.TryGetValue(ComboBoxGender.Text, out newCustomGod.Gender);

                customGods.Add(newCustomGod);

                File.WriteAllText(Paths.CustomGodsMetadata, JsonConvert.SerializeObject(customGods, Formatting.Indented));

                Cache.Clear();
                Cache.Load();
                Cache.DumpLog();

                Game.GameMaster.Player.Inventory.Add(new SimpleSticker()
                {
                    ItemID = newCustomGod.ID
                });

                App.ClientWindow.SetCurrentPage(new StickerRegister_Finished(StickerNewStricker));
            } catch (Exception ex) {
                DebugUtils.LogError("Error creating sticker => " + ex.Message);
            }
        }
Example #26
0
		public void SetDrawAreaWithoutInterpolation()
		{
			var sprite = new Sprite("DeltaEngineLogoAlpha", Rectangle.Zero);
			sprite.SetWithoutInterpolation(Rectangle.One);
			sprite.SetWithoutInterpolation(sprite.renderingData);
			Assert.AreEqual(Rectangle.One, sprite.DrawArea);
			Assert.AreEqual(Rectangle.One, sprite.LastDrawArea);
			Assert.AreEqual(sprite.renderingData, sprite.Get<RenderingData>());
		}