Example #1
0
        protected override void InternalAfterLogin()
        {
            SubTaskMgr.Instance.InitEntityTasks(this);
            m_loginFlag = true;

            if (!m_subAccountInfo.Check)
            {
                var wait = FlowLogicHelper.RepeatRun(() =>
                {
                    var view  = WlyViewMgr.GetView(WlyViewType.略_防沉迷验证);
                    var view1 = WlyViewMgr.GetView(WlyViewType.略_跳过);
                    return(DMService.Instance.FindPic(DMGuid, WlyPicType.择国家, WlyUtilityBiz.GameWndRect) || view.IsCurrentView(DMGuid) ||
                           view1.IsCurrentView(DMGuid));
                }, TimeSpan.FromSeconds(30));
                if (wait && DMService.Instance.FindPic(DMGuid, WlyPicType.择国家, WlyUtilityBiz.GameWndRect))
                {
                    CreateRole(AutoPlayerVM.Instance.GetAvailableName());
                }
            }

            WxLog.Debug($"SubEntity.InternalAfterLogin AutoPlay Start <{m_subAccountInfo.Name}>");

            // 先检测主公等级
            var level = WlyUtilityBiz.GetMainLevel(DMGuid);

            if (level > m_subAccountInfo.Level)
            {
                WlyMainLevelMgr.Upgrade(DMGuid);
                m_subAccountInfo.Level = level;
                m_subAccountInfo.Save();
            }

            // 检测银币数量是否到达上限
            var result = WlyUtilityBiz.GetPercent(DMGuid, new WxRect(133, 26, 217, 47), "f3f3da-000000", out var percent);

            if (!result)
            {
                throw new InvalidOperationException("Cannot Get Money Amount");
            }

            // 银币超过上限了,想尽办法进行使用
            if (percent >= 0.9)
            {
                GetEuqipments();
                UpgradeEquipments();
            }

            // 如果可以捐国政了,则捐国政
            var now       = DateTime.Now;
            var timeNotOK = (now.DayOfWeek == DayOfWeek.Sunday) && (now.Hour >= 4) && (now.Hour < 21);

            if ((percent >= 0.5) && (m_subAccountInfo.GetBuildingInfo(WlyBuildingType.主城).Level >= 130) && !timeNotOK)
            {
                // 捐款2600万获取100政绩
                WlyViewMgr.GoTo(DMGuid, WlyViewType.场景_国政);

                // 点开内政
                var wait = FlowLogicHelper.RepeatRun(() =>
                {
                    DMService.Instance.LeftClick(DMGuid, new WxPoint(95, 42));
                    if (DMService.Instance.FindStr(DMGuid, new WxRect(483, 100, 516, 120), "国政", WlyColor.Normal))
                    {
                        return(true);
                    }

                    Thread.Sleep(500);
                    return(false);
                }, TimeSpan.FromSeconds(10));
                if (!wait)
                {
                    throw new InvalidOperationException();
                }

                // 捐款铸造
                DMService.Instance.LeftClick(DMGuid, new WxPoint(560, 270));
                DMService.Instance.LeftClick(DMGuid, new WxPoint(613, 438));
                DMService.Instance.SendString(DMGuid, WndHwnd, "50000000");

                wait = FlowLogicHelper.RepeatRun(() =>
                {
                    if (WlyUtilityBiz.GetAmount(DMGuid, new WxRect(577, 429, 671, 447), "e7e7fd-000000", out var amount))
                    {
                        return(true);
                    }

                    Thread.Sleep(500);
                    return(false);
                }, TimeSpan.FromSeconds(10));
                if (!wait)
                {
                    throw new InvalidOperationException();
                }

                DMService.Instance.LeftClick(DMGuid, new WxPoint(739, 438));
            }

            // 如果可以进行开发,则马上开发并立刻结束
            //if (DevelopTime < DateTime.Now)
            //{
            //    WlyUtilityBiz.GetAmount(DMGuid, new WxRect(133, 26, 217, 47), "f3f3da-000000", out var amount);
            //    if (amount > 500000)
            //    {
            //        DevelopCity();
            //        //Stop();
            //    }
            //}
        }