Пример #1
0
    public static DataFrameState FrameDefault(DataMeta dataMeta)
    {
#if UNITY_EDITOR
        var speed =
            Vector2.down *
            dataMeta.BallInitialSpeed;
#else
        var speed =
            UnityEngine.Random.insideUnitCircle.normalized *
            dataMeta.BallInitialSpeed;
#endif
        return(new DataFrameState
        {
            Time = 0,
            //
            PaddleLocalPosition = 0f,
            PaddleLocalSpeed = 0f,
            PaddleLocalReflectorOffset = dataMeta.PaddleReflectorOffset,
            PaddleLocalReflectorHalfSize = dataMeta.PaddleReflectorHalfSize,
            //
            PaddleRemotePosition = 0f,
            PaddleRemoteSpeed = 0f,
            PaddleRemoteReflectorOffset = dataMeta.PaddleReflectorOffset,
            PaddleRemoteReflectorHalfSize = dataMeta.PaddleReflectorHalfSize,
            //
            BallPositionX = 0f,
            BallPositionY = 0f,
            BallSpeedX = speed.x,
            BallSpeedY = speed.y,
        });
    }
Пример #2
0
        public static DataMeta TaiwanBK_GetRate(this HtmlNodeCollection Node, EnumBank EnumBank)
        {
            DataMeta Table     = new DataMeta();
            RateData TempTable = new RateData();

            Table.CreateDate = MyTimeZone.Today;
            Table.Expire     = MyTimeZone.Today.AddMinutes(Expire);
            Table.Key        = EnumBank;

            //int LIndex = (int)EnumRate.幣別;
            foreach (var item in Node.Select((value, index) => new { index, value }))
            {
                Table.Data.Add(new RateData()
                {
                    Currencty = item.value.SelectNodes(@"//div[@class=""hidden-phone print_show""]")[item.index].InnerText
                                .Replace("\r\n", "")
                                .Replace("              ", "")
                                .Replace(" ", "")
                                .Replace("(", "")
                                .Replace(")", "")
                                .TrimStart(' ').TrimEnd(' ').Replace("\r\n", ""),
                    CashBuying  = item.value.SelectNodes(@"//td[@data-table=""本行現金買入""]")[item.index].InnerText,
                    CashSelling = item.value.SelectNodes(@"//td[@data-table=""本行現金賣出""]")[item.index].InnerText,
                    SpotBuying  = item.value.SelectNodes(@"//td[@data-table=""本行即期買入""]")[item.index].InnerText,
                    SpotSelling = item.value.SelectNodes(@"//td[@data-table=""本行即期賣出""]")[item.index].InnerText
                });
            }
            return(Table);
        }
Пример #3
0
 public static void SaveSettings(DataMeta data)
 {
     PlayerPrefs.SetString(
         Application.installerName,
         JsonUtility.ToJson(data));
     PlayerPrefs.Save();
 }
Пример #4
0
        public void ProcessRecordData_Test(string data, DataMeta dm)
        {
            var person = parser.Parse(data, dm);

            Assert.IsInstanceOfType(person, new Person().GetType());
            ComparePerson(person, person1);
        }
Пример #5
0
        public void Initialize()
        {
            parser = new PersonParser();

            dataMeta1           = new DataMeta();
            dataMeta1.Delimiter = ',';
            dataMeta1.Fields.Add("lastname", 0);
            dataMeta1.Fields.Add("firstname", 1);
            dataMeta1.Fields.Add("gender", 2);
            dataMeta1.Fields.Add("dateofbirth", 4);
            dataMeta1.Fields.Add("favoritecolor", 3);

            dataMeta2           = new DataMeta();
            dataMeta2.Delimiter = ',';
            dataMeta2.Fields.Add("lastname", 1);
            dataMeta2.Fields.Add("firstname", 0);
            dataMeta2.Fields.Add("gender", 3);
            dataMeta2.Fields.Add("dateofbirth", 4);
            dataMeta2.Fields.Add("favoritecolor", 2);

            person1               = new Person();
            person1.DateOfBirth   = new DateTime(1962, 06, 21);
            person1.Gender        = "M";
            person1.FavoriteColor = "black";
            person1.LastName      = "Tsoi";
            person1.FirstName     = "Viktor";
        }
Пример #6
0
        static void Main(string[] args)
        {
            var Exit   = false;
            var Result = new DataMeta();

            while (!Exit)
            {
                ShowEnumList();
                var BankKey = Console.ReadLine();

                switch (Enum.Parse(typeof(EnumBank), BankKey))
                {
                case EnumBank.臺灣銀行:
                    Result = BankRate.GetRate(EnumBank.臺灣銀行);
                    break;

                case EnumBank.台新銀行:
                    Result = BankRate.GetRate(EnumBank.台新銀行);
                    break;

                default:
                    Exit = true;
                    break;
                }
                ShowResult(Result);
            }
        }
Пример #7
0
    public static DataFrameState FrameConsent(DataMeta dataMeta, NetState network)
    {
        var @default = FrameDefault(dataMeta);

        @default.BallSpeedX = network.IsLead
                        ? network.Local.BallSpeedX
                        : network.Remote.BallSpeedX;
        @default.BallSpeedY = network.IsLead
                        ? network.Local.BallSpeedY
                        : -network.Remote.BallSpeedY;
        return(@default);
    }
Пример #8
0
        public static DataMeta Taishin_GetRate(this HtmlNodeCollection Node, EnumBank EnumBank)
        {
            DataMeta Table     = new DataMeta();
            RateData TempTable = new RateData();

            Table.CreateDate = DateTime.Now;
            Table.Expire     = DateTime.Now.AddMinutes(Expire);
            Table.Key        = EnumBank;

            int LIndex = (int)EnumRate.幣別;

            foreach (var item in Node)
            {
                if (LIndex == (int)EnumRate.幣別)
                {
                    TempTable = new RateData();
                }
                switch (LIndex)
                {
                case (int)EnumRate.幣別:
                    TempTable.Currencty = item.InnerText;
                    break;

                case (int)EnumRate.即期買入:
                    TempTable.SpotBuying = item.InnerText;
                    break;

                case (int)EnumRate.即期賣出:
                    TempTable.SpotSelling = item.InnerText;
                    break;

                case (int)EnumRate.現鈔買入:
                    TempTable.CashBuying = item.InnerText;
                    break;

                case (int)EnumRate.現鈔賣出:
                    TempTable.CashSelling = item.InnerText;
                    break;
                }
                if (LIndex == (int)EnumRate.現鈔賣出)
                {
                    Table.Data.Add(TempTable);
                }
                LIndex = LIndex == (int)EnumRate.現鈔賣出 ? (int)EnumRate.幣別 : LIndex + 1;
            }
            return(Table);
        }
Пример #9
0
        public static void ShowResult(DataMeta Result)
        {
            Console.WriteLine("--------------------------------------------------------------------------------------------\r\n"
                              + Result.Key + "匯率"
                              + " 資料更新時間為:" + Result.CreateDate.Value.ToString("yyyy/MM/dd HH:mm:ss.fff")
                              + " 下次更新時間為:" + Result.Expire.Value.ToString("yyyy/MM/dd HH:mm:ss.fff")
                              + "\r\n--------------------------------------------------------------------------------------------");

            string Title = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}"
                                         , SerialNo
                                         , CalSpace(SerialNo, NoSpaceSize)
                                         , Currencty
                                         , CalSpace(Currencty, SpaceSize)
                                         , SpotBuying
                                         , CalSpace(SpotBuying, SpaceSize)
                                         , SpotSelling
                                         , CalSpace(SpotSelling, SpaceSize)
                                         , CashBuying
                                         , CalSpace(CashBuying, SpaceSize)
                                         , CashSelling
                                         , CalSpace(CashSelling, SpaceSize));

            Console.WriteLine(Title);

            foreach (var item in Result.Data.Select((value, index) => new { index, value }))
            {
                byte[] byteStr = Encoding.GetEncoding("big5").GetBytes(item.value.Currencty);
                Console.WriteLine(
                    string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11} \r\n"
                                  , (item.index + 1).ToString().PadLeft(2, '0')
                                  , CalSpace((item.index + 1).ToString().PadLeft(2, '0'), NoSpaceSize)
                                  , item.value.Currencty
                                  , CalSpace(item.value.Currencty, SpaceSize)
                                  , item.value.SpotBuying
                                  , CalSpace(item.value.SpotBuying, SpaceSize)
                                  , item.value.SpotSelling
                                  , CalSpace(item.value.SpotSelling, SpaceSize)
                                  , item.value.CashBuying
                                  , CalSpace(item.value.CashBuying, SpaceSize)
                                  , item.value.CashSelling
                                  , CalSpace(item.value.CashSelling, SpaceSize)
                                  ));
            }
            Console.WriteLine("--------------------------------------------------------------------------------------------\r\n");
        }