Exemplo n.º 1
0
    public void buttonClicked(GameObject btnObj)
    {
        if (DataObj.isDp)
        {
            ExitGames.Client.Photon.Hashtable h = new ExitGames.Client.Photon.Hashtable();
            h.Add("operator", btnObj.name);
            DataObj.lbc.LocalPlayer.SetCustomProperties(h);

            gameObject.SetActive(false);
            return;
        }

        controlScript.canAddOperation = false;

        OperatorObj operatorobj = new OperatorObj();

        foreach (OperatorObj op in operators)
        {
            if (op.name.Equals(btnObj.name))
            {
                operatorobj = op;
            }
        }


        GameObject cube1 = (GameObject)Instantiate(operatorobj.operatorPrefab);

        ghostObjInstance = Instantiate(cube1, cube1.transform.position, Quaternion.identity).GetComponent <Transform>();
        ghostObjInstance.transform.localScale *= controlScript.scaleChange;
        Debug.Log(controlScript.scaleChange);
        Vector3 pivotOffsetExtra;
        bool    objPivotIsBase = controlScript.isPivotInBase(ghostObjInstance, out pivotOffsetExtra);

        if (!objPivotIsBase)
        {
            ghostObjInstance = controlScript.CreateBasePivot(ghostObjInstance, pivotOffsetExtra);
        }
        Vector3 pos = rayhit.point;

        ghostObjInstance.position = pos;

        controlScript.AlignGhostToSurface(ghostObjInstance, rayhit.normal);

        ghostObjInstance = ghostObjInstance.GetComponent <PivotHelper>().DeletePivot();

        GameObject cube = Instantiate(operatorobj.operatorPrefab, ghostObjInstance.position, ghostObjInstance.rotation);

        Destroy(ghostObjInstance.gameObject);
        Destroy(cube1);
        cube.transform.SetParent(hitobject.transform);
        cube.transform.rotation = hitobject.transform.rotation;
        //cube.transform.localScale = new Vector3(0.012f, 0.012f, 0.012f);
        cube.transform.localScale *= controlScript.scaleChange;

        string currentFloor = controlScript.gameObject.GetComponent <MapObj>().currentFloorName;

        StepDetailAction action = new StepDetailAction(cube.transform, "Operator", currentFloor, hitobject.name);

        action.createTime = System.DateTime.Now.ToString();
        action.actionName = operatorobj.name;
        CommonData storeData = controlScript.gameObject.GetComponent <CommonData>();
        StepDetail detail    = storeData.newStrategy.steps[storeData.chosenStepIndex];

        if (detail.detailActions != null)
        {
            detail.detailActions.Add(action);
        }
        else
        {
            detail.detailActions = new List <StepDetailAction>();
            detail.detailActions.Add(action);
        }

        OperatorData cubeData = cube.GetComponent <OperatorData>();

        cubeData.createTime  = action.createTime;
        cubeData.actionName  = operatorobj.name;
        cubeData.parentFloor = currentFloor;
        cubeData.actionType  = "Operator";

        stepDetailPAnel panelScript = controlScript.detailPanel.GetComponent <stepDetailPAnel>();

        panelScript.scrollView.GetComponent <DetailStepScrollview>().storeData = storeData;

        storeData.Operators.Add(cube);


        Debug.Log(JsonUtility.ToJson(storeData));
        storeData.isUpdated = true;

        //controlScript.alreadyHavepoint = false;
        this.gameObject.SetActive(false);
    }
Exemplo n.º 2
0
    public void createOperatorOnMap()
    {
        if (storedData == null)
        {
            return;
        }

        if (storedData.newStrategy.steps.Count == 0)
        {
            return;
        }
        List <StepDetailAction> detailActions = storedData.newStrategy.steps[storedData.chosenStepIndex].detailActions;

        foreach (GameObject item in storedData.Operators)
        {
            Destroy(item);
        }
        storedData.Operators = new List <GameObject>();

        if (detailActions != null && IndetailActions)
        {
            for (int i = 0; i < detailActions.Count; i++)
            {
                StepDetailAction action = detailActions[i];
                //string currentfloorName = gameObject.GetComponent<MapObj>().currentFloorName;
                if (action.parentFloor.Equals(tempCurrentFloorName) && action.actionType.Equals("Operator"))
                {
                    OperatorObj operatorobj = new OperatorObj();
                    foreach (OperatorObj op in OperatorChoosePanel.GetComponent <OperatorChoose>().operators)
                    {
                        if (op.name.Equals(action.actionName))
                        {
                            operatorobj = op;
                        }
                    }


                    GameObject parentObj = GameObject.Find(action.parentName);
                    Debug.Log("parentObj = " + parentObj);
                    GameObject cube = (GameObject)Instantiate(operatorobj.operatorPrefab);
                    cube.transform.SetParent(parentObj.transform);
                    cube.transform.localScale    = action.mainTransform.localscale;
                    cube.transform.localPosition = action.mainTransform.localposition;
                    cube.transform.localRotation = action.mainTransform.localrotation;

                    if (action.hasArrow)
                    {
                        GameObject arrow = (GameObject)Instantiate(directionArrowPrefab);
                        arrow.name = "arrow";
                        arrow.transform.SetParent(cube.transform);
                        arrow.transform.localScale    = action.directionTransform.localscale;
                        arrow.transform.localPosition = action.directionTransform.localposition;
                        arrow.transform.localRotation = action.directionTransform.localrotation;
                    }


                    OperatorData cubeData = cube.GetComponent <OperatorData>();
                    cubeData.createTime  = action.createTime;
                    cubeData.actionName  = operatorobj.name;
                    cubeData.parentFloor = action.parentFloor;
                    cubeData.actionType  = action.actionType;
                    cubeData.localscale  = action.mainTransform.localscale;

                    storedData.Operators.Add(cube);
                    storedData.isUpdated = true;
                }
            }
        }
        if (operatorCreateTime != null)
        {
            bigSizeWhenchosen(operatorCreateTime);
        }
    }