Exemple #1
0
    protected AudioSource CrashSound; //충돌음을 담는 변수
    //private



    //	  Use this for initialization
    protected void Start()
    {
        ////// 모든 공들이 공통적으로 초기화 해야하는 대상들
        main_scr         = GameObject.Find("GameObjects").GetComponent <Main_Script>(); //메인 스크립트 로딩
        _Sphere          = transform.gameObject;                                        //자기 자신
        CrashSound       = GetComponent <AudioSource>();                                //충돌음
        HP_prefab        = Resources.Load("Text_HP") as GameObject;                     //충돌시 HP증감 표시 글자
        pow              = new power_info(0f, 0f);                                      //힘 정보도 초기화
        cur_moving_state = moving_state.init;                                           //처음 상태
        ////// 공마다 다른 값을 가져야 할 대상들
    }
 // Use this for initialization
 void Start()
 {
     //-------------------------------------------------------------------------------------------------------------------------------------------------------
     //---------------------------------------------------------Задание всех переменных-----------------------------------------------------------------------
     //-------------------------------------------------------------------------------------------------------------------------------------------------------
     eventlog_up_button   = GameObject.Find("EL up Button").GetComponent <Button>();
     eventlog_down_button = GameObject.Find("EL down Button").GetComponent <Button>();
     Download_Resourcses("eng");
     EL_text     = GameObject.Find("EL Text").GetComponent <Text>();
     main_script = GameObject.Find("Main Background").GetComponent <Main_Script>();
     //-------------------------------------------------------------------------------------------------------------------------------------------------------
     //-------------------------------------------------------------------------------------------------------------------------------------------------------
 }
    // Use this for initialization
    void Start()
    {
        main_script        = GameObject.Find("Main Background").GetComponent <Main_Script>();
        main_screen_script = GameObject.Find("Main Screen").GetComponent <Main_screen_Script>();

        popup_text = GameObject.Find("Popup_text");

        OK_button  = GameObject.Find("Popup_OK");
        YES_button = GameObject.Find("Popup_YES");
        NO_button  = GameObject.Find("Popup_NO");
        OK_button.GetComponent <Button>().onClick.AddListener(OK_click);
        YES_button.GetComponent <Button>().onClick.AddListener(YES_click);
        NO_button.GetComponent <Button>().onClick.AddListener(NO_click);


        dropdown       = GameObject.Find("Popup_dropdown");
        OK_drop_button = GameObject.Find("Popup_drop_OK");
    }
    void GenerateMatrix(string btnText)
    {
        if (btnText == "Generate")
        {
            foreach (InputField inf in this.GetComponentsInChildren <InputField>())
            {
                DestroyObject(inf.gameObject);
            }

            row    = Convert.ToInt32(dpMatrix.captionText.text);
            column = row + 1;
            gameObject.GetComponent <GridLayoutGroup>().constraintCount = column;

            for (int i = 0; i < row * column; i++)
            {
                clone = Instantiate(cellInput, this.transform, false);
                clone.placeholder.GetComponent <Text>().text = i.ToString();
            }

            //Debug.Log(this.GetComponentsInChildren<InputField>().Length);
        }
        else if (btnText == "Solve")
        {
            origMatrix     = new double[row, row];
            constantMatrix = new double[row];
            int r = 0, c = 0, counter = 1;

            foreach (InputField inf in this.GetComponentsInChildren <InputField>())
            {
                if (counter % column == 0)
                {
                    constantMatrix[r] = Convert.ToDouble(inf.text);
                    r++;
                    c = 0;
                }
                else
                {
                    origMatrix[r, c] = Convert.ToDouble(inf.text);
                    c++;
                }
                counter++;
                Debug.Log(inf.text);
            }
            Debug.Log(printArray(origMatrix));


            Main_Script ms = new Main_Script();
            double[,] tmpMatrix = new double[origMatrix.GetLength(0), origMatrix.GetLength(1)];
            double   mainDeterminant = ms.compute(origMatrix);
            double[] solve           = new double[constantMatrix.GetLength(0)];

            for (int i = 0; i < solve.GetLength(0); i++)
            {
                Array.Copy(swapMatrixConstant(origMatrix, i, constantMatrix), 0, tmpMatrix, 0, tmpMatrix.Length);
                solve[i] = ms.compute(tmpMatrix);
                Debug.Log(solve[i]);
            }

            string output = "Main Determinant: " + mainDeterminant + "\n";
            for (int i = 0; i < tmpMatrix.GetLength(0); i++)
            {
                output += "x" + (i + 1) + " = (" + solve[i] + ")/(" + mainDeterminant + ") = " + Math.Round(solve[i] / mainDeterminant, 2) + "\n";
            }

            string appendOutput = "";

            foreach (string tIn in ms.returnArrayList())
            {
                appendOutput += tIn;
            }
            textHolder.GetComponent <Text>().text = output + "\n" + appendOutput;
        }
    }
Exemple #5
0
 public void main_script_reference(Main_Script script)
 {
     main_script = script;
 }