Example #1
0
    //Happens on the client, dragging is a local function
    public static void DroppingAnObj(int uId)
    {
        int index = GetObjIndexForUID(uId);

        if (objs[index] == null)
        {
            return;
        }

        //Is this object on any of the grids?
        for (int i = 0; i < Cl_Orders.gridObjs.Count; i++)
        {
            Vector2 gridPos = GlobalPosToGridXY(Cl_Orders.gridObjs[i], objs[index].go.transform.position);
            if (IsOnGrid(Cl_Orders.gridObjs[i], gridPos))
            {
                //Maybe it can be dropped on this grid
                if (IsGridSqValid(Cl_Orders.gridObjs[i], gridPos))
                {
                    //It can be! Yay!
                    Debug.Log("VALID DROP POINT");
                    Obj o       = objs[index];
                    Obj gridObj = Cl_Orders.gridObjs[i];

                    Effects.Bubbles(o.go.transform.position);

                    //attach it!
                    o.visualState[0] = 0;
                    o.gridPos        = gridPos;
                    Vector3 localPos = GridXYToLocalPos(gridObj, gridPos);
                    Debug.Log("GridPos: " + gridPos + ", LocalPos: " + localPos);
                    o.attachedTo          = gridObj.uId;
                    o.go.transform.parent = gridObj.go.transform;
                    o.go.transform.LocalSetX(localPos.x);
                    o.go.transform.LocalSetZ(localPos.z);                    //Snap to this point's position
                    //o.go.transform.SetAngY(gridObj.go.transform.localEulerAngles.y);

                    RegisterOnGrid(gridObj, o, gridPos); //Register this unit on its own grid
                    break;                               //Break out, as we only want this object to attach to one of the grids.
                }
            }
        }

        //Turn off all grids
        TurnOffAllGrids();
    }
Example #2
0
 /*
  *
  */
 public void KillMeDead()
 {
     //detach this obj from the world, in all ways. Don't have to actually destroy any of the GameObjects.
     Effects.Bubbles(go.transform.position);
     Destroy(go);
 }