Пример #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int    value = (int)this.numericUpDownPeriod.Value;
            int    index = this.comboBoxUnit.SelectedIndex;
            string unit  = "秒";

            switch (index)
            {
            case 0:
                unit = "秒";
                break;

            case 1:
                unit = "分钟";
                break;

            case 2:
                unit = "小时";
                break;

            case 3:
                unit = "日";
                break;
            }

            period       = new TimeCycle();
            period.value = value;
            period.unit  = unit;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #2
0
 void Awake()
 {
     if (Access != null)
     {
         Destroy(gameObject);
     }
     Access = this;
 }
Пример #3
0
 public Time()
 {
     CurrentCycle     = TimeCycle.Dawn;
     TimePeriod       = 30;
     m_Time           = new Timer(1000 * 60 * TimePeriod);
     m_Time.Enabled   = true;
     m_Time.AutoReset = true;
     m_Time.Elapsed  += OnTimeEvent;
 }
Пример #4
0
        public async Task CycleTimeAsync(int framesPerHour = 1, int delay = 150, int?loop = null)
        {
            string   path = $"../tmp/{Context.User.Id}_time.gif";
            FontFace font = JsonHandler.Load <FontFace>(@"../assets/fonts/orikos.json");

            char[][][][] charMap = JsonHandler.Load <char[][][][]>(@"../assets/char_map.json", new JsonCharArrayConverter());
            var          config  = TextFactoryConfig.Default;

            config.CharMap = charMap;

            var frames     = new List <Stream>();
            var properties = new ImageProperties
            {
                TrimEmptyPixels = true,
                Padding         = new Padding(2),
                Width           = 47
            };

            float t = 0.00f;

            using (var factory = new TextFactory(config))
            {
                factory.SetFont(font);

                for (float h = 0; h < 24 * framesPerHour; h++)
                {
                    GammaPalette colors = TimeCycle.FromHour(t);
                    properties.Matte = colors[Gamma.Min];

                    frames.Add(DrawFrame(factory, t.ToString("00.00H"), colors[Gamma.Max], properties));

                    t += (1.00f / framesPerHour);
                }
            }

            var gifStream = new MemoryStream();

            using (var encoder = new GifEncoder(gifStream, repeatCount: loop))
            {
                encoder.FrameLength = TimeSpan.FromMilliseconds(delay);

                foreach (Stream frame in frames)
                {
                    await using (frame)
                        encoder.EncodeFrame(Image.FromStream(frame));
                }
            }

            gifStream.Position = 0;
            Image gifResult = Image.FromStream(gifStream);

            gifResult.Save(path, ImageFormat.Gif);
            await gifStream.DisposeAsync();

            await Context.Channel.SendFileAsync(path);
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            FormAddCustomCycle formAddCustomPeriod = new FormAddCustomCycle();

            if (formAddCustomPeriod.ShowDialog() == DialogResult.OK)
            {
                TimeCycle period = formAddCustomPeriod.getResult();
                customPeriods.Add(period);
                refreshCustomPeriod();
            }
        }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        timeCycle   = GameObject.Find("Manager").GetComponent <TimeCycle>();
        workerIndex = GameObject.Find("Manager").GetComponent <WorkerIndex>();

        fire = transform.GetChild(0).gameObject;
        fire.SetActive(false);

        Register();

        //MoveToSite(WorkSite.Pyramid);
    }
Пример #7
0
        /// <summary>
        /// Sets an event definition for the timer with a time cycle.
        /// </summary>
        /// <param name="timerCycle"> the time cycle of the timer </param>
        /// <returns> the builder object </returns>
        public virtual B timerWithCycle(string timerCycle)
        {
            TimeCycle timeCycle = createInstance(typeof(TimeCycle));

            timeCycle.TextContent = timerCycle;

            TimerEventDefinition timerEventDefinition = createInstance(typeof(TimerEventDefinition));

            timerEventDefinition.TimeCycle = timeCycle;

            element.EventDefinitions.add(timerEventDefinition);

            return(myself);
        }
Пример #8
0
        private void OnTimeEvent(Object source, ElapsedEventArgs e)
        {
            if (((byte)CurrentCycle) == 3)
            {
                CurrentCycle = TimeCycle.Dawn;
            }
            else
            {
                CurrentCycle = (TimeCycle)(CurrentCycle + 1);
            }

#if DEBUG
            Console.WriteLine("The Cycle has changed to {0}", CurrentCycle);
#endif
        }
Пример #9
0
        public async Task GetTimeAsync()
        {
            try
            {
                string       path    = $"../tmp/{Context.User.Id}_time.png";
                GammaPalette palette = TimeCycle.FromUtcNow();

                using var graphics = new GraphicsService();
                Bitmap bmp = graphics.DrawText(DateTime.UtcNow.ToString("hh:mm tt").ToUpper(), Gamma.Max, palette);
                await Context.Channel.SendImageAsync(bmp, path);
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
Пример #10
0
    public override void Publish(Publisher publisher)
    {
        bool lastHour = night;

        if (publisher.GetType() == typeof(TimeCycle))
        {
            TimeCycle timeCycle = (TimeCycle)publisher;

            night = timeCycle.nightTime;
        }

        if (night != lastHour)
        {
            StartCoroutine("ChangeOverlay");
        }

        //nightOverlay.enabled = night;
    }
    private void DayNightCycle()
    {
        sun.transform.Rotate(-Vector3.right * cycleSpeed * Time.deltaTime);
        float sunRotation = sun.transform.rotation.eulerAngles.x;

        timeCounter += cycleSpeed * Time.deltaTime;
        if (timeCounter >= 45)
        {
            if (timeCycle == TimeCycle.Latenight)
            {
                timeCycle = TimeCycle.Dawn;
            }
            else
            {
                timeCycle += 1;
            }
            timeCounter = 0;
        }
    }
Пример #12
0
        private static string GetInterval(TimeCycle cycle)
        {
            switch (cycle)
            {
            case TimeCycle.Daily:
                return("day");

            case TimeCycle.Weekly:
                return("week");

            case TimeCycle.Monthly:
                return("month");

            case TimeCycle.Yearly:
                return("year");

            default:
                throw new ArgumentOutOfRangeException(nameof(cycle), cycle, null);
            }
        }
Пример #13
0
        public async Task GetTimeAsync(float hour)
        {
            if (hour > 23.00f || hour < 0.00f)
            {
                await Context.Channel.SendMessageAsync("hour out of range");

                return;
            }

            try
            {
                string path = $"../tmp/{Context.User.Id}_time.png";
                var    font = JsonHandler.Load <FontFace>(@"../assets/fonts/orikos.json");
                // new OutlineProperties(1, new OriColor(0x44B29B)): Too taxing on performance as of now
                char[][][][] charMap = JsonHandler.Load <char[][][][]>(@"../assets/char_map.json", new JsonCharArrayConverter());
                GammaPalette colors  = TimeCycle.FromHour(hour);
                var          config  = TextFactoryConfig.Default;
                config.CharMap = charMap;
                var properties = new ImageProperties
                {
                    TrimEmptyPixels = true,
                    Padding         = new Padding(2),
                    Matte           = colors[Gamma.Min]
                };

                using (var factory = new TextFactory(config))
                    using (Bitmap bmp = factory.DrawText(hour.ToString("00.00H").ToUpper(), font, properties))
                        ImageHelper.Save(bmp, path, ImageFormat.Png);

                await Context.Channel.SendFileAsync(path);
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
Пример #14
0
    public override void Publish(Publisher publisher)
    {
        if (publisher.GetType() == typeof(Supplies))
        {
            Supplies supplies = (Supplies)publisher;

            this.food.text  = (System.Math.Floor(supplies.food)).ToString();
            this.stone.text = (System.Math.Floor(supplies.stones)).ToString();
        }
        else if (publisher.GetType() == typeof(TimeCycle))
        {
            TimeCycle timeCycle = (TimeCycle)publisher;

            hour      = timeCycle.hour;
            day       = timeCycle.daysPassed;
            time.text = day.ToString() + "d " + hour.ToString() + "h";
        }
        else if (publisher.GetType() == typeof(WorkerIndex))
        {
            WorkerIndex workerIndex = (WorkerIndex)publisher;

            this.workers.text = workerIndex.GetAllWorkers().Count.ToString();
        }
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     time = GetComponent <TimeCycle>();
     Register();
 }
Пример #16
0
 public MenuItemTimeCycle(Client client, Menu owner, string label, TimeCycle timeCycle, int priority = -1) : base(client, owner, label, priority)
 {
     TimeCycle = timeCycle;
 }
        private void buttonNext_Click(object sender, EventArgs e)
        {
            periods.Clear();

            List <CheckBox> checkBoxes = new List <CheckBox>();

            foreach (Control c in this.Controls)
            {
                if (c is CheckBox)
                {
                    CheckBox cb = (CheckBox)c;
                    checkBoxes.Add(cb);
                }
            }

            checkBoxes = checkBoxes.OrderBy(x => x.Tag).ToList();

            foreach (CheckBox cb in checkBoxes)
            {
                if (cb.Checked)
                {
                    TimeCycle period = new TimeCycle();
                    switch (cb.Text)
                    {
                    case "5秒":
                        period.value = 5;
                        period.unit  = "秒";
                        periods.Add(period);
                        break;

                    case "10秒":
                        period.value = 10;
                        period.unit  = "秒";
                        periods.Add(period);
                        break;

                    case "15秒":
                        period.value = 15;
                        period.unit  = "秒";
                        periods.Add(period);
                        break;

                    case "30秒":
                        period.value = 30;
                        period.unit  = "秒";
                        periods.Add(period);
                        break;

                    case "1分钟":
                        period.value = 1;
                        period.unit  = "分钟";
                        periods.Add(period);
                        break;

                    case "3分钟":
                        period.value = 3;
                        period.unit  = "分钟";
                        periods.Add(period);
                        break;

                    case "5分钟":
                        period.value = 5;
                        period.unit  = "分钟";
                        periods.Add(period);
                        break;

                    case "10分钟":
                        period.value = 10;
                        period.unit  = "分钟";
                        periods.Add(period);
                        break;

                    case "15分钟":
                        period.value = 15;
                        period.unit  = "分钟";
                        periods.Add(period);
                        break;

                    case "30分钟":
                        period.value = 30;
                        period.unit  = "分钟";
                        periods.Add(period);
                        break;

                    case "1小时":
                        period.value = 1;
                        period.unit  = "小时";
                        periods.Add(period);
                        break;

                    case "2小时":
                        period.value = 2;
                        period.unit  = "小时";
                        periods.Add(period);
                        break;

                    case "3小时":
                        period.value = 3;
                        period.unit  = "小时";
                        periods.Add(period);
                        break;

                    case "4小时":
                        period.value = 4;
                        period.unit  = "小时";
                        periods.Add(period);
                        break;

                    case "日线":
                        period.value = 0;
                        period.unit  = "日线";
                        periods.Add(period);
                        break;

                    case "周线":
                        period.value = 0;
                        period.unit  = "周线";
                        periods.Add(period);
                        break;

                    case "月线":
                        period.value = 0;
                        period.unit  = "月线";
                        periods.Add(period);
                        break;

                    case "季线":
                        period.value = 0;
                        period.unit  = "季线";
                        periods.Add(period);
                        break;

                    case "年线":
                        period.value = 0;
                        period.unit  = "年线";
                        periods.Add(period);
                        break;
                    }
                }
            }
            periods.AddRange(customPeriods);
            if (periods.Count == 0)
            {
                MessageBox.Show("请选择周期");
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }