コード例 #1
0
    public GameObject SpOneNumber(string Name)       //生產數字
    {
        GameObject a = MyCalculate.SpObj(Number, transform, Vector3.zero);

        ChIm(a.GetComponent <UISprite> (), Name);
        return(a);
    }
コード例 #2
0
    public void Load_Lv_Data(G0_Lv_Data data)
    {
        //決定這場要哪些地點
        int [] rD = new int [Now_Lv_Data.All_Target.Length];        //每個地點抽到的機率
        for (int i = 0; i < rD.Length; i++)
        {
            rD [i] = 1;
        }
        Now_Traget_Nobs = Dice <int> .GetNotRepeatingInts(Now_Lv_Data.N, rD);

        UI.Map.sprite = data.Map_Im;

        All_Photo = new List <G0_Photo_UICon> ();
        G0_Photo_UICon.AllPhoto = null;
        for (int i = 0; i < Now_Traget_Nobs.Length; i++)
        {
            int            Nob = Now_Traget_Nobs [i];
            G0_Photo_UICon r   = MyCalculate.SpObj(UI.Photo_Obj, UI.Photo_Parent.transform, Vector3.zero).GetComponent <G0_Photo_UICon> ();
            r.Load_Target_Data(data.All_Target [Nob]);
            All_Photo.Add(r);
        }

        All_Target = new List <G0_Target_UICOn> ();
        G0_Target_UICOn.AllTarget = null;
        for (int i = 0; i < data.All_Target.Length; i++)
        {
            G0_Target_Data  Target = data.All_Target [i];
            G0_Target_UICOn r      = MyCalculate.SpObj(UI.Traget_Obj, UI.Target_Parent.transform, (Vector2)Target.Pot).GetComponent <G0_Target_UICOn> ();
            r.Data = Target;
            All_Target.Add(r);
        }
    }
コード例 #3
0
    /// <summary>
    /// 開啟或關閉某個物件 並啟動事件
    /// </summary>
    public void OnOffObj(int n, bool OnOff)
    {
        n = MyCalculate.SaladModInt(n, AllObj.Length);
        if (AllObj [n].obj == null)
        {
            return;
        }

        if (AllObj [n].Open == OnOff)
        {
            return;
        }
        AllObj [n].obj.SetActive(OnOff);
        if (OnOff)
        {
            if (AllObj [n].EnterEvent != null)
            {
                AllObj [n].EnterEvent.Invoke();
            }
        }
        else
        {
            if (AllObj [n].ExitEvent != null)
            {
                AllObj [n].ExitEvent.Invoke();
            }
        }
    }
コード例 #4
0
    public void  Open(int Nob)
    {
        string _Nob = Nob.ToString();

        int [] NobInt = new int [_Nob.Length];
        for (int i = 0; i < NobInt.Length; i++)
        {
            NobInt [i] = "0123456789".IndexOf(_Nob [i]);
            ObjArray OA = MyCalculate.SpObj(NobObj.gameObject, m_Nob.transform, Vector3.zero).GetComponent <ObjArray> ();
            OA.OnOnlyObjs(NobInt [i]);
            OA.gameObject.SetActive(true);
        }

        m_Nob.GetComponent <Tween_Color> ().Del += (f) => {
            Image [] Ims = GetComponentsInChildren <Image> ();
            foreach (Image i in Ims)
            {
                i.color = m_Nob.GetComponent <Tween_Color> ().NowColor;
            }
        };
        m_Nob.GetComponent <Tween_Color> ().End_Del += () => {
            Destroy(gameObject);
        };
        m_Nob.SetActive(true);
        m_Nob.GetComponent <Tween_Color> ().Play(true);
    }
コード例 #5
0
 public void Open(int MaxHP)
 {
     for (int i = 1; i < MaxHP; i++)
     {
         MyCalculate.SpObj(HPObj, transform, Vector3.zero, i.ToString());
     }
     SetObj();
     HP = MaxHP;
 }
コード例 #6
0
    public void Sp_Obj(bool LR, bool IsOK)
    {
        Vector3 StartPot = AllObj [LR ? 1 : 0].obj.transform.localPosition;
        int     Y        = IsOK ? Random.Range(8, 10) : Random.Range(3, 7);

        Vector3 Obj_v = new Vector2(Random.Range(1, 11), Y);

        Obj_v.x *= LR ? -1 : 1;

        MyCalculate.SpObj(G1_Obj [Random.Range(0, G1_Obj.Length)].gameObject, transform, StartPot).GetComponent <G1_Obj> ().Open(Obj_v);
    }
コード例 #7
0
        internal static void SimpleLambdas()
        {
            MyCalculate calc = (x, y) => x + y;

            Console.WriteLine($"Sum is {calc(3, 4)}");

            // Redefine the same delegate with different lambda expression.
            calc = (x, y) => x * y;

            Console.WriteLine($"Product is {calc(3, 4)}");
        }
コード例 #8
0
    void Start()
    {
        UI.d.Start_Del += (v) => {
            UI.d.Update_Del(v);
        };
        UI.d.Update_Del += (v) => {
            UI.T.transform.position = v;
            Now_TPot = UI.T.transform.localPosition;
        };

        Now_User = MyCalculate.SpObj(Users [G0_MainUI._.UI.UserSet.UI.SexButt.Nob], transform, Vector3.one).GetComponent <G0_UserPlayUICon> ();
    }
コード例 #9
0
 public void SetP(int N)
 {
     if (N == 0)
     {
         MyCalculate.SpObj(NobObj.AllObj [0].obj, PUI.transform, Vector3.zero);
         return;
     }
     for (; N >= 1;)
     {
         MyCalculate.SpObj(NobObj.AllObj [N % 10].obj, PUI.transform, Vector3.zero);
         N /= 10;
     }
 }
コード例 #10
0
        internal static void LambdaExpressionWithMultipleStatements()
        {
            MyCalculate calc = (x, y) =>
            {
                Console.WriteLine("Adding numbers");
                return(x + y);
            };
            int result = calc(3, 4);

            // Displays
            // Adding numbers

            Console.WriteLine($"Product is {result}");
        }
コード例 #11
0
    public void OpenBox()
    {
        int n = GetAInt();

        if (n < 0)
        {
            // print ("所有箱子都生成了");
            return;
        }

        G0_Box _Box = MyCalculate.SpObj(Box, transform, Vector3.one).GetComponent <G0_Box> ();

        _Box.End_Del += () => { AllInt [n] = 1; };
        _Box.Open(AllT [n].transform.localPosition);
        AllInt [n] = 0;
    }
コード例 #12
0
        private void tabPage5_Paint(object sender, PaintEventArgs e)
        {
            if (status5 == 1)
            {
                Graphics g = e.Graphics;
                //z轴挠度
                for (int i = 0; i <= 100; i++)
                {
                    double x = a * i / 100.0;
                    myAverage[i] = -x;
                }
                for (int i = 101; i <= 400; i++)
                {
                    double x = a * i / 100.0;
                    myAverage[i] = 1 / 3.0 * (x - 4 * a);
                }
                for (int i = 401; i <= 500; i++)
                {
                    myAverage[i] = 0;
                }
                for (int i = 0; i <= 500; i++)
                {
                    myMyAverage[i] = my[i] * myAverage[i];
                }
                double I        = (pi * diameter1 * diameter1 * diameter1 * diameter1) / 64;
                double bendingZ = (MyCalculate.DefiniteIntegral(myMyAverage, 0, 500) * a / 100) / (E * I);
                g.DrawString("Δz= " + Math.Round(bendingZ * 1000, 3) + " mm", font1, brush1, 100, 100);

                //y轴挠度
                for (int i = 0; i <= 500; i++)
                {
                    mzAverage[i]   = myAverage[i];
                    mzMzAverage[i] = mz[i] * mzAverage[i];
                }
                double bendingY = (MyCalculate.DefiniteIntegral(mzMzAverage, 0, 500) * a / 100) / (E * I);
                g.DrawString("Δy= " + Math.Round(bendingY * 1000, 3) + " mm", font1, brush1, 100, 140);

                //总挠度
                double bendingXY = Math.Sqrt(bendingZ * 1000 * bendingZ * 1000 + bendingY * 1000 * bendingY * 1000);
                g.DrawString("Δ= " + Math.Round(bendingXY, 3) + " mm", font1, brush1, 100, 180);
            }
        }
コード例 #13
0
    public void OpenLvUp(int Lv)
    {
        GameObject g = MyCalculate.SpObj(LvUpObjs [Lv], transform, LVUpDice.GetAT().transform.localPosition);

        g.name = "LvUp_" + Lv;
    }
コード例 #14
0
        private void tabPage6_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            int      x = 0;

            switch (comboBox1.SelectedIndex)
            {
            case 0: x = 0; break;

            case 1: x = 50; break;

            case 2: x = 150; break;

            case 3: x = 300; break;

            case 4: x = 350; break;

            case 5: x = 450; break;

            case 6: x = 500; break;
            }
            g.DrawString("Mx= " + Math.Round(mx[x], 2) +
                         " N•m     My= " + Math.Round(my[x], 2) + " N•m     Mz= " + Math.Round(mz[x], 2) + " N•m",
                         font1, brush1, 100, 100);
            if (status6 == 1)
            {
                double W    = (pi * diameter2 * diameter2 * diameter2) / 32;
                double aMax = (Math.Sqrt(my[x] * my[x] + mz[x] * mz[x])) / W;
                double Wp   = (pi * diameter2 * diameter2 * diameter2) / 16;
                double tMax = mx[x] / Wp;
                double tm   = tMax / 2;
                double ta   = tMax / 2;
                double na   = (a_1 * Ea * B) / (Ka * aMax);
                double nt   = t_1 / (Kt * ta / (Et * B) + sensitivity * tm);
                double nat  = (na * nt) / Math.Sqrt(na * na + nt * nt);
                double a_r3 = Math.Sqrt(MyCalculate.SumOfSquaresMxyz(x)) / W;
                double nat1 = a_s / a_r3;
                string isOk = "";
                if (double.IsNaN(nat) || double.IsNaN(nat1))
                {
                    if (nt > safeN)
                    {
                        isOk = "是";
                    }
                    else
                    {
                        isOk = "否";
                    }
                }
                else
                {
                    if (nat > safeN && nat1 > safeN)
                    {
                        isOk = "是";
                    }
                    else
                    {
                        isOk = "否";
                    }
                }

                g.DrawString("σmax= " + Math.Round(aMax / 1000000, 2) + " Mpa" + "     τmax= " + Math.Round(tMax / 1000000, 2) + " Mpa\n\n" +
                             "Na= " + Math.Round(na, 2) + "    Nt= " + Math.Round(nt, 2) + "    Nat= " + Math.Round(nat, 2) + "    Nat′= " + Math.Round(nat1, 2) +
                             "\n\n该截面是否满足强度要求: " + isOk,
                             font2, brush1, 100, 300);
                status6 = 0;
            }
        }
コード例 #15
0
        private void tabPage4_Paint(object sender, PaintEventArgs e)
        {
            Graphics g    = e.Graphics;
            int      maxX = 0;

            int[]    tempDiameter = new int[5];
            double[] diameter     = new double[5];
            double   maxDiameter;
            float    x1 = 100, y1 = 10;

            for (int i = 0; i <= 500; i += 100)
            {
                if (MyCalculate.IsMxMyMzMore(i, maxX))
                {
                    maxX = i;
                }
            }
            int maxDiameterIndex;

            if ((maxX >= 0 && maxX <= 50) || (maxX >= 450 && maxX <= 500))
            {
                maxDiameterIndex = 4;
            }
            else if (maxX > 50 && maxX <= 150)
            {
                maxDiameterIndex = 3;
            }
            else if (maxX > 150 && maxX <= 350)
            {
                maxDiameterIndex = 2;
            }
            else
            {
                maxDiameterIndex = 1;
            }
            g.DrawString("危险截面的横坐标:  x=" + Math.Round(a * maxX / 100.0, 2) + "m     截面直径为Φ" + maxDiameterIndex + "\n\n设计直径:",
                         font1, brush1, x1, y1);

            //设计直径1
            maxX = 350;
            for (int i = 351; i <= 450; i++)
            {
                if (MyCalculate.IsMxMyMzMore(i, maxX))
                {
                    maxX = i;
                }
            }
            maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0);
            diameter[1] = maxDiameter * 1000;
            g.DrawString("Φ1≥" + Math.Round(maxDiameter * 1000, 2) + "mm    在 x=" + maxX * a / 100.0 + "m 处应力最大",
                         font1, brush1, x1, y1 + 80);

            //设计直径2
            maxX = 150;
            for (int i = 151; i <= 350; i++)
            {
                if (MyCalculate.IsMxMyMzMore(i, maxX))
                {
                    maxX = i;
                }
            }
            maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0);
            diameter[2] = maxDiameter * 1000;
            g.DrawString("Φ2≥" + Math.Round(maxDiameter * 1000, 2) + "mm    在 x=" + maxX * a / 100.0 + "m 处应力最大",
                         font1, brush1, x1, y1 + 120);

            //设计直径3
            maxX = 50;
            for (int i = 51; i <= 150; i++)
            {
                if (MyCalculate.IsMxMyMzMore(i, maxX))
                {
                    maxX = i;
                }
            }
            maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0);
            diameter[3] = maxDiameter * 1000;
            g.DrawString("Φ3≥" + Math.Round(maxDiameter * 1000, 2) + "mm    在 x=" + maxX * a / 100.0 + "m 处应力最大",
                         font1, brush1, x1, y1 + 160);

            //设计直径4
            maxX = 0;
            for (int i = 1; i <= 50; i++)
            {
                if (MyCalculate.IsMxMyMzMore(i, maxX))
                {
                    maxX = i;
                }
            }
            for (int i = 450; i <= 500; i++)
            {
                if (MyCalculate.IsMxMyMzMore(i, maxX))
                {
                    maxX = i;
                }
            }
            maxDiameter = Math.Pow((32 * Math.Sqrt(MyCalculate.SumOfSquaresMxyz(maxX))) / (pi * permissibleStress), 1 / 3.0);
            diameter[4] = maxDiameter * 1000;
            g.DrawString("Φ4≥" + Math.Round(maxDiameter * 1000, 2) + "mm    在 x=" + maxX * a / 100.0 + "m 处应力最大",
                         font1, brush1, x1, y1 + 200);

            g.DrawString("之后根据比例关系得(这部分不同人有不同理解):", font2, brush1, x1, y1 + 240);
            int diameterStatus = 1;

            tempDiameter[1] = MyCalculate.NearestMoreEvenNumber(diameter[1]) - 2;
            while (diameterStatus != 4)
            {
                tempDiameter[1] += 2;
                if (tempDiameter[1] / 1.1 >= diameter[2])
                {
                    tempDiameter[2] = MyCalculate.NearestMoreEvenNumber(tempDiameter[1] / 1.1);
                    diameterStatus  = 2;
                }
                if (diameterStatus == 2 && tempDiameter[2] / 1.1 >= diameter[3])
                {
                    tempDiameter[3] = MyCalculate.NearestMoreEvenNumber(tempDiameter[2] / 1.1);
                    diameterStatus  = 3;
                }
                if (diameterStatus == 3 && tempDiameter[3] / 1.1 >= diameter[4])
                {
                    tempDiameter[4] = MyCalculate.NearestMoreEvenNumber(tempDiameter[3] / 1.1);
                    diameterStatus  = 4;
                }
            }
            g.DrawString("Φ1≥ " + tempDiameter[1] + " mm" +
                         "\n\nΦ2≥ " + tempDiameter[2] + " mm" +
                         "\n\nΦ3≥ " + tempDiameter[3] + " mm" +
                         "\n\nΦ4≥ " + tempDiameter[4] + " mm",
                         font2, brush1, x1, y1 + 270);
            textBox13.Text = "" + tempDiameter[1];
        }
コード例 #16
0
 public void SpImNob(Vector3 v3, int Lv, int n)
 {
     MyCalculate.SpObj(Nobs [Lv], transform, v3).GetComponent <Mobe_Nob> ().Open(n);
 }
コード例 #17
0
    void Start()
    {
        void SetPos(Vector3 v3)
        {
            if (Lines.Count <= 0)
            {
                return;
            }

            NowLine.positionCount++;
            NowLine.SetPosition(NowLine.positionCount - 1, v3);
            Mouse.position = v3;
        }

        DragButt.Start_Del += (v3) =>
        {
            Mouse.gameObject.SetActive(true);
            GameObject obj = MyCalculate.SpObj(LineObj.gameObject, transform, Vector3.zero);
            obj.transform.position = v3;
            Lines.Add(obj.GetComponent <LineRenderer>());

            SetPos(v3);
        };
        DragButt.Update_Del += (v3) =>
        {
            SetPos(v3);
        };
        DragButt.End_Del += (v3) =>
        {
            if (NowT.IsLast)
            {
                StartCoroutine(_End_Del());
            }
            Mouse.gameObject.SetActive(false);
        };
        IEnumerator _End_Del()//跳到下一畫必須要晚一偵執行避免半段錯誤
        {
            yield return(null);

            NowT.IsOK_2 = true;
            LoadNext();
            // print ("x");
        }

//==========================================================================================
        IEnumerator OX(string text)
        {
            Text.GetComponentsInChildren <Text> ()[1].text = text;
            yield return(new WaitForSeconds(1));

            Text.GetComponentsInChildren <Text> ()[1].text = "";
        }

        FallEvent += () =>
        {
            print("失敗!");
            StartCoroutine(OX("X"));
            ResetLine();
        };
        WinEvent += () =>
        {
            print("勝利!");
            StartCoroutine(OX("O"));
            ResetLine();
        };
        //Open (Data);
    }
コード例 #18
0
ファイル: ScrollCon.cs プロジェクト: tommyboys0107/2018gcgj
 public int Getn(ScrollObj Obj)
 {
     return((int)MyCalculate.SaladMod((-transform.localPosition.y + Obj.g / 2) / Obj.g, Obj.ObjL));
 }
コード例 #19
0
        static void Main(string[] args)
        {
            #region 计算器
            MyCalculate _MyCalculate = new MyCalculate();
            //一般的调用
            Calculate_Delegate _calculate_Delegate;
            //创建的多种方法
            _calculate_Delegate = new Calculate_Delegate(_MyCalculate.Add);
            //_calculate_Delegate = _MyCalculate.Add; //可以直接这么写(只要符合委托签名即可)
            //多播委托(栈方式 如果有返回值,则只返回后入的那个方法返回值)
            _calculate_Delegate += _MyCalculate.Subtraction;
            _calculate_Delegate += _MyCalculate.Multiplication;
            _calculate_Delegate -= _MyCalculate.Subtraction;
            _calculate_Delegate -= _MyCalculate.Divide;//可以去除不存在的方法
            double result;
            //执行的多种方法
            result = _calculate_Delegate.Invoke(4, 3);
            //Func<T> 委托
            result = _MyCalculate.DoCalculate <double>(4, 5, _MyCalculate.Add);
            Console.WriteLine($"{result}");
            result = _calculate_Delegate(4, 3);
            Console.WriteLine($"{result}");
            //方法作为参数传递给另一个方法
            result = _MyCalculate.DoCalculate(_MyCalculate.Divide, 4, 3);
            Console.WriteLine("计算结果是:" + result);

            #endregion

            #region 通用排序实例
            List <Employee> Employees = new List <Employee>
            {
                new Employee("和", 6),
                new Employee("林", 8),
                new Employee("粥", 5),
                new Employee("轮", 3),
                new Employee("顾", 9),
                new Employee("小", 4),
                new Employee("仟", 7)
            };

            MySort.Sort(Employees, Employee.CompareAge);
            Employees.ForEach(
                f =>
            {
                Console.WriteLine(f);
            });

            #endregion

            #region 多播委托和异常处理
            Action actions = One;
            actions += Two;
            ////第一种:这种多播委托 如果第一个方法异常了  就会停止迭代了  不会去执行后面的方法了
            try
            {
                actions.Invoke();
            }
            catch (Exception ex)
            {
                Console.WriteLine("actions.Invoke() exception");
            }
            //第二种:将多播委托使用GetInvocationList() ,得到一个Delegate[],再执行,出异常可以继续下一次迭代
            System.Delegate[] d = actions.GetInvocationList();
            foreach (Action item in d)
            {
                try
                {
                    item();
                }
                catch (Exception)
                {
                    Console.WriteLine("Delegate[] d , item() exception");
                }
            }

            #endregion

            //Action a = () => Console.WriteLine("1");
            Console.ReadKey();
        }