Esempio n. 1
0
        //----------------------------------------------------------------------------private
        //正常刷新时间,加秒
        private void ReflashTime(object sender, EventArgs e)
        {                                              // gg yyyy/MM/dd hh:mm:ss dddd
            Worldtime.AddTime(new TimeSpan(0, 0, 15)); //1秒
            var    time  = Worldtime.GetTime();
            string state = Worldtime.GetState();

            TB_time.Text = time.ToString() + " " + state;
        }
Esempio n. 2
0
        private static void GeneralToolfn(Tool tool, string tag, Dictionary <string, uint> input)
        {
            tool.SetUsefn((Prefab who) => {
                Random rand                = new Random();
                var traveler               = Form1.traveler;
                char[] separator           = { ' ' };
                StringSplitOptions options = StringSplitOptions.RemoveEmptyEntries;
                if (traveler.HasTag(tag))
                {
                    if (Worldtime.GetState() == "晚上" && !traveler.HasTag("light"))
                    {
                        // MainForm.Print(traveler.name + "迷失在了黑暗当中");
                        g_baseresult.LostInDark();
                        return;
                    }
                    MainForm.SleepTime();
                    TimeSpan passtime = Worldtime.GetTimeNowToNext();
                    string hour       = Convert.ToString((int)(passtime.TotalHours * 10) / 10.0); //保留一位小数
                    //--------------------------
                    var my = (Tool)who;
                    my.curusetime--;
                    if (my.IsBroken())
                    {
                        traveler.backpack.Remove(my.name, 1);
                    }
                    //----------------------------
                    Queue <string> output = new Queue <string>();
                    foreach (var v in input)
                    {
                        int num = (int)(passtime.TotalMinutes * 0.01 * v.Value);  // (12-6)*60*0.01 = 3.6
                        num     = rand.Next(num - 1) + 1;

                        string[] str = v.Key.Split(separator, options);
                        if (str.Length != 3)
                        {
                            return;
                        }
                        string spoil = str[0], action = str[1], unit = str[2];
                        if (traveler.backpack.IsFull() && !traveler.backpack.IsExistObject(spoil))
                        {
                            output.Enqueue(traveler.name + "花费了" + hour + "小时来" + action + ",掉落了" + num + unit + spoil + ",却因背包满而带不回来。");
                        }
                        else
                        {
                            traveler.backpack.AddObject(spoil, (uint)num);
                            output.Enqueue(traveler.name + "花费" + hour + "小时来" + action + ",得到了" + (uint)num + unit + spoil + "。");
                        }
                    }
                    //-------------------
                    MainForm.Print(output);
                    // MainForm.Awake(passtime);
                    MainForm.ReflashBackpackList();
                    Worldtime.GotoNextState();
                    MainForm.Awake();
                }
            });
        }
Esempio n. 3
0
 public Button(string name, ElFN fn, int usetime = 1, bool CanLostInDark = true, bool CanLostCook = true, string prefabname = null, bool GotoNextState = false, double rate = 0.5)
 {
     this.name       = name;
     this.maxusetime = this.usetime = usetime;
     this.prefabname = prefabname;
     this.fn         = (object sender, EventArgs e) => {
         if (CanLostInDark && Worldtime.GetState() == "晚上" && !Form1.traveler.HasTag("light"))
         {
             g_baseresult.LostInDark();
         }
         else
         {
             if (this.usetime > 0) //注意不能直接用 usetime--  !!!,因为它是指传入的参数
             {
                 --this.usetime;
                 if (fn != null)
                 {
                     fn(this.scane);
                 }
                 if (this.usetime <= 0)
                 {
                     if (linkbutton != null)
                     {
                         linkbutton.Enabled = false;
                     }
                 }
             }
             if (CanLostCook)
             {
                 MainForm.DeCookMenu();
             }
         }
         if (GotoNextState)
         {
             Worldtime.GotoNextState(rate);
         }
     };
 }
Esempio n. 4
0
        //使用以及烹饪
        private static void SetToolUSe(Tool tool)
        { //"斧头","鹤嘴锄","火把","篝火","石篝火","钓鱼竿"
            Random rand     = new Random();
            var    traveler = Form1.traveler;

            if (tool.name == "斧头")
            {//Tool tool,string tag, Dictionary<string,uint> input;
             //string spoil,string action,string unit="个")
                Dictionary <string, uint> input = new Dictionary <string, uint>();
                input.Add("木材 砍树 个", 10);
                GeneralToolfn(tool, "canuseaxe", input);
            }
            else if (tool.name == "鹤嘴锄")
            {
                Dictionary <string, uint> input = new Dictionary <string, uint>();
                input.Add("金块 挖矿 个", 2);
                input.Add("石头 挖矿 个", 8);
                input.Add("燧石 挖矿 个", 6);
                GeneralToolfn(tool, "canusepickaxe", input);
            }
            else if (tool.name == "火把")
            {
                tool.SetUsefn((Prefab who) => {
                    if (Worldtime.GetState() == "晚上")
                    {
                        traveler.AddTag("light"); //判断是否能在黑暗中行走
                        traveler.backpack.Remove(who.name, 1);
                        MainForm.Print(traveler.name + "点上了火把。");
                    }
                });
            }
            else if (tool.name == "篝火" || tool.name == "石篝火")
            {
                tool.SetUsefn((Prefab who) => {
                    traveler.AddTag("light"); //判断是否能在黑暗中行走
                    traveler.AddTag("cookable");
                    if (tool.name == "篝火")
                    {
                        traveler.backpack.Remove(who.name, 1);
                    }
                    else
                    {
                        var my = (Tool)who;
                        my.curusetime--;
                        if (my.IsBroken())
                        {
                            traveler.backpack.Remove(my.name, 1);
                        }
                    }
                    MainForm.Print(traveler.name + "生起了" + tool.name + "。");
                    MainForm.EnCookMenu();
                    MainForm.ReflashBackpackList();
                });
            }
            else if (tool.name == "钓鱼竿")
            {
                Dictionary <string, uint> input = new Dictionary <string, uint>();
                input.Add("鱼 钓鱼 条", 4);
                GeneralToolfn(tool, "canfish", input);
            }
            else if (tool.name == "烹饪锅")
            {
                tool.SetUsefn((Prefab who) => {
                    traveler.AddTag("cookable");
                    var my = (Tool)who;
                    my.curusetime--;
                    if (my.IsBroken())
                    {
                        traveler.backpack.Remove(my.name, 1);
                    }
                    MainForm.Print(traveler.name + "架起来" + tool.name + "。");
                    MainForm.EnCookRecipe();
                    MainForm.ReflashBackpackList();
                });
            }
            else
            {
            }
        }
Esempio n. 5
0
 public void Awake()//timer_Time
 {
     timer_Time.Enabled = true;
     TB_time.Text       = Worldtime.GetTime().ToString() + " " + Worldtime.GetState();
 }