I’m being to create mini game. Request: drag items to object by corresponding number and then drop enough items like request, it will message: You Win!
For example: if request 2, so you drag 2 items then drop 2 items to bellow object
p/s: item in middle like picture must be more items, depending on requirements of program.
do you scripts? I want to refer
Here is a simple example to get you started:
using UnityEngine;
using System.Collections;
public class drop : MonoBehaviour {
public class box { public Rect pos; public bool off;}
public Texture2D background;
public string answer;
public box[] picks;
public box[] drops;
public int xidx;
public int idx{get{return xidx;}set{
if(value==-1&&xidx>-1){check(xidx);}xidx=value;}}
public string[] dropnames = new string[]{"banannas", "carrots","peanuts","beer"};
public string[] picknames = new string[]{"monkeys", "squirels","rabbits","grandmas"};
public float sx,sy,mx,my,rx,ry;
void Start () {
background = new Texture2D (1, 1);
sx = Screen.width;
sy = Screen.height;
int i = picknames.Length;
picks = new box*;*
_ float xp = Screen.width * .2f;_
-
while(i>0){i--;*
_ picks*=new box();_
picks_.pos = new Rect(xp,sy.3f,sx*.12f,sy*.09f);
xp+=sx*.15f;}
i = dropnames.Length;
drops = new box*;
xp = Screen.width * .2f;
while(i>0){i–;
drops=new box();
drops.pos = new Rect(xp,sy.6f,sx*.12f,sy*.09f);_
xp+=sx*.15f;}}
* void OnGUI(){int i;*
_ GUI.Label (new Rect(0, 0, sx, sy * .2f), answer);
* i = drops.Length;
while (i>0) {i–;
if(!drops.off){GUI.DrawTexture(drops.pos,background);
GUI.Label(drops.pos,dropnames);}}
i = picks.Length;
while (i>0) {i–;
if(!picks.off){
GUI.DrawTexture(picks.pos,background);
GUI.Label(picks.pos,picknames);}}
}
void Update () {int i;
mx = Input.mousePosition.x;
my = sy-Input.mousePosition.y;
if (Input.GetMouseButton(0)) {
if (Input.GetMouseButtonDown (0)) {
i = picks.Length;while(i>0){i–;
if(!picks.off&&picks.pos.Contains(new Vector3(mx,my,0))){*_
rx=picks_.pos.x-mx;ry=picks*.pos.y-my;
print (“dragging:”+picknames);idx = i;break;}
}}}else{idx=-1;}if (idx > -1) {
picks[idx].pos = new Rect(mx+rx,my+ry,picks[idx].pos.width,picks[idx].pos.height);}
}
void check(int v){
int i = drops.Length;
while(i>0){i–;if(drops.pos.Contains(new Vector3(mx,my,0))){
picks[v].off = true;
answer = "User thinks that “+picknames[v]+” eat "+dropnames;print(answer);break; }
}}
}*_