void Regulus.Game.IStage.Enter()
            {
                for (int i = 0; i < _Groups.Length; ++i )
                {
                    var energy = new Energy(3);
                    var eg = new EnergyGroup() { Energy = energy, Round = Regulus.Utility.Random.Next(0, 3) } ;
                    Func<bool>[] incs1 =
                    {
                        energy.IncGreen , energy.IncRed , energy.IncYellow
                    };
                    incs1[Regulus.Utility.Random.Next(0, incs1.Length)]();
                    incs1[Regulus.Utility.Random.Next(0, incs1.Length)]();

                    Func<bool>[] incs2 =
                    {
                        energy.IncPower , ()=>{eg.Hp = 1; return true;} , ()=>{eg.Change = 1; return true;}
                    };

                    incs2[Regulus.Utility.Random.Next(0, incs2.Length)]();
                    _Groups[i] = eg ;
                }

                foreach (var capture in _Capturers)
                {
                    capture.Player.OnSpawnCaptureEnergy(capture);
                    capture.Initial(_Groups);
                    capture.CaptureEvent += _OnCapture;
                }

                _Timeout = new Utility.TimeCounter();
            }
Esempio n. 2
0
        private static void _TestService(IBinderProvider entry, ref bool bind, IProtocol protocol)
        {
            bind = false;
            var service = Regulus.Remote.Standalone.Provider.CreateService(protocol, entry);

            Ghost.IAgent agent = new Regulus.Remote.Ghost.Agent(protocol);
            service.Join(agent, null);
            IGpiA retGpiA = null;
            bool  ret     = false;

            agent.QueryNotifier <IGpiA>().Supply += gpi => {
                ret     = true;
                retGpiA = gpi;
            };
            var timer = new Regulus.Utility.TimeCounter();
            var apr   = new Regulus.Utility.AutoPowerRegulator(new Utility.PowerRegulator());

            while (retGpiA == null)
            {
                apr.Operate();
                agent.Update();
                if (timer.Second > 10)
                {
                    throw new System.Exception($"debug agent:{agent.Active} bind:{bind} ");
                }
            }

            service.Leave(agent);
            service.Dispose();

            Assert.AreNotEqual(null, retGpiA);
            Assert.AreEqual(true, bind);
            Assert.AreEqual(true, ret);
        }
Esempio n. 3
0
 public Complex(IStorage stroage)
 {
     _Time = new LocalTime();
     _Hall = new Hall();
     _World = new World(LocalTime.Instance);
     _Updater = new Utility.Updater();
     _Storage = stroage;
     _TimeCounter = new Utility.TimeCounter();
 }
Esempio n. 4
0
        public BatchCommander(Regulus.Utility.Command command)
        {
            _Timer = new Regulus.Utility.TimeCounter();

            this._Command = command;

            _Command.Register("1" , _1);
            _CommandStrings = new Queue<CommandString>();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var view = new Regulus.Utility.ConsoleViewer();
            var input = new Regulus.Utility.ConsoleInput(view);

            var application = new Regulus.Project.SamebestKeys.Console(view, input);

            _BuildGameData(view);
            BotSet bots = new BotSet();

            application.SetLogMessage(Regulus.Utility.Console.LogFilter.All);

            Regulus.Utility.Updater updater = new Regulus.Utility.Updater();

            updater.Add(application);
            updater.Add(input);
            updater.Add(bots);

            bool exit = false;
            application.Command.Register("quit", () => { exit = true; });
            application.Command.Register<string,int>("SetBotIp",
                (ip,port) =>
                {
                    Bot.Port = port;
                    Bot.IpAddress = ip;
                });
            application.Command.Register<int>("BotSn", (sn) =>
            {
                bots.Sn = sn;
            });

            application.Command.Register<int>("Bot", (count) =>
            {
                bots.Create(count);
            });
            application.SelectSystemEvent += (selector) =>
            {
                var value = selector.Use("remoting");
                value.OnValue += _SpawnController;
                value.OnValue += (requester) =>
                {
                    bots.Requester = requester;
                };
            };

            Regulus.Utility.TimeCounter fps = new Regulus.Utility.TimeCounter(); ;
            while (exit == false)
            {
                updater.Update();
                fps.Reset();
            }
            application.Command.Unregister("SetBotIp");
            application.Command.Unregister("BotSn");
            application.Command.Unregister("Bot");
            application.Command.Unregister("quit");
            application.Stop();
        }
Esempio n. 6
0
        public BatchCommander(Regulus.Utility.Command command)
        {
            _Timer = new Regulus.Utility.TimeCounter();

            this._Command = command;


            _Command.Register("1", _1);
            _CommandStrings = new Queue <CommandString>();
        }
            public WaittingConnectStage(BattlerInfomation[] battlerInfomation)
            {
                _Count = 0;
                _ReadyInfomations = new List<ReadyInfomation>();
                foreach(var battrler in battlerInfomation)
                {
                    _ReadyInfomations.Add(new ReadyInfomation() { Battler = battrler });
                }

                _Timeout = new Utility.TimeCounter();
            }
Esempio n. 8
0
        public BatchCommander(Regulus.Utility.Command command, Regulus.Utility.ConsoleViewer viewer)
        {
            _Timer = new Regulus.Utility.TimeCounter();

            this._Command = command;

            _Command.Register("1" , _1);
            _Command.Register("2", _2);
            _Command.Register("3", _3);

            _CommandStrings = new Queue<CommandString>();
        }
            void Regulus.Game.IStage.Enter()
            {
                _Timeout = new Utility.TimeCounter();
                _Decideds = new List<Decided>();
                foreach(var player in _Players)
                {

                    var decided = new Decided() { Owner = player };

                    player.OnSpawnReadyCaptureEnergy(decided);
                    _Decideds.Add(decided);
                }
            }
Esempio n. 10
0
        static void Main(string[] args)
        {
            var view = new Regulus.Utility.ConsoleViewer();
            var input = new Regulus.Utility.ConsoleInput(view);

            var application = new Regulus.Project.SamebestKeys.Console(view, input);

            BotSet bots = new BotSet();

            application.SetLogMessage(Regulus.Utility.Console.LogFilter.All);

            Regulus.Utility.Updater<Regulus.Utility.IUpdatable> updater = new Regulus.Utility.Updater<Regulus.Utility.IUpdatable>();

            updater.Add(application);
            updater.Add(input);
            updater.Add(bots);

            bool exit = false;
            application.Command.Register("quit", () => { exit = true; });
            application.Command.Register<int>("Bot", (count) =>
            {
                bots.Create(count);
            });
            application.SelectSystemEvent += (selector) =>
            {
                var value = selector.Use("remoting");
                value.OnValue += _SpawnController;
                value.OnValue += (requester) =>
                {
                    bots.Requester = requester;
                };
            };

            Regulus.Utility.TimeCounter fps = new Regulus.Utility.TimeCounter(); ;
            while (exit == false)
            {
                if (fps.Second > 1.0 / 60)
                {
                    updater.Update();
                    fps.Reset();
                }
            }
            application.Command.Unregister("Bot");
            application.Command.Unregister("quit");
            application.Stop();
        }
Esempio n. 11
0
        public BatchCommander(Regulus.Utility.Command command, Regulus.Utility.ConsoleViewer viewer)
        {
            _Timer = new Regulus.Utility.TimeCounter();

            command.Register("1", _1);
            command.Register("2", _2);
            command.Register("3", _3);
            command.Register("4", _4);

            this._Command = command;

            _CommandStrings = new Queue<CommandString>();
            _CommandStrings.Enqueue(new CommandString() { Name = "standalong" , Args = new string[]{}});

            _CommandStrings.Enqueue(new CommandString() { Name = "spawncontroller", Args = new string[] { "茄子"} });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectcontroller", Args = new string[] { "茄子" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "ready", Args = new string[] { } });
            _CommandStrings.Enqueue(new CommandString() { Name = "login", Args = new string[] { "1" ,"1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectactor", Args = new string[] {"123" } });

            _CommandStrings.Enqueue(new CommandString() { Name = "spawncontroller", Args = new string[] { "彥龍" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectcontroller", Args = new string[] { "彥龍" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "ready", Args = new string[] {} });
            _CommandStrings.Enqueue(new CommandString() { Name = "login", Args = new string[] { "2", "1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectactor", Args = new string[] { "456" } });

            /*_CommandStrings.Enqueue(new CommandString() { Name = "spawncontroller", Args = new string[] { "茄子1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectcontroller", Args = new string[] { "茄子1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "login", Args = new string[] { "1", "1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectactor", Args = new string[] { "123" } });

            _CommandStrings.Enqueue(new CommandString() { Name = "spawncontroller", Args = new string[] { "彥龍1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectcontroller", Args = new string[] { "彥龍1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "login", Args = new string[] { "2", "1" } });
            _CommandStrings.Enqueue(new CommandString() { Name = "selectactor", Args = new string[] { "456" } });*/

            _CommandStrings.Enqueue(new CommandString() { Name = "inbattle", Args = new string[] { } });
        }
Esempio n. 12
0
 public BotRunStage()
 {
     _TimeUp = new Regulus.Utility.TimeCounter();
 }
Esempio n. 13
0
        bool Utility.IUpdatable.Update()
        {
            if (_NeedRecover)
            {
                if (_Team.MemberAmount() == 0)
                {
                    if (_IdleTime == null)
                    {
                        _IdleTime = new Utility.TimeCounter();
                    }
                    else if (_IdleTime.Second >= 30f)
                    {
                        return false;
                    }
                }
                else
                {
                    _IdleTime = null;
                }
            }

            _Updater.Update();
            return true;
        }
Esempio n. 14
0
 public ActorDoWakin(Serializable.EntityPropertyInfomation property)
 {
     Timer = new Utility.TimeCounter();
     this._Property = property;
 }
Esempio n. 15
0
        private static List <Suit> _SingThread(PropertyValue[] filterPropertys, int outAmount, Property[] propertys, Card[] cards1, Card[] cards2, Card[] cards3, Card[] cards4, Card[] cards5, Card[] cards6, Card[] cards7, Card[] cards8, System.Int64 total)
        {
            int count = 0;

            Regulus.Utility.TimeCounter timeCounter = new Regulus.Utility.TimeCounter();

            List <Suit> suits = new List <Suit>();


            foreach (var card1 in cards1)
            {
                foreach (var card2 in cards2)
                {
                    foreach (var card3 in cards3)
                    {
                        foreach (var card4 in cards4)
                        {
                            foreach (var card5 in cards5)
                            {
                                foreach (var card6 in cards6)
                                {
                                    foreach (var card7 in cards7)
                                    {
                                        foreach (var card8 in cards8)
                                        {
                                            if (timeCounter.Second > 1)
                                            {
                                                var orders = suits.OrderBy((suit) => suit.GetValue(propertys[0]));
                                                foreach (var property in propertys.Skip(1))
                                                {
                                                    orders = orders.ThenBy((suit) => suit.GetValue(property));
                                                }

                                                suits = orders.ToList();

                                                if (suits.Count > outAmount)
                                                {
                                                    suits.RemoveRange(0, suits.Count - outAmount);
                                                }

                                                System.Console.WriteLine(string.Format("{0}/{1}...{2}", count, total, suits.Count));

                                                timeCounter.Reset();
                                            }

                                            var s = new Suit(card1, card2, card3, card4, card5, card6, card7, card8);

                                            bool pass = (from filter in filterPropertys
                                                         where s.GetValue(filter) < filter.Value
                                                         select false).Count() == 0;

                                            if (pass)
                                            {
                                                suits.Add(s);
                                            }
                                            count++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            var result = suits.OrderByDescending((suit) => suit.GetValue(propertys[0]));

            foreach (var property in propertys.Skip(1))
            {
                result = result.ThenByDescending((suit) => suit.GetValue(property));
            }

            suits = result.ToList();
            return(suits);
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            CardSet set = CardSet.Instance;

            System.Console.WriteLine("劍靈八卦牌計算器");
            System.Console.WriteLine("讀取資源檔data.txt...");

            try
            {
                var text = System.IO.File.ReadAllText("data.txt");
                set.Load(text);
            }
            catch
            {
                System.Console.WriteLine("找不到data.txt");
                return;
            }


            var filterSuits = _ShowSuitFilter();

            PropertyValue[] filterPropertys = _InputProperty();

            System.Console.Write("\n輸出格式1.csv 2.html(預設1):");
            var fileFormat = System.Console.ReadLine();

            System.Console.Write("\n輸出最大筆數:");
            var outCount = System.Console.ReadLine();

            int outAmount = 0;

            int.TryParse(outCount, out outAmount);


            Property[] propertys = filterPropertys.ToArray();
            Card[]     cards     = set.Find(propertys, filterSuits);

            var cards1 = cards.Assort(1).Fill(CardSet.Instance, 1);
            var cards2 = cards.Assort(2).Fill(CardSet.Instance, 2);
            var cards3 = cards.Assort(3).Fill(CardSet.Instance, 3);
            var cards4 = cards.Assort(4).Fill(CardSet.Instance, 4);
            var cards5 = cards.Assort(5).Fill(CardSet.Instance, 5);
            var cards6 = cards.Assort(6).Fill(CardSet.Instance, 6);
            var cards7 = cards.Assort(7).Fill(CardSet.Instance, 7);
            var cards8 = cards.Assort(8).Fill(CardSet.Instance, 8);

            System.Int64 total = cards1.Count() * cards2.Count() * cards3.Count() * cards4.Count() * cards5.Count() * cards6.Count() * cards7.Count() * cards8.Count();
            System.Console.WriteLine(string.Format("{0}筆資料比對中...請稍候", total));


            Regulus.Utility.TimeCounter runTime = new Regulus.Utility.TimeCounter();

            var suitFinder = new SuitFinder(cards1, cards2, cards3, cards4, cards5, cards6, cards7, cards8);

            Regulus.Utility.TimeCounter secondCounter = new Regulus.Utility.TimeCounter();
            suitFinder.ProgressEvent += (count, amount, found) =>
            {
                if (secondCounter.Second > 1 || count / amount == 1)
                {
                    System.Console.WriteLine(string.Format("{1}/{2} ({3:0.00}%)...{0}(已找到)", found, count, amount, (float)count / (float)amount * 100));
                    secondCounter.Reset();
                }
            };
            List <Suit> suits = suitFinder.Find(filterPropertys, outAmount);



            //List<Suit> suits = _SingThread(filterPropertys, outAmount, propertys, cards1, cards2, cards3, cards4, cards5, cards6, cards7, cards8, total);


            System.Console.WriteLine(string.Format("花費秒數{0}", runTime.Second));
            System.Console.WriteLine(string.Format("檔案寫入中..."));



            string path;

            if (fileFormat == "1")
            {
                path = _WriteCSV(_GetFileName(filterPropertys), suits.ToArray(), outAmount);
            }
            else if (fileFormat == "2")
            {
                path = _WriteHTML(_GetFileName(filterPropertys), suits.ToArray(), outAmount);
            }
            else
            {
                path = _WriteCSV(_GetFileName(filterPropertys), suits.ToArray(), outAmount);
            }


            System.Console.WriteLine("寫入完成.");
            _ShowThank();
            System.Console.ReadKey();

            System.Diagnostics.Process.Start(path);
        }
 internal void OpenEnable()
 {
     Player.OnSpawnEnableChip(this);
     _Time = new Utility.TimeCounter();
 }
Esempio n. 18
0
 public After(float interval)
 {
     // TODO: Complete member initialization
     this._Interval = interval;
     _TimeCounter = new Utility.TimeCounter();
 }
Esempio n. 19
0
 Effective(float interval)
 {
     this._Interval = interval;
     _Timer = new Utility.TimeCounter();
 }
Esempio n. 20
0
 public BotMapStage(Regulus.Project.SamebestKeys.IUser _User)
 {
     this._User = _User;
     _TimeCounter = new Regulus.Utility.TimeCounter();
     _Timeup = Regulus.Utility.Random.Next(1, 10);
 }
Esempio n. 21
0
 public BotEmoStage(Regulus.Project.SamebestKeys.IPlayer _Player)
 {
     _TimeCounter = new Regulus.Utility.TimeCounter();
     this._Player = _Player;
 }
Esempio n. 22
0
        public List <Suit> Find(PropertyValue[] filter_propertys, int out_amount)
        {
            object      suitSetLock = new object();
            List <Suit> suitSet     = new List <Suit>();


            var rangePartitioner = System.Collections.Concurrent.Partitioner.Create(0, _Total());

            object readLock = new object();
            int    reads    = 0;

            System.Threading.SpinWait sw = new System.Threading.SpinWait();
            Parallel.ForEach(rangePartitioner, (range, loopState) =>
            {
                Regulus.Utility.TimeCounter time = new Regulus.Utility.TimeCounter();
                List <Suit> suits = new List <Suit>();
                int count         = 0;
                //var range = new {Item1 = 0 , Item2 = _Total()};
                for (long i = range.Item2 - 1; i >= range.Item1; --i, ++count)
                {
                    int[] indexs = _GetIndexs(i);
                    var s        = new Suit(
                        _GetCard(0, indexs[0]),
                        _GetCard(1, indexs[1]),
                        _GetCard(2, indexs[2]),
                        _GetCard(3, indexs[3]),
                        _GetCard(4, indexs[4]),
                        _GetCard(5, indexs[5]),
                        _GetCard(6, indexs[6]),
                        _GetCard(7, indexs[7]));

                    bool pass = (from filter in filter_propertys
                                 where s.GetValue(filter) < filter.Value
                                 select false).Count() == 0;
                    sw.SpinOnce();
                    if (pass)
                    {
                        suits.Add(s);
                    }

                    if (time.Second > 1)
                    {
                        lock (readLock)
                        {
                            reads += count;
                            count  = 0;
                        }

                        _UpdateSet(ref suitSet, filter_propertys, out_amount, suitSetLock, reads, suits);
                        suits.Clear();
                        time.Reset();

                        sw.SpinOnce();
                    }
                }

                lock (readLock)
                {
                    reads += count;
                    count  = 0;
                }
                _UpdateSet(ref suitSet, filter_propertys, out_amount, suitSetLock, reads, suits);
            });



            var result = suitSet.OrderByDescending((suit) => suit.GetValue(filter_propertys[0]));

            foreach (var property in filter_propertys.Skip(1))
            {
                result = result.ThenByDescending((suit) => suit.GetValue(property));
            }

            return(result.ToList());
        }