Beispiel #1
0
    private void Update()
    {
        if (updating)
        {
            GameObjectPos currentObj = objects.Peek();
            switch (bodyType)
            {
            case BodyType.Line:
                currentObj.obj.transform.position = (currentObj.startPos + fingertip.transform.position) / 2.0f;
                currentObj.obj.transform.LookAt(fingertip.transform.position);
                currentObj.obj.transform.localScale = new Vector3(0.1f, 0.1f, Vector3.Distance(currentObj.startPos, fingertip.transform.position));
                break;

            case BodyType.Ellipse:
                currentObj.obj.transform.position = (currentObj.startPos + fingertip.transform.position) / 2.0f;
                currentObj.obj.transform.LookAt(fingertip.transform.position);
                currentObj.obj.transform.localScale = new Vector3(0.1f, 0.1f, Vector3.Distance(currentObj.startPos, fingertip.transform.position));
                break;

            case BodyType.Free:
                if (Vector3.Distance(vertPositions[vertPositions.Count - 1], fingertip.transform.position) > 0.03)
                {
                    currLine.AddPoint(fingertip.transform.position);
                    vertPositions.Add(fingertip.transform.position);
                    currLine.GetComponent <MeshCollider>().sharedMesh = currLine.ml;
                }
                break;

            default:
                break;
            }
        }
    }
Beispiel #2
0
        private void PlaceObject(GameObjectPos pos, GameObject obj)
        {
            var p = pos.position.Integerize();
            var s = pos.size.Integerize();

            for (int i = 0; i < s.X; i++)
            {
                for (int j = 0; j < s.Y; j++)
                {
                    this[p + new Vector2(i, j)].Object = obj;
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Updates 'Object' property of all GameTile objects.
 /// </summary>
 public void RebaseObjects()
 {
     for (int i = 0; i < objects.Count; i++)
     {
         var ob = objects.ElementAt(i);
         var o  = ob.Value;
         var p  = new GameObjectPos(o.obj.Position, o.obj.Size);
         if (p != o.lastPos)
         {
             DisplaceObject(o.lastPos);
             PlaceObject(p, o.obj);
             objects[ob.Key] = new GameObjectFrame(o.obj, p);
         }
     }
 }
Beispiel #4
0
 private void DisplaceObject(GameObjectPos pos)
 {
     DisplaceObject(pos.position, pos.size);
 }
Beispiel #5
0
 private bool CanPlaceObject(GameObjectPos pos)
 {
     return(CanPlaceObject(pos.position, pos.size));
 }
Beispiel #6
0
 public GameObjectFrame(GameObject o)
 {
     obj     = o;
     lastPos = new GameObjectPos(o.Position, o.Size);
 }
Beispiel #7
0
 public GameObjectFrame(GameObject o, GameObjectPos p)
 {
     obj     = o;
     lastPos = p;
 }