Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (functionCallback != null)
     {
         functionCallback.Invoke();
         functionCallback = null;
     }
 }
Exemple #2
0
 // coordinate from args is Touch screen Size
 void OnRecieveBallCollision(ArgsPosition[] args)
 {
     functionCallback += delegate {
         for (int i = 0; i < args.Length; i++)
         {
             LogicSystem.current.CreateIcon(args [i].x, args [i].y);
         }
     };
 }
Exemple #3
0
 void OnRecievePosition(ArgsPosition[] args)
 {
     functionCallback += delegate {
         for (int i = 0; i < args.Length; i++)
         {
             GameObject temp = Instantiate(ColliderCapsule, new Vector3(RectX(args [i].x), RectY(args[i].z), RectZ(args [i].y)), Quaternion.identity);
             temp.transform.localScale = new Vector3(capsuleSize, capsuleSize, capsuleSize);
             Destroy(temp, capsuleDelay);
         }
     };
 }
Exemple #4
0
    void OnRecieveTouch(ArgsPosition[] args)
    {
        //Debug.Log ("Recieve data and Trigger Event");

        functionCallback += delegate {
            for (int i = 0; i < args.Length; i++)
            {
                Instantiate(iconPrefab, new Vector3(RectX(args [i].x), iconHeight, RectZ(args [i].y)), Quaternion.identity);
                Destroy(Instantiate(exploreParticle, new Vector3(RectX(args [i].x), iconHeight, RectZ(args [i].y)), Quaternion.Euler(new Vector3(90, 0, 0))) as GameObject, 3f);
                //Debug.Log("x:" + RectX (args [i].x) + " , y:" + RectZ (args [i].y));
            }
        };
    }
Exemple #5
0
    void SendPositionToGlass(ArgsPosition[] args)
    {
        functionCallback += delegate {
            if ((Time.time - lastSendGlassTime) < secondGlassSendPeriod)
            {
                return;
            }
            lastSendGlassTime = Time.time;

            string message = "pt";
            message += "," + args.Length;
            for (int i = 0; i < args.Length; i++)
            {
                message += "," + args [i].x + "," + args [i].y + "," + args [i].z;
            }
            ServerGlass.current.SocketSend(message);
        };
    }
Exemple #6
0
    // Update is called once per frame
    void Update()
    {
        if (functionCallback != null)
        {
            functionCallback.Invoke();
            functionCallback = null;
        }

        for (int i = 0; i < usersSet.Count; i++)
        {
            UserData loc       = usersSet [i].GetComponent <UserData> ();
            Vector3  targetPos = new Vector3(DepthToSceneX(loc.depthX), userHeight, DepthToSceneZ(loc.depthY));

            SmoothMove(usersSet[i], targetPos);

            var textScore = usersSet [i].GetComponent <UserChildMethod> ().textScore;
            var vPos      = cameraWalk.WorldToScreenPoint(targetPos) + new Vector3(0, textShift, 0);

            SmoothMove(textScore.gameObject, vPos);
            //textScore.transform.position = vPos + new Vector3 (0, -90, 0);
        }

        LightSpot.transform.position = View_MapCenter = new Vector3(GetUsersCenter().x, SpotLightheight, GetUsersCenter().z);
    }
Exemple #7
0
    void OnRecieveUserPosition(ArgsPosition[] args)
    {
        functionCallback += delegate {
            int numToCreate = args.Length - usersSet.Count;
            if (numToCreate > 0)
            {
                for (int i = 0; i < numToCreate; i++)
                {
                    GameObject temp = Instantiate(userBase, new Vector3(0, -100, 0), Quaternion.identity);
                    usersSet.Add(temp);

                    //Change Color when it isn't first object
                    if (temp != usersSet[0])
                    {
                        temp.GetComponent <UserChildMethod>().SetColorRandom();
                    }
                }
            }
            if (numToCreate < 0)
            {
                for (int i = usersSet.Count; i > args.Length; i--)
                {
                    Destroy(usersSet[i - 1].GetComponent <UserChildMethod>().textScore);
                    Destroy(usersSet[i - 1]);
                    usersSet.RemoveAt(i - 1);
                }
            }

//			PositionTracking[] pts = new PositionTracking[args.Length];
//			for(int i = 0 ; i < pts.Length ; i++)
//				pts[i] = new PositionTracking(args[i]);
//			List<GameObject> remainUser;
//			List<ArgsPosition> remainArgs;


            //Step1. Get Every Object the min distance to args
            bool[] hasArgsPick = new bool[args.Length];
            for (int a = 0; a < usersSet.Count; a++)
            {
                UserData data     = usersSet[a].GetComponent <UserData>();
                float    fitMin   = float.MaxValue;
                int      fitIndex = 0;

                //Search the minimun Distance and it's Args index
                for (int b = 0; b < args.Length; b++)
                {
                    if (hasArgsPick[b])
                    {
                        continue;
                    }
                    float dis = Vector2.Distance(data.Position(), args[b].Position());
                    if (dis < fitMin)
                    {
                        fitMin   = dis;
                        fitIndex = b;
                    }
                }


//				if(pts[fitIndex].fitDistance == float.MaxValue){
//					pts[fitIndex].fitID = a;
//					pts[fitIndex].fitDistance = fitMin;
//					pts[fitIndex].hasArgsPick = true;
//				} else if(fitMin < pts[fitIndex].fitDistance) {
//					remainUser.Add(usersSet[pts[fitIndex].fitID]);
//					pts[fitIndex].fitID = a;
//					pts[fitIndex].fitDistance = fitMin;
//					pts[fitIndex].hasArgsPick = true;
//				}

                hasArgsPick[fitIndex] = true;
                usersSet[a].GetComponent <UserData>().Setup(args[fitIndex].x, args[fitIndex].y);
            }


//			for(int b = 0; b < pts.Length ; b++){
//				if(pts[b].hasArgsPick == true){
//
//				} else {
//					remainArgs.Add(args[b]);
//				}
//			}
        };
    }