private void ClickMovable(DrawableItems sender, MouseEventArgs e) { drawArea1.ActiveItem=sender; offset=new Point(e.X,e.Y); int x=(int)((sender.Bounds.X+sender.Bounds.X+sender.Bounds.Width)/2); int y=(int)((sender.Bounds.Y+sender.Bounds.Y+sender.Bounds.Height)/2); sender.Parent.BringItemToFront(sender); dragging=(!dragging)&sender.Enabled; }
public GameFruits() { InitializeComponent(); for(int i=0;i<((int)Config.LoggedInUser.difficulty)+2;i++) { plate[i]=new DrawableItems(); plate[i].Parent=drawArea1; plate[i].Image=global::glass.Resources.plate; plate[i].Bounds=platePositions[i]; drawArea1.Items.Add(plate[i]); } SpawnItems(); }
public GameFruits() { InitializeComponent(); for(int i=0;i<((int)Config.LoggedInUser.difficulty)+2;i++) { plate[i]=new DrawableItems(); plate[i].Parent=drawArea1; plate[i].Image=global::glass.Resources.plate; plate[i].Bounds=platePositions[i]; drawArea1.Items.Add(plate[i]); } SpawnItems(); Framework.sndPlay.SoundLocation=@"Sounds\Fruits\flyttafrukt.wav"; Framework.sndPlay.Play(); }
public static void EnterClickable(DrawableItems sender, EventArgs e) { sender.Parent.Cursor=Cursors.Hand; }
public void BringItemToFront(DrawableItems item) { Items.Remove(item); Items.Insert(0,item); Invalidate(); }
private void stubMouseEvent(DrawableItems sender, MouseEventArgs e) { }
private void stubEvent(DrawableItems sender, EventArgs e) { }
public GameClothes() { InitializeComponent(); DrawableItems d=new DrawableItems(); d.Parent=drawArea1; d.Image=global::glass.Resources.gubbe; d.Bounds=new Rectangle(250,20,300,500); drawArea1.Items.Add(d); SpawnClothes(); }
private void ClickMovable(DrawableItems sender, MouseEventArgs e) { drawArea1.ActiveItem=sender; offset=new Point(e.X,e.Y); int x=(int)((sender.Bounds.X+sender.Bounds.X+sender.Bounds.Width)/2); int y=(int)((sender.Bounds.Y+sender.Bounds.Y+sender.Bounds.Height)/2); sender.Parent.BringItemToFront(sender); dragging=(!dragging)&sender.Enabled; if((!dragging)&&(sender.Enabled)) { foreach (Places place in PlaceCollection[Config.LoggedInUser.difficulty]) { if((place.Name==goal.Name)&&(Framework.PointInPolygon(new Point(x,y),place.Polygon))) { sender.Enabled=false; Rectangle InvalidateRect=new Rectangle(sender.Bounds.X,sender.Bounds.Y,sender.Bounds.Width,sender.Bounds.Height); correct++; prgProgress.PerformStep(); drawArea1.Items.Remove(sender); if(correct>=total) { if((Config.LoggedInUser.score&((int)Framework.LevelScores.Prepositons<<(int)Config.LoggedInUser.difficulty))!=((int)Framework.LevelScores.Prepositons<<(int)Config.LoggedInUser.difficulty)) { Config.LoggedInUser.score+=(uint)Framework.LevelScores.Prepositons<<(int)Config.LoggedInUser.difficulty; Config.UpdateScore(Config.LoggedInUser); } Framework.sndPlay.SoundLocation=@"Sounds\bra.wav"; Framework.sndPlay.PlaySync(); this.Close(); }else{ SpawnItem(); Invalidate(InvalidateRect); } } } } }
private void ClickMovable(DrawableItems sender, MouseEventArgs e) { drawArea1.ActiveItem=sender; offset=new Point(e.X,e.Y); int x=(int)((sender.Bounds.X+sender.Bounds.X+sender.Bounds.Width)/2); int y=(int)((sender.Bounds.Y+sender.Bounds.Y+sender.Bounds.Height)/2); sender.Parent.BringItemToFront(sender); dragging=(!dragging)&sender.Enabled; if((!dragging)&&(sender.Enabled)) { MessageBox.Show("omg"); foreach (ClothPlaces place in PlaceCollection) { if((place.Name==goal.Name)&&(Framework.PointInPolygon(new Point(x,y),place.Polygon))) { MessageBox.Show("lol"); } } } }
void SpawnClothes() { if(Config.LoggedInUser.difficulty==Difficulty.easy) { DrawableItems d=new DrawableItems(); d.Parent=drawArea1; d.Image=trojor[Framework.rndInt(0,trojor.Length)]; d.Bounds=new Rectangle(0,0,236,185); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; d.Image=byxor[Framework.rndInt(0,byxor.Length)]; d.Bounds=new Rectangle(600,100,213,178); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; d.Image=mossor[Framework.rndInt(0,mossor.Length)]; d.Bounds=new Rectangle(600,300,87,60); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); goal=PlaceCollection[0]; } }
public fruit(DrawableItems it, fruitType ft) { Item=it; Type=ft; }
private void SpawnItems() { Fruits.Clear(); int f1=Framework.rndInt(0,fruitImg.Length); int f3=f1; int f2=f1; while(f2==f1) { f2=Framework.rndInt(0,fruitImg.Length); } while(f3==f1||f3==f2) { f3=Framework.rndInt(0,fruitImg.Length); } t1=f1;t2=f2; if (Config.LoggedInUser.difficulty== Difficulty.easy){ int r=(((int)Config.LoggedInUser.difficulty+2)*(Framework.rndInt(1,4))); for (int i = 0; i<r;i++) { DrawableItems d=new DrawableItems(); d.MouseDown+=new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); d.Parent=drawArea1; d.Image=fruitImg[f1]; d.Bounds=new Rectangle(Framework.rndInt(250,400),Framework.rndInt(100,400),100,100); Fruits.Add(new fruit(d,(fruitType)f1)); drawArea1.Items.Add(d); } }else { int r; r=(((int)Config.LoggedInUser.difficulty+2)*(Framework.rndInt(1,4))); for (int i = 0; i<r;i++) { DrawableItems d=new DrawableItems(); d.MouseDown+=new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); d.Parent=drawArea1; d.Image=fruitImg[f1]; d.Bounds=new Rectangle(Framework.rndInt(250,400),Framework.rndInt(100,400),100,100); Fruits.Add(new fruit(d,(fruitType)f1)); drawArea1.Items.Add(d); } r=(((int)Config.LoggedInUser.difficulty+2)*(Framework.rndInt(1,4))); for (int i = 0; i<r;i++) { DrawableItems d=new DrawableItems(); d.MouseDown+=new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); d.Parent=drawArea1; d.Image=fruitImg[f2]; d.Bounds=new Rectangle(Framework.rndInt(250,400),Framework.rndInt(100,400),100,100); Fruits.Add(new fruit(d,(fruitType)f2)); drawArea1.Items.Add(d); } if(Config.LoggedInUser.difficulty== Difficulty.hard) { r=Framework.rndInt(1,4); for (int i = 0; i<r;i++) { DrawableItems d=new DrawableItems(); d.MouseDown+=new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); d.Parent=drawArea1; d.Image=fruitImg[f3]; d.Bounds=new Rectangle(Framework.rndInt(250,400),Framework.rndInt(100,400),100,100); OddFruits.Add(new fruit(d,(fruitType)f3)); drawArea1.Items.Add(d); } } } }
public static void LeaveClickable(DrawableItems sender, EventArgs e) { sender.Parent.Cursor=Cursors.Default; }
private void ClickMovable(DrawableItems sender, MouseEventArgs e) { drawArea1.ActiveItem=sender; offset=new Point(e.X,e.Y); int x=(int)((sender.Bounds.X+sender.Bounds.X+sender.Bounds.Width)/2); int y=(int)((sender.Bounds.Y+sender.Bounds.Y+sender.Bounds.Height)/2); dragging=(!dragging)&sender.Enabled; if((!dragging)&&(sender.Enabled)) { //if(sender.Tag==ActiveClothes&&goal.Polygon.Contains(new Point(x,y))) { if(sender.Tag==ActiveClothes&&goal.Polygon.Contains(sender.Bounds.Location)) { sender.Bounds=new Rectangle(goal.Polygon.Location.X+16,goal.Polygon.Y+16, sender.Bounds.Width, sender.Bounds.Height); sender.Enabled=false; drawArea1.Invalidate(); ActiveClothes++; if(ActiveClothes==Clothes[Config.LoggedInUser.difficulty].Length) { if((Config.LoggedInUser.score&((int)Framework.LevelScores.Clothes<<(int)Config.LoggedInUser.difficulty))!=((int)Framework.LevelScores.Clothes<<(int)Config.LoggedInUser.difficulty)) { Config.LoggedInUser.score+=(uint)Framework.LevelScores.Clothes<<(int)Config.LoggedInUser.difficulty; Config.UpdateScore(Config.LoggedInUser); } Framework.sndPlay.SoundLocation=@"Sounds\bra.wav"; Framework.sndPlay.Play(); //MessageBox.Show("omglol"); this.Close(); }else{ goal=PlaceCollection[Clothes[Config.LoggedInUser.difficulty][ActiveClothes]]; Framework.sndPlay.SoundLocation=@"Sounds\Clothes\klapa.wav"; Framework.sndPlay.PlaySync(); Framework.sndPlay.SoundLocation=@"Sounds\Clothes\"+ClothSounds[Config.LoggedInUser.difficulty][ActiveClothes]; Framework.sndPlay.Play(); //MessageBox.Show(goal.Name+" "+goal.Polygon.X.ToString()+" "+goal.Polygon.Y.ToString()); //picBack.Bounds=goal.Polygon; //drawArea1.Controls.Add(picBack); } } } if(sender.Enabled) { sender.Parent.BringItemToFront(sender); } }
public void SpawnItem() { DrawableItems d=new DrawableItems(); Items item=ItemCollection[Framework.rndInt(0,ItemCollection.Length)]; Places place=PlaceCollection[Config.LoggedInUser.difficulty][Framework.rndInt(0,PlaceCollection[Config.LoggedInUser.difficulty].Length)]; d.Parent=drawArea1; d.Image=item.Image; d.Bounds=new Rectangle(Framework.rndInt(64,736),Framework.rndInt(500,506),d.Image.Width,d.Image.Height); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+= new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); goal=place; lblInstruction.Text="Lägg "+item.Name+item.Ending+" "+place.Name+"; "+Convert.ToString(total-correct)+" kvar"; string itemsound=item.Name+item.Ending; itemsound=itemsound.ToLower().Replace(" ","").Replace('ä','a').Replace('å','a').Replace('ö','o')+".wav"; string placesound=place.Name; placesound=placesound.ToLower().Replace(" ","").Replace('ä','a').Replace('å','a').Replace('ö','o')+".wav"; Framework.sndPlay.SoundLocation=@"Sounds\Prepositions\"+itemsound; Framework.sndPlay.PlaySync(); Framework.sndPlay.SoundLocation=@"Sounds\Prepositions\"+placesound; Framework.sndPlay.Play(); }
void SpawnClothes() { int l; if(Config.LoggedInUser.difficulty==Difficulty.easy) { DrawableItems d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=trojor[l]; d.Tag=0; d.Bounds=new Rectangle(0,0,236,185); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=byxor[l]; d.Tag=1; d.Bounds=new Rectangle(600,100,213,178); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=mossor[l]; d.Tag=2; d.Bounds=new Rectangle(600,300,87,60); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); }else if(Config.LoggedInUser.difficulty==Difficulty.normal) { DrawableItems d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=trojor[l]; d.Tag=0; d.Bounds=new Rectangle(0,0,236,185); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=strumpor[l]; d.Tag=1; d.Bounds=new Rectangle(200,510,274,38); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=byxor[l]; d.Tag=2; d.Bounds=new Rectangle(550,100,213,178); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=mossor[l]; d.Tag=3; d.Bounds=new Rectangle(20,300,87,60); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=jackor[l]; d.Tag=4; d.Bounds=new Rectangle(600,300,237,187); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); }else if(Config.LoggedInUser.difficulty==Difficulty.hard) { DrawableItems d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=tshirts[l]; d.Tag=0; d.Bounds=new Rectangle(0,0,236,180); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=trojor[l]; d.Tag=1; d.Bounds=new Rectangle(500,50,236,185); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=strumpor[l]; d.Tag=2; d.Bounds=new Rectangle(200,510,274,38); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=byxor[l]; d.Tag=3; d.Bounds=new Rectangle(600,200,213,178); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=mossor[l]; d.Tag=4; d.Bounds=new Rectangle(20,200,87,60); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); d=new DrawableItems(); d.Parent=drawArea1; l=Framework.rndInt(0,trojor.Length); d.Image=jackor[l]; d.Tag=5; d.Bounds=new Rectangle(600,400,237,187); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+=new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); } goal=PlaceCollection[0]; ActiveClothes=0; Framework.sndPlay.SoundLocation=@"Sounds\Clothes\klapa.wav"; Framework.sndPlay.PlaySync(); Framework.sndPlay.SoundLocation=@"Sounds\Clothes\"+ClothSounds[Config.LoggedInUser.difficulty][ActiveClothes]; Framework.sndPlay.Play(); }
private void MoveMovable(DrawableItems sender,MouseEventArgs e) { if(dragging&&sender.Enabled) { Point p=sender.Bounds.Location; sender.Bounds=new Rectangle(new Point(p.X+e.X-offset.X,p.Y+e.Y-offset.Y),new Size(sender.Bounds.Width,sender.Bounds.Height)); Rectangle InvalidateRect=new Rectangle(Math.Min(sender.Bounds.X,p.X),Math.Min(sender.Bounds.Y,p.Y),sender.Bounds.Width+Math.Abs(sender.Bounds.X-p.X),sender.Bounds.Height+Math.Abs(sender.Bounds.Y-p.Y)); drawArea1.Invalidate(InvalidateRect); this.Cursor=Cursors.SizeAll; } else { this.Cursor=Cursors.Default; } }
public void SpawnItem() { DrawableItems d=new DrawableItems(); Items item=ItemCollection[Framework.rndInt(0,ItemCollection.Length)]; Places place=PlaceCollection[Config.LoggedInUser.difficulty][Framework.rndInt(0,PlaceCollection[Config.LoggedInUser.difficulty].Length)]; d.Parent=drawArea1; d.Image=item.Image; d.Bounds=new Rectangle(Framework.rndInt(64,736),Framework.rndInt(500,506),d.Image.Width,d.Image.Height); //d.MouseEnter+= new DrawableItems.ItemEventHandler(Framework.EnterClickable); //d.MouseLeave+= new DrawableItems.ItemEventHandler(Framework.LeaveClickable); d.MouseDown+= new DrawableItems.ItemMouseEventHandler(ClickMovable); d.MouseMove+= new DrawableItems.ItemMouseEventHandler(MoveMovable); drawArea1.Items.Add(d); goal=place; lblInstruction.Text="Lägg "+item.Name+item.Ending+" "+place.Name+"; "+Convert.ToString(total-correct)+" kvar"; }