Exemple #1
0
 public void ScaleObject()
 {
     if (currentId == -1)
     {
         //ошибка о том, что объект не выбран
         errEngine.SetError("Object not selected");
     }
     else
     {
         try
         {
             inputParams = paramPanelLogic.GetParameters();
             for (int i = 0; i < childList.Count; i++)
             {
                 objLogic = childList[i].GetComponent <ObjectLogic>();
                 if (objLogic.GetID() == currentId)
                 {
                     objLogic.ScaleObject(inputParams);
                     Debug.Log("Scaled " + currentId + " on " + inputParams.x + " " + inputParams.y + " " + inputParams.z);
                     break;
                 }
             }
         }
         catch (System.Exception)
         {
             errEngine.SetError("Wrong values");
         }
     }
 }
Exemple #2
0
 public void DeleteObject()
 {
     if (currentId == -1)
     {
         //ошибка о том, что объект не выбран
         errEngine.SetError("Object not selected");
     }
     else
     {
         //определение текущего объекта
         for (int i = 0; i < childList.Count; i++)
         {
             objLogic = childList[i].GetComponent <ObjectLogic>();
             if (objLogic.GetID() == currentId)
             {
                 Debug.Log("Removed " + currentId);
                 objLogic.SetChecking(false);
                 objLogic.DestroyObject();
                 childList.Remove(childList[i]);
                 ResetCurrentID();
                 break;
             }
         }
     }
 }
Exemple #3
0
 void Start()
 {
     waterQuad = GameObject.Find("WaterSurface");
     materialCubeMap.shader = Shader.Find("WaterReflectShader");
     objectLogic            = new ObjectLogic(this);
     rowSize = texture1.width;
     colSize = texture1.height;
 }
    Vector3 rotateVector;                       //вектор, на который необходимо повернуть объект, которому прикреплены направляющие

    void OnMouseDown()
    {
        //если зажат "пробел", то объект будет масштабироваться
        if (Input.GetKey(KeyCode.Space))
        {
            currentMode = CurrentMode.scale;
        }
        //если зажать "левый Ctrl", то объект будет вращаться
        else if (Input.GetKey(KeyCode.LeftControl))
        {
            currentMode = CurrentMode.rotate;
        }
        //если не зажато ничего, то объект будет перемещаться
        else
        {
            currentMode = CurrentMode.move;
        }
        try
        {
            attachedInstance = axisController.GetAttachedInstance();
            objLogic         = attachedInstance.GetComponent <ObjectLogic>();
        }
        catch (System.Exception e)
        {
            //errEngine.SetError(e.Message);
            errEngine.SetError("Error. There is no attached object");
        }

        Debug.Log(gameObject.name);
        //для каждой оси смещение относительно центра родительского элемента рассчитывается отдельно
        if (currentAxis == CurrentAxis.xAxis)
        {
            centerShift = new Vector3(thisCollider.bounds.size.x / 2, 0, 0);
        }
        else if (currentAxis == CurrentAxis.yAxis)
        {
            centerShift = new Vector3(0, thisCollider.bounds.size.y / 2, 0);
        }
        else if (currentAxis == CurrentAxis.zAxis)
        {
            centerShift = new Vector3(0, 0, thisCollider.bounds.size.z / 2);
        }

        savedPosition = gameObject.transform.position;
        screenPoint   = Camera.main.WorldToScreenPoint(transform.position);

        offset           = transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
        curScreenPoint.x = Input.mousePosition.x;
        curScreenPoint.y = Input.mousePosition.y;
        curScreenPoint.z = screenPoint.z;
        prevPosition     = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
        rotateVector     = attachedInstance.transform.eulerAngles;
    }
Exemple #5
0
 /// <summary>
 /// перекраска выбранного объекта и выбранного до этого
 /// </summary>
 public void Recolor()
 {
     for (int i = 0; i < childList.Count; i++)
     {
         objLogic = childList[i].GetComponent <ObjectLogic>();
         if (objLogic.GetID() == oldId)
         {
             objLogic.SetChecking(false);
         }
         if (objLogic.GetID() == currentId)
         {
             objLogic.SetChecking(true);
         }
     }
 }
Exemple #6
0
        protected void AddObjectButton_Click(object sender, EventArgs e)
        {
            if (ObjectTypeDropDownList.SelectedValue == null || ObjectTypeDropDownList.SelectedValue.Length == 0)
            {
                return;
            }
            if (BubbleDropDownList.SelectedValue == null || BubbleDropDownList.SelectedValue.Length == 0)
            {
                return;
            }
            ObjectType  objectType  = ObjectLogic.GetObjectType(new Guid(ObjectTypeDropDownList.SelectedValue));
            Bubble      bubble      = BubbleLogic.GetBubble(new Guid(BubbleDropDownList.SelectedValue));
            CloudObject cloudObject = ObjectLogic.AddObject(DaemonHttpContext.LoggedInParticipant, objectType, bubble);

            Response.Redirect(Request.Url.OriginalString);
        }
    //
    // Initialize Game Data
    //
    // Game Data can be initialized in the Start method.
    // Start is called on the frame when the script is enabled.
    //
    // Here we will instantiate all our objects in the scene and populate them
    // with our game data.
    //
    void Start()
    {
        // Initialize with the file path which is a resource in the
        // Unity Scene hence the no json file extension.
        if (GDEDataManager.Instance.Init(DataFilePath))
        {
            Dictionary <string, object> objectData;

            // Get the square's data
            GDEDataManager.Instance.Get("square", out objectData);
            GameObject  cube      = GameObject.CreatePrimitive(PrimitiveType.Cube);
            ObjectLogic cubeLogic = cube.AddComponent <ObjectLogic>();
            cubeLogic.Data = objectData;
            cubeLogic.Init();

            // Get the circle's data
            GDEDataManager.Instance.Get("circle", out objectData);
            GameObject  circle      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            ObjectLogic circleLogic = circle.AddComponent <ObjectLogic>();
            circleLogic.Data = objectData;
            circleLogic.Init();

            // Init all of our GUITexts
            Dictionary <string, object> guiTextDataList;
            GDEDataManager.Instance.GetAllDataBySchema("GuiText", out guiTextDataList);
            foreach (KeyValuePair <string, object> pair in guiTextDataList)
            {
                GameObject guiText = new GameObject(pair.Key);
                guiText.AddComponent <GUIText>();

                GUITextSettings textSettings = guiText.AddComponent <GUITextSettings>();
                textSettings.Data = pair.Value as Dictionary <string, object>;
                textSettings.Init();
            }
        }
        else
        {
            Debug.Log("GDEManager not initialized!");
        }
    }
Exemple #8
0
    public void AddObject()
    {
        if (childList.Count == 10)
        {
            errEngine.SetError("Error.Max limit.");
        }
        else
        {
            //создание нового объекта префаба
            parentItem.SetActive(true);
            //сдвиг с учетом размера префаба
            //GameObject currentChild = Instantiate(parentItem, parentItem.transform.position + new Vector3(2 * parentItemCollider.bounds.size.x * objectId, 0, 0), parentItem.transform.rotation);
            GameObject currentChild;
            if (objectId == 0)
            {
                currentChild = Instantiate(parentItem);
                Collider tempCollider = currentChild.GetComponent <Collider>();
                colliderValues.x = tempCollider.bounds.size.x;
                colliderValues.y = tempCollider.bounds.size.y;
                colliderValues.z = tempCollider.bounds.size.z;
            }
            else
            {
                currentChild = Instantiate(parentItem, parentItem.transform.position + new Vector3(2 * colliderValues.x * objectId, 0, 0), parentItem.transform.rotation);
            }

            //сдвиг без учета размера префаба - если размер префаба больше задаваемого смещения - объекты "слипнутся"
            //GameObject currentChild = Instantiate(parentItem, parentItem.transform.position + new Vector3(3 * (objectId), 0, 0), parentItem.transform.rotation);
            childList.Add(currentChild);
            objLogic = currentChild.GetComponent <ObjectLogic>();
            objLogic.SetID(objectId);
            Debug.Log("Created " + objectId);

            objectId++;
            parentItem.SetActive(false);
        }
    }
Exemple #9
0
        protected void AddObjectTypeButton_Click(object sender, EventArgs e)
        {
            ObjectType objectType = ObjectLogic.AddObjectType(DaemonHttpContext.LoggedInParticipant);

            Response.Redirect(Request.Url.OriginalString);
        }