Пример #1
0
        // Use this for initialization
        void Start()
        {
            player = GameObject.Find("Player");
            GameObject An;
            GameObject Sa;

            AnQueue    = new Queue();
            SaQueue    = new Queue();
            startShoot = true;
            for (int i = 0; i < EmotionNum; i++)
            {
                An = Instantiate(AngerUp, Vector2.zero, Quaternion.identity) as GameObject;
                //An.transform.parent = this.gameObject.transform;
                An.GetComponent <EmotionBullet>().m_EmotionTurret = this.gameObject;
                AnQueue.Enqueue(An);
                An.SetActive(false);

                Sa = Instantiate(SadUp, Vector2.zero, Quaternion.identity) as GameObject;
                //Sa.transform.parent = this.gameObject.transform;
                Sa.GetComponent <EmotionBullet>().m_EmotionTurret = this.gameObject;
                SaQueue.Enqueue(Sa);
                Sa.SetActive(false);

                Debug.Log(AnQueue.Count);
            }
        }
        /// <summary>
        ///     Wird aufgerufen sobald die View initialisiert wurde
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override async Task OnActivated(object args = null)
        {
            if (args is object[] argsArr)
            {
                if (argsArr[0] is UiMeeting appointment && argsArr[1] is ExShop shop)
                {
                    Appointment = appointment;
                    _shop       = shop;
                    PageTitle   = shop.Name;
                    var response = await Sa.GetDefaultText(appointment.Meeting.Staff.Id);

                    if (response.Ok && response.Result != null && !string.IsNullOrWhiteSpace(response.Result.PlaceholderText))
                    {
                        Placeholder = response.Result.PlaceholderText;
                    }
                    else
                    {
                        Placeholder = ResViewAppointmentInfo.LblShopAdditionalInfo;
                    }
                }
            }
            else
            {
                await Nav.Back();
            }
        }
Пример #3
0
        /// <summary>
        ///     Commands Initialisieren (aufruf im Kostruktor von VmBase)
        /// </summary>
        protected override void InitializeCommands()
        {
            CmdSave = new VmCommand(ResViewEditUser.CmdSaveName, async() =>
            {
                IsBusy = true;

                var d        = BissClone.Clone(UserAccountData);
                d.FirstName  = Data.FirstName;
                d.LastName   = Data.LastName;
                d.City       = Data.City;
                d.PostalCode = Data.PostalCode;
                d.Street     = Data.Street;

                var r = await Sa.UserUpdate(d);
                if (await this.CheckRestStatusResult(r.Status) &&
                    await this.CheckSaveResult(r.Result))
                {
                    CheckSaveBehavior = null;
                    UserAccountData   = d;
                    FileExtensions.BcFiles(null).UserAppData.Save(d);
                    ViewResult = Data;

                    ContinueNavigation();
                }

                IsBusy = false;
            }, () => CheckSaveBehavior != null && CheckSaveBehavior.Check(), ResViewEditUser.CmdSaveTooltip);

            CmdSkip = new VmCommand(ResViewEditUser.CmdSkipName, async() =>
            {
                CheckSaveBehavior = null;
                ContinueNavigation();
            });
        }
Пример #4
0
 private static int GetMark(Pod root, int i, int c)
 {
     var p = Sa.FindMark(root, GetFinder(i), GetHasMark(i, c));
     if (p == null) return 0;
     if (p.MaxSt[c] > 0) return p.MaxSt[c];
     return p.Max[c];
 }
        /// <summary>
        ///     Wird aufgerufen sobald die View initialisiert wurde
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override async Task OnActivated(object args = null)
        {
            var data = await Sa.GetAppInfo();

            if (data.Ok && data.Result != null)
            {
                AppInfo = data.Result;
            }
        }
        /// <summary>
        ///     Commands Initialisieren (aufruf im Kostruktor von VmBase)
        /// </summary>
        protected override void InitializeCommands()
        {
            CmdAbort = new VmCommand("", () => { Nav.ToView("ViewMain"); });
            CmdScheduleAppointment = new VmCommand("", async() =>
            {
                var response = await Sa.SetMeeting(new ExSaveMeetingRequest
                {
                    OptionalText = InfoText,
                    LocationId   = _shop.Id,
                    StartTime    = Appointment.Meeting.Start,
                    StaffId      = Appointment.Meeting.Staff.Id,
                    UserId       = UserAccountData.UserId
                });

                if (response.Ok && response.Result.Result == EnumSaveDataResult.Ok)
                {
                    Nav.ToView("ViewAppointments", response.Result.Data);
                }
                else
                {
                    await MsgBox.Show(ResViewAppointmentInfo.MsgBoxCreateAppointmentError, ResViewAppointmentInfo.MsgBoxCreateAppointmentCaption);
                }
            });
        }
Пример #7
0
        /// <summary>
        ///     Commands Initialisieren (aufruf im Kostruktor von VmBase)
        /// </summary>
        protected override void InitializeCommands()
        {
            CmdChangeUserData = new VmCommand(ResViewUser.CmdChangeUserData, async() =>
            {
                IsBusy = true;

                var d        = BissClone.Clone(UserAccountData);
                d.FirstName  = Data.FirstName;
                d.LastName   = Data.LastName;
                d.City       = Data.City;
                d.PostalCode = Data.PostalCode;
                d.Street     = Data.Street;

                var r = await Sa.UserUpdate(d);
                if (await this.CheckRestStatusResult(r.Status) &&
                    await this.CheckSaveResult(r.Result))
                {
                    CheckSaveBehavior = null;
                    UserAccountData   = d;
                    FileExtensions.BcFiles(null).UserAppData.Save(d);
                    ViewResult = Data;
                }

                IsBusy = false;
                UpdateData();
            }, () => CheckSaveBehavior != null && CheckSaveBehavior.Check());

            CmdChangePassword = new VmCommand(ResViewUser.CmdChangePassword, async() => { await Nav.ToViewWithResult("ViewEditPassword"); }, () => _dataLoaded);

            CmdLogout = new VmCommand(ResViewUser.CmdLogout, async() =>
            {
                FileExtensions.BcFiles(null).UserAppData.Delete();
                UserAccountData = null;
                await DeviceInfoDelete();
                if (Constants.SupportLogin)
                {
                    AppCenter.UpdateCurrentUser("", "");
                }
                UpdateMenu();
                Nav.ToView("ViewMain");
            });

            CmdDeleteAccount = new VmCommand(ResViewUser.CmdDeleteAccount, async() =>
            {
                var res = await MsgBox.Show(ResViewUser.MsgBoxDeleteAccount, ResViewUser.MsgBoxDeleteAccountCaption, VmMessageBoxButton.YesNo);

                if (res == VmMessageBoxResult.Yes)
                {
                    IsBusy = true;

                    var saRes = await Sa.DeleteUser(UserAccountData.UserId);

                    if (await this.CheckRestStatusResult(saRes.Status))
                    {
                        CheckSaveBehavior = null;
                        CmdLogout.Execute(null);
                    }

                    IsBusy = false;
                }
            });
        }
Пример #8
0
        public int solution(int[] A)
        {
#if PROFILING
            var profiler = new SpeedProfiler();
            profiler.Start("Loading and Sorting");
#endif

            var N = A.Length;
#if PRINT_PROGRAM
            Console.WriteLine("A:");
            for (var i = 0; i < N; i++)
            {
                Console.Write($" {A[i]}");
            }
            Console.WriteLine();
#endif
            var pods = Sa.Load(A, x => new Pod { XPos = x }).ToArray();
            for (var i = 0; i < N; i++)
            {
                pods[i].YPos = i;
            }
            Array.Sort(pods);
            for (var i = 0; i < N; i++)
            {
                pods[i].Index = i;
            }

            var ytopod = new int[N];
            for (var i = 0; i < N; i++)
            {
                ytopod[pods[i].YPos] = i;
            }
#if PROFILING
            profiler.Stop("Loading and Sorting");
            profiler.Start("Treefication");
#endif
            var root = Sa.Treeify(pods);
#if PROFILING
            profiler.Stop("Treefication");
            profiler.Start("DP");
#endif
            var max0 = 0;
            var max1 = 0;
            var max2 = 0;

#if DEBUG_PROGRAM
            Console.WriteLine($"N = {N}");
            void SnapShot(out int[] p0, out int[] p1, out int[] p2)
            {
                p0 = new int[N];
                p1 = new int[N];
                p2 = new int[N];
                for (var i = 0; i < N; i++)
                {
                    p0[i] = GetMark(root, i, 0);
                    p1[i] = GetMark(root, i, 1);
                    p2[i] = GetMark(root, i, 2);
                }
            }
            void Print(int c)
            {
                for (var i = 0; i < N; i++)
                {
                    var m = GetMark(root, i, c);
                    Console.Write($" {m}");
                }
                Console.WriteLine();
            }
            void PrintSnapshot(int[] snapshot)
            {
                for (var i = 0; i < N; i++)
                {
                    Console.Write($" {snapshot[i]}");
                }
                Console.WriteLine();
            }
            bool CheckMonotonity(int c, bool decrease)
            {
                int? last = null;
                for (var i = 0; i < N; i++)
                {
                    var m = GetMark(root, i, c);
                    if (!decrease && m < last)
                    {
                        return false;
                    }
                    if (decrease && m > last)
                    {
                        return false;
                    }
                    last = m;
                }
                return true;
            }
#endif

            for (var i = 0; i < N; i++)
            {
                var podi = ytopod[i];
                var pod = pods[podi];

#if PROFILING
                profiler.Start("Get Mark");
#endif

                var pod0 = i == 0 ? 0 : GetMark(root, podi, 0);
                var pod1 = i == 0 ? 0 : GetMark(root, podi, 1);
                var pod2 = i == 0 ? 0 : GetMark(root, podi, 2);

#if PROFILING
                profiler.Stop("Get Mark");
#endif

#if PRINT_PROGRAM
                Console.WriteLine($"{i}:");
#endif
#if DEBUG_PROGRAM
                SnapShot(out var oldp0, out var oldp1, out var oldp2);
#endif

                // 0
                var new0 = pod0 + 1;

#if PROFILING
                profiler.Start("Find First");
#endif
                var end0 = i == 0 ? N : FindFirstNoLess(root, new0, 0, false, N);
#if PROFILING
                profiler.Stop("Find First");
                profiler.Start("Mark");
#endif
                Mark(pod, pods[end0 - 1], 0, new0);
#if PROFILING
                profiler.Stop("Mark");
#endif
#if DEBUG_PROGRAM
                var cr = CheckMonotonity(0, false);
#if !PRINT_PROGRAM
                if (!cr)
#endif
                {
#endif
#if DEBUG_PROGRAM || PRINT_PROGRAM
                    Console.WriteLine($" {i} cmp 0 mark {pod.Index} to {end0 - 1} as {new0}:");
                    PrintSnapshot(oldp0);
                    Print(0);
#endif
#if DEBUG_PROGRAM
                    System.Diagnostics.Debug.Assert(cr);
                }
#endif
                // 1
#if PROFILING
                profiler.Start("Find First");
#endif
                var new1 = Math.Max(pod1 + 1, max0 + 1);
                var end1 = i == 0 ? -1 : FindFirstNoLess(root, new1, 1, true, N);
#if PROFILING
                profiler.Stop("Find First");
                profiler.Start("Mark");
#endif
                Mark(pods[end1 + 1], pod, 1, new1);
#if PROFILING
                profiler.Stop("Mark");
#endif
#if DEBUG_PROGRAM
                cr = CheckMonotonity(1, true);
#if !PRINT_PROGRAM
                if (!cr)
#endif
                {
#endif
#if DEBUG_PROGRAM || PRINT_PROGRAM
                    Console.WriteLine($" {i} cmp 1 mark {end1 + 1} to {pod.Index} as {new1}:");
                    PrintSnapshot(oldp1);
                    Print(1);
#endif
#if DEBUG_PROGRAM
                    System.Diagnostics.Debug.Assert(cr);
                }
#endif
                // 2
#if PROFILING
                profiler.Start("Find First");
#endif
                var new2 = Math.Max(pod2 + 1, max1 + 1); //todo also consider max0+1?
                var end2 = i == 0 ? N : FindFirstNoLess(root, new2, 2, false, N);
#if PROFILING
                profiler.Stop("Find First");
                profiler.Start("Mark");
#endif
                Mark(pod, pods[end2 - 1], 2, new2);
#if PROFILING
                profiler.Stop("Mark");
#endif
#if DEBUG_PROGRAM
                cr = CheckMonotonity(2, false);
#if !PRINT_PROGRAM
                if (!cr)
#endif
                {
#endif
#if DEBUG_PROGRAM || PRINT_PROGRAM
                    Console.WriteLine($" {i} cmp 2 mark {pod.Index} to {end2 - 1} as {new2}:");
                    PrintSnapshot(oldp2);
                    Print(2);
#endif
#if DEBUG_PROGRAM
                    System.Diagnostics.Debug.Assert(cr);
                }
#endif

                if (new0 > max0) max0 = new0;
                if (new1 > max1) max1 = new1;
                if (new2 > max2) max2 = new2;
            }
#if PROFILING
            profiler.Stop("DP");
            profiler.Display();
#endif
            return Math.Max(Math.Max(max0, max1), max2);
        }
Пример #9
0
 private static void Mark(Pod left, Pod right, int c, int m)
     => Sa.MarkRange<int>(left, right, GenMark(c, m), GenMarkStm(c), GenGetStm(c));
 public SbFactory(Sa sa) => _sa = sa;