Exemple #1
0
    private void PlatformDataNodeVer2_OnUpdatePlatformDataNodeUI(PlatformDataNodeVer2 dataNode)
    {
        dataNode.sliderSelectedProgramNodeHeight = sliderYRange;

        // update the min/max values for slider
        dataNode.sliderSelectedProgramNodeHeight.minValue = 0;
        dataNode.sliderSelectedProgramNodeHeight.maxValue = PlatformManager.Instance.configurationData.RandomHeight;

        dataNode.txtSelectedNodeName     = txtSelectedNodeName;
        dataNode.txtSelectedNodePosition = txtSelectedNodePosition;
    }
    public void BuildPlatform()
    {
        Debug.Log("Building");
        DestroyPlatform();

        platformNodes = new GameObject[configurationData.M, configurationData.N];

        spaceX = 0;
        spaceZ = 0;

        for (int i = 0; i < configurationData.M; i++)
        {
            spaceZ = 0.0f;
            for (int j = 0; j < configurationData.N; j++)
            {
                float x = (i * 1) + spaceX;
                float z = (j * 1) + spaceZ;

                var platformBase = Instantiate(PlatformBasePref,
                                               new Vector3(x, 0, z),
                                               Quaternion.identity);

                platformBase.name = string.Format("Node[{0},{1}]", i, j);

                platformBase.AddComponent <PlatformDataNodeVer2>();

                platformNodes[i, j] = platformBase;

                PlatformDataNodeVer2 pdn = platformBase.transform.GetComponent <PlatformDataNodeVer2>();
                pdn.Program = Program;
                pdn.i       = i;
                pdn.j       = j;

                spaceZ += configurationData.deltaSpace;
            }
            spaceX += configurationData.deltaSpace;
        }

        oldM = configurationData.M;
        oldN = configurationData.N;

        if (OnPlatformManagerChanged != null)
        {
            OnPlatformManagerChanged(configurationData);
        }
    }
    // Update is called once per frame
    void Update()
    {
        // check to see if platform has been build
        if (platformNodes == null)
        {
            return;
        }

        //if (Input.GetKeyUp(KeyCode.T))
        //    SimulateTest = !SimulateTest;
        //if (Input.GetKeyUp(KeyCode.H))
        //    shade = ColorShade.GrayScale;
        //if (Input.GetKeyUp(KeyCode.R))
        //    shade = ColorShade.RedScale;
        //if (Input.GetKeyUp(KeyCode.G))
        //    shade = ColorShade.GreenScale;
        //if (Input.GetKeyUp(KeyCode.B))
        //    shade = ColorShade.BlueScale;
        //if (Input.GetKeyUp(KeyCode.E))
        //    shade = ColorShade.Random;
        //if (Input.GetKeyUp(KeyCode.W))
        //{
        //    RandomHeight += 1;
        //    txtPlatformYAxisRange.text = string.Format("{0}", RandomHeight);
        //}
        //if (Input.GetKeyUp(KeyCode.S))
        //{
        //    RandomHeight -= 1;
        //    if (RandomHeight < 0)
        //        RandomHeight = 0;
        //    txtPlatformYAxisRange.text = string.Format("{0}", RandomHeight);
        //}
        if (Input.GetKey(KeyCode.Q))
        {
            Application.Quit();
        }

        #region Object Selection
        // you can select only if in program mode/scene
        if (Program)
        {
            if (Input.GetMouseButtonUp(0))
            {
                if (IsPointerOverUIObject())
                {
                    return;
                }

                #region Screen To World
                RaycastHit hitInfo = new RaycastHit();
                bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);
                if (hit)
                {
                    #region COLOR

                    if (currentSelection != null)
                    {
                        PlatformDataNodeVer2 pdn = currentSelection.transform.GetComponent <PlatformDataNodeVer2>();
                        pdn.ResetDataNode();
                    }

                    currentSelection = hitInfo.transform.gameObject;
                    PlatformDataNodeVer2 newPdn = currentSelection.transform.GetComponent <PlatformDataNodeVer2>();
                    newPdn.SelectNode();

                    #endregion
                }
                else
                {
                    Debug.Log("No hit");
                }
                #endregion
            }
        }
        #endregion

        if (SimulateTest)
        {
            if (PlatformNodesDone())
            //for (int i = 0; i < configurationData.N; i += 1)
            {
                foreach (GameObject currentNode in platformNodes)//platformNodesGetRow(i))
                {
                    if (!currentNode.GetComponent <PlatformDataNodeVer2>().Simulate)
                    {
                        currentNode.GetComponent <PlatformDataNodeVer2>().setNextPosition(configurationData);
                    }
                }
            }
        }
    }