| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- using Client.MirControls;
- using Client.MirGraphics;
- using Client.MirNetwork;
- using Client.MirSounds;
- using C = ClientPackets;
- namespace Client.MirScenes.Dialogs
- {
- public sealed class RollDialog : MirControl
- {
- private readonly MirAnimatedControl _animation;
- private readonly MirImageControl _image;
- private int _currentLoop;
- private int _type;
- private string _npcPage;
- private int _result;
- private bool _rolled;
- private bool _rolling;
- public RollDialog()
- {
- Movable = false;
- Sort = true;
- _animation = new MirAnimatedControl
- {
- Parent = this,
- Index = 0,
- Library = Libraries.Prguse2,
- UseOffSet = true,
- Location = new Point(0, 0),
- Visible = true
- };
- _animation.AfterAnimation += (o, e) =>
- {
- switch (_type)
- {
- case 0: //Die
- {
- if (_currentLoop < 5)
- {
- _currentLoop++;
- return;
- }
- _image.Visible = true;
- _animation.Visible = false;
- _animation.Animated = false;
- ReturnResult();
- }
- break;
- case 1: //Yut
- {
- _image.Visible = true;
- _animation.Visible = false;
- _animation.Animated = false;
- ReturnResult();
- }
- break;
- }
-
- };
- _image = new MirImageControl
- {
- Parent = this,
- Index = 0,
- Library = Libraries.Prguse2,
- UseOffSet = true,
- Location = new Point(0, 0),
- Visible = false
- };
- _image.Click += _image_Click;
- }
- public void Setup(int type, string page, int result, bool autoRoll)
- {
- _type = type;
- _npcPage = page;
- _result = result;
- _rolled = false;
- _currentLoop = 0;
- Visible = true;
- switch (type)
- {
- case 0: //Die
- {
- Size = new Size(65, 65);
- Location = new Point((Settings.ScreenWidth / 2) - 38, (Settings.ScreenHeight / 2) - 40);
- _image.Index = 282;
- _image.Library = Libraries.Prguse;
- _image.Visible = true;
- _animation.Loop = true;
- _animation.Visible = false;
- _animation.Animated = false;
- _animation.OffSet = 0;
- }
- break;
- case 1: //Yut
- {
- Size = new Size(180, 130);
- Location = new Point((Settings.ScreenWidth / 2) - 90, (Settings.ScreenHeight / 2) - 65);
- _image.Index = 2581;
- _image.Library = Libraries.Items;
- _image.Visible = true;
- _animation.Loop = false;
- _animation.Visible = false;
- _animation.Animated = false;
- _animation.OffSet = 0;
- }
- break;
- }
- if (autoRoll)
- {
- Roll();
- }
- }
- private void Roll()
- {
- Visible = true;
- _rolling = true;
- switch (_type)
- {
- case 0: //Die
- {
- _image.Index = 281 + _result;
- _image.Library = Libraries.Prguse;
- _image.Visible = false;
- _animation.Index = 290;
- _animation.Library = Libraries.Prguse;
- _animation.AnimationCount = 4;
- _animation.AnimationDelay = 100;
- _animation.Loop = true;
- _animation.Visible = true;
- _animation.Animated = true;
- _animation.OffSet = 0;
- SoundManager.PlaySound(10600);
- }
- break;
- case 1: //Yut
- {
- _image.Index = 2587 + _result;
- _image.Library = Libraries.Items;
- _image.Visible = false;
- _animation.Index = 2581;
- _animation.Library = Libraries.Items;
- _animation.AnimationCount = 6;
- _animation.AnimationDelay = 100;
- _animation.Loop = false;
- _animation.Visible = true;
- _animation.Animated = true;
- _animation.OffSet = 0;
- SoundManager.PlaySound(10601);
- }
- break;
- }
- }
- private void _image_Click(object sender, EventArgs e)
- {
- if (_rolling) return;
- if (_rolled)
- {
- Hide();
- return;
- }
- Roll();
- }
- private void ReturnResult()
- {
- _rolling = false;
- _rolled = true;
- if (CMain.Time <= GameScene.NPCTime) return;
- GameScene.NPCTime = CMain.Time + 5000;
- Network.Enqueue(new C.CallNPC { ObjectID = GameScene.NPCID, Key = $"[{_npcPage}]" });
- }
- }
- }
|