public ResponseModel <Rescue> Add(Rescue entity)
        {
            ResponseModel <Rescue> _rescue = new ResponseModel <Rescue>();

            try
            {
                var record = database.Insert(entity);
                if (record > 0)
                {
                    _rescue.Message = "Record has been inserted";
                    _rescue.Status  = true;
                }
                else
                {
                    _rescue.Message = "Something went wrong";
                    _rescue.Status  = false;
                }
            }
            catch (Exception ex)
            {
                _rescue.Message = ex.Message;
                _rescue.Status  = false;
            }
            return(_rescue);
        }
Exemple #2
0
 private void Start()
 {
     FG     = GameObject.Find("FireGenerator").GetComponent <FireGenerator>();
     MM     = GameObject.Find("MapManager").GetComponent <MapManager>();
     RES    = GameObject.Find("RescuGenerator").GetComponent <Rescue>();
     playAP = SUI.AP;
 }
Exemple #3
0
        public bool LaunchNotification(UILocalNotification notification, bool isMainLauncher)
        {
            bool     didLaunch = false;
            NSString key       = new NSString("rescue_id");

            if (notification != null && notification.UserInfo != null && notification.UserInfo.ContainsKey(key)) //TODO:Should: Remove inline constant
            {
                string rescueID = notification.UserInfo[key].ToString();
                Rescue rescue   = Container.EscapeApp.RescueGetById(new Guid(rescueID));
                if (rescue != null)
                {
                    NotificationController notificationController = this.MainStoryboard.InstantiateViewController(NotificationController.IDENTIFIER) as NotificationController;
                    notificationController.Rescue = rescue;

                    // start with a new nav
                    UINavigationController navController = new UINavigationController(notificationController);
                    navController.NavigationBarHidden = true;
                    this.ChangeRootViewController(navController, UIViewAnimationOptions.TransitionNone);
                    didLaunch = true;
                }
            }


            if (!didLaunch && isMainLauncher)
            {
                this.LaunchMain();
            }

            return(didLaunch);
        }
Exemple #4
0
    private void setupRescue()
    {
        int iRescueCount = 2;

        rescues = new List <Rescue>();

        int i;
        int iRandRow, iRandCol;

        List <Cell> cellsAvailable = new List <Cell>();

        foreach (Cell cell in cells)
        {
            cellsAvailable.Add(cell);
        }

        for (i = 0; i < iRescueCount; i++)
        {
            if (cellsAvailable.Count > 0)
            {
                Cell randCell = cellsAvailable[Random.Range(0, cellsAvailable.Count)];
                cellsAvailable.Remove(randCell);
                Rescue rescue = Instantiate(RescuePrefab, new Vector3(randCell.transform.position.x, 0f, randCell.transform.position.z), Quaternion.identity).GetComponent <Rescue>();
                rescue.transform.SetParent(this.transform);
                rescues.Add(rescue);
            }
        }
    }
Exemple #5
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                Rescue          data = this.Controller.ViewModel.Rescues[indexPath.Row];
                UITableViewCell cell = tableView.DequeueReusableCell("CellRescue");

                cell.TextLabel.Text = data.title;
                return(cell);
            }
Exemple #6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Rescue rescue = JsonConvert.DeserializeObject <Rescue>(e.Parameter.ToString());

            txtTitle.Text = rescue.title;
            txtBody.Text  = rescue.body;
        }
Exemple #7
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.transform.tag == "fire")
     {
         isFire = false;
         cdr    = null;
     }
     else if (collision.transform.tag == "rescue")
     {
         isRescue = false;
         res      = null;
     }
 }
Exemple #8
0
    private void doRescue(Cell in_Cell)
    {
        Rescue rescue = gamemanager.board.getRescue(in_Cell);

        if (rescue != null)
        {
            rescue.setRescued(true);
        }
        gamemanager.board.resetSelectedRowCol();
        targetCell = null;

        gamemanager.board.checkLevelComplete();
    }
Exemple #9
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.transform.tag == "fire")
     {
         isFire = true;
         cdr    = collision.GetComponent <Fire>();
     }
     else if (collision.transform.tag == "rescue")
     {
         isRescue = true;
         res      = collision.GetComponent <Rescue>();
     }
 }
Exemple #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.SetContentView(Resource.Layout.Notification);

            string rescueString = this.Intent.GetStringExtra("rescue");
            Rescue rescue       = JsonConvert.DeserializeObject <Rescue>(rescueString);

            TextView txtTitle = this.FindViewById <TextView>(Resource.Id.general_title);
            TextView txtBody  = this.FindViewById <TextView>(Resource.Id.general_body);

            txtTitle.Text = rescue.title;
            txtBody.Text  = rescue.body;
        }
Exemple #11
0
 protected override void DeleteInternal()
 {
     if (Engine)
     {
         Engine.Dismiss();
     }
     if (Battalion)
     {
         Battalion.Dismiss();
     }
     if (Rescue)
     {
         Rescue.Dismiss();
     }
     StopAlarm();
 }
Exemple #12
0
        protected void Create()
        {
            try
            {
                TextView txtTitle = this.FindViewById <TextView>(Resource.Id.rescue_title);
                TextView txtBody  = this.FindViewById <TextView>(Resource.Id.rescue_body);
                TextView txtWhen  = this.FindViewById <TextView>(Resource.Id.rescue_when);

                DateTime parsed = default(DateTime);
                if (!DateTime.TryParse(txtWhen.Text, out parsed) || parsed == default(DateTime))
                {
                    throw new Exception("You must provide a valid date");
                }
                Rescue rescue = new Rescue()
                {
                    rescue_id = Guid.NewGuid(),
                    stamp_utc = parsed,
                    title     = txtTitle.Text,
                    body      = txtBody.Text
                };

                TimeSpan fromNow = rescue.stamp_utc - DateTime.Now;

                Intent alarmIntent = new Intent(this, typeof(AlarmReceiver));
                alarmIntent.PutExtra("rescue", JsonConvert.SerializeObject(rescue));

                PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);

                AlarmManager alarmManager = (AlarmManager)this.GetSystemService(Context.AlarmService);
                alarmManager.Set(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + (long)fromNow.TotalMilliseconds, pendingIntent);

                this.ViewModel.AddRescue(rescue);

                //TODO:Could:Notify success first.

                this.Finish();
            }
            catch (Exception ex)
            {
                new Android.Support.V7.App.AlertDialog.Builder(this)
                .SetTitle("Error")
                .SetMessage(ex.Message)
                .SetPositiveButton("Okay", new EventHandler <DialogClickEventArgs>((s, e) => {}))
                .Show();
            }
        }
Exemple #13
0
        private void Create()
        {
            try
            {
                DateTime parsed = default(DateTime);
                if (!DateTime.TryParse(txtWhen.Text, out parsed) || parsed == default(DateTime))
                {
                    throw new Exception("You must provide a valid date");
                }
                Rescue rescue = new Rescue()
                {
                    rescue_id = Guid.NewGuid(),
                    stamp_utc = parsed,
                    title     = txtTitle.Text,
                    body      = txtBody.Text
                };

                string jsonString = JsonConvert.SerializeObject(rescue);

                // create notification here
                XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                var         strings  = toastXml.GetElementsByTagName("text");
                strings[0].AppendChild(toastXml.CreateTextNode(rescue.title));
                strings[1].AppendChild(toastXml.CreateTextNode(rescue.body));
                XmlElement toastElement = ((XmlElement)toastXml.SelectSingleNode("/toast"));
                toastElement.SetAttribute("launch", "#/Pages/Notification.xaml?rescue=" + jsonString);

                ScheduledToastNotification toast = new ScheduledToastNotification(toastXml, rescue.stamp_utc);
                toast.Id = rescue.ToString();

                Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);



                this.ViewModel.AddRescue(rescue);

                //TODO:Could:Notify success first.

                this.Frame.GoBack();
            }
            catch (Exception ex)
            {
                new MessageDialog(ex.Message, "Error").ShowAsync();
            }
        }
Exemple #14
0
    public Rescue getRescue(Cell in_Cell)
    {
        Rescue rescueReturn = null;

        if (in_Cell != null)
        {
            Debug.Log("resuces: " + rescues.Count);
            foreach (Rescue rescue in rescues)
            {
                if (rescue.transform.position.x == in_Cell.transform.position.x &&
                    rescue.transform.position.z == in_Cell.transform.position.z)
                {
                    rescueReturn = rescue;
                }
            }
        }

        return(rescueReturn);
    }
        public void Should_complete_the_rescue_vane()
        {
            var success = new TestSuccess();

            var fail = new TestFail();
            var middle = new TestVane();
            var rescue = new Rescue<TestSubject>(success);
            Vane<TestSubject> vane = Vane.Connect(fail, rescue, middle);

            Assert.IsTrue(vane.Execute(_testSubject));

            Assert.IsTrue(fail.AssignCalled);
            Assert.IsTrue(fail.ExecuteCalled);
            Assert.IsFalse(fail.CompensateCalled);

            Assert.IsTrue(middle.AssignCalled);
            Assert.IsTrue(middle.ExecuteCalled);
            Assert.IsTrue(middle.CompensateCalled);

            Assert.IsTrue(success.AssignCalled);
        }
Exemple #16
0
        protected void DoCreate()
        {
            try
            {
                DateTime parsed = default(DateTime);
                if (!DateTime.TryParse(txtWhen.Text, out parsed) || parsed == default(DateTime))
                {
                    throw new Exception("You must provide a valid date");
                }
                Rescue rescue = new Rescue()
                {
                    rescue_id = Guid.NewGuid(),
                    stamp_utc = parsed,
                    title     = txtTitle.Text,
                    body      = txtBody.Text
                };

                UILocalNotification localNofication = new UILocalNotification()
                {
                    FireDate   = rescue.stamp_utc.ToNSDate(),
                    TimeZone   = NSTimeZone.LocalTimeZone,
                    AlertTitle = rescue.title,
                    AlertBody  = rescue.body,
                    UserInfo   = NSDictionary.FromObjectAndKey(new NSString(rescue.rescue_id.ToString()), new NSString("rescue_id"))
                };
                UIApplication.SharedApplication.ScheduleLocalNotification(localNofication);

                this.ViewModel.AddRescue(rescue);

                //TODO:Could:Notify success first.

                this.NavigationController.PopViewController(true);
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.Message, null, "Okay").Show();
            }
        }
Exemple #17
0
        public override void OnReceive(Context context, Intent intent)
        {
            //TODO:SHOULD: Verify Intent Extra
            string rescueString = intent.GetStringExtra("rescue");
            Rescue rescue       = JsonConvert.DeserializeObject <Rescue>(rescueString);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                                 .SetStyle(new NotificationCompat.InboxStyle())
                                                 .SetSmallIcon(Resource.Drawable.launch)
                                                 .SetContentTitle(rescue.title)
                                                 .SetContentText(rescue.body);

            Intent resultIntent = new Intent(context, typeof(NotificationActivity));

            resultIntent.PutExtra("rescue", rescueString);
            PendingIntent resultPendingIntent = PendingIntent.GetActivity(context, 0, resultIntent, PendingIntentFlags.UpdateCurrent);

            //TODO:MUST: Inject the back stack so that the back button works as we want
            builder.SetContentIntent(resultPendingIntent);

            NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);

            notificationManager.Notify(0, builder.Build());
        }
Exemple #18
0
        private void Update()
        {
            if (SceneManager.GetActiveScene().buildIndex == 0)
            {
                Destroy(gameObject);
            }

            if (SceneManager.GetActiveScene().buildIndex != SceneManager.sceneCount - 1)
            {
                // Destroy on main menu to clear data
                if (SceneManager.GetActiveScene().buildIndex == 0)
                {
                    Destroy(gameObject);
                }

                if (inDialogue)
                {
                    var mouse = Mouse.current;
                    if (mouse.leftButton.wasPressedThisFrame)
                    {
                        if (dialog.finishedTyping)
                        {
                            if (_currentMsg < _currentDialogue.dialogue.Count - 1)
                            {
                                _currentMsg++;
                                RunMessage(_currentDialogue.dialogue[_currentMsg]);
                            }
                            else
                            {
                                FinishDialogue();
                                PlayerController.Instance.PostDialogeHotfix();
                            }
                        }
                        else
                        {
                            dialog.QuickFinish();
                        }
                    }
                }

                hud.companionCounter.text = FindObjectsOfType <CompanionAI>().Length.ToString();

                UpdateObjectiveCount();

                // Iterate over enemies and find closest
                var state = PlayerState.Instance;
                int kills = state.killedOverall.Count + state.killedThisLife.Count;

                if (kills < _enemyCount || bossBattle)
                {
                    var enemies = FindObjectsOfType <EnemyAI>();
                    var plr     = PlayerController.Instance;
                    if (enemies.Length > 0)
                    {
                        var     smallestDistance = Single.MaxValue;
                        EnemyAI closest          = null;
                        foreach (var enemy in enemies)
                        {
                            var dist = enemy.transform.position - plr.transform.position;
                            if (dist.magnitude < smallestDistance)
                            {
                                smallestDistance = dist.magnitude;
                                closest          = enemy;
                            }
                        }

                        if (closest != null)
                        {
                            var viewportPos = Camera.main.WorldToViewportPoint(closest.transform.position);
                            if (viewportPos.x < 0 || viewportPos.x > 1 || viewportPos.y < 0 || viewportPos.y > 1)
                            {
                                var dir = closest.transform.position - plr.transform.position;

                                var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
                                indicatorArrow.rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                                indicatorArrow.rectTransform.position =
                                    uiCenter.position + dir.normalized * indicatorRadius;
                                indicatorArrow.gameObject.SetActive(true);
                                indicatorArrow.color = enemyIndicator;
                            }
                            else
                            {
                                indicatorArrow.gameObject.SetActive(false);
                            }
                        }
                        else
                        {
                            indicatorArrow.gameObject.SetActive(false);
                        }
                    }
                    else
                    {
                        var boss        = FindObjectOfType <BossManager>();
                        var viewportPos = Camera.main.WorldToViewportPoint(boss.transform.position);
                        if (viewportPos.x < 0 || viewportPos.x > 1 || viewportPos.y < 0 || viewportPos.y > 1)
                        {
                            var dir = boss.transform.position - plr.transform.position;

                            var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
                            indicatorArrow.rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                            indicatorArrow.rectTransform.position =
                                uiCenter.position + dir.normalized * indicatorRadius;
                            indicatorArrow.gameObject.SetActive(true);
                            indicatorArrow.color = enemyIndicator;
                        }
                        else
                        {
                            indicatorArrow.gameObject.SetActive(false);
                        }
                    }
                }
                else
                {
                    var plr        = PlayerController.Instance;
                    var companions = FindObjectsOfType <Rescue>();
                    var boss       = FindObjectOfType <BossManager>();
                    if (boss == null)
                    {
                        return;
                    }

                    if (companions.Length > 0 && boss.exitDoor.locked)
                    {
                        var    smallestDistance = Single.MaxValue;
                        Rescue closest          = null;
                        foreach (var companion in companions)
                        {
                            var dist = companion.transform.position - plr.transform.position;
                            if (dist.magnitude < smallestDistance)
                            {
                                smallestDistance = dist.magnitude;
                                closest          = companion;
                            }
                        }

                        if (closest != null)
                        {
                            var viewportPos = Camera.main.WorldToViewportPoint(closest.transform.position);
                            if (viewportPos.x < 0 || viewportPos.x > 1 || viewportPos.y < 0 || viewportPos.y > 1)
                            {
                                var dir = closest.transform.position - plr.transform.position;

                                var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
                                indicatorArrow.rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                                indicatorArrow.rectTransform.position =
                                    uiCenter.position + dir.normalized * indicatorRadius;
                                indicatorArrow.gameObject.SetActive(true);
                                indicatorArrow.color = companionIndicator;
                            }
                            else
                            {
                                indicatorArrow.gameObject.SetActive(false);
                            }
                        }
                        else
                        {
                            indicatorArrow.gameObject.SetActive(false);
                        }
                    }
                    else
                    {
                        if (boss.exitDoor.locked)
                        {
                            var viewportPos = Camera.main.WorldToViewportPoint(boss.entryDoor.transform.position);
                            if (viewportPos.x < 0 || viewportPos.x > 1 || viewportPos.y < 0 || viewportPos.y > 1)
                            {
                                var dir = boss.entryDoor.transform.position - plr.transform.position;

                                var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
                                indicatorArrow.rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                                indicatorArrow.rectTransform.position =
                                    uiCenter.position + dir.normalized * indicatorRadius;
                                indicatorArrow.gameObject.SetActive(true);
                                indicatorArrow.color = enemyIndicator;
                            }
                            else
                            {
                                indicatorArrow.gameObject.SetActive(false);
                            }
                        }
                        else
                        {
                            var viewportPos = Camera.main.WorldToViewportPoint(boss.exitDoor.transform.position);
                            if (viewportPos.x < 0 || viewportPos.x > 1 || viewportPos.y < 0 || viewportPos.y > 1)
                            {
                                var dir = boss.exitDoor.transform.position - plr.transform.position;

                                var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
                                indicatorArrow.rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                                indicatorArrow.rectTransform.position =
                                    uiCenter.position + dir.normalized * indicatorRadius;
                                indicatorArrow.gameObject.SetActive(true);
                                indicatorArrow.color = enemyIndicator;
                            }
                            else
                            {
                                indicatorArrow.gameObject.SetActive(false);
                            }
                        }
                    }
                }
            }
        }
Exemple #19
0
 private void EventBusOnRescueUpdated(object sender, Rescue rescue)
 {
     AddRescue(rescue);
 }
Exemple #20
0
        public static PlayerClass FighterClass()
        {
            var fighter = new PlayerClass
            {
                Name               = "Fighter",
                IsBaseClass        = true,
                ExperienceModifier = 500,
                HelpText           = new Help(),
                Skills             = new List <Skill>(),
                ReclassOptions     = new List <PlayerClass>(),
                MaxHpGain          = 15,
                MinHpGain          = 10,
                MaxManaGain        = 8,
                MinManaGain        = 4,
                MaxEnduranceGain   = 15,
                MinEnduranceGain   = 11,
                StatBonusStr       = 1,
                StatBonusCon       = 1,
            };

            /* TODO: some skills to add
             * Axe Dagger Polearm  Mace
             * Spear Shield Block
             * staff  sword
             *  bash Whip Enhanced damage
             *  parry rescue swim  scrolls
             *  staves  wands  recall
             *  age  dig
             *  dirt kicking
             *  second atttack
             *  third attack
             *  fouth attack
             *  fast healing
             *  kick
             *  disarm
             *  blind fighting
             *  trip
             *  berserk
             *  dual wield (eek)
             * */


            #region  Lvl 1 skills

            var longBlades = LongBlades.LongBladesAb();
            longBlades.Learned = true;
            fighter.Skills.Add(longBlades);

            var shortBlades = ShortBlades.ShortBladesAb();
            shortBlades.Learned = true;
            fighter.Skills.Add(shortBlades);

            var axe = Axe.AxeAb();
            axe.Learned = true;
            fighter.Skills.Add(axe);

            var blunt = BluntWeapons.BluntWeaponsAb();
            blunt.Learned = true;
            fighter.Skills.Add(blunt);

            var polearm = Polearms.PolearmsAb();
            polearm.Learned = true;
            fighter.Skills.Add(polearm);

            var exotic = Exotic.ExoticAb();
            exotic.Learned = true;
            fighter.Skills.Add(exotic);

            var staff = Staff.StaffAb();
            staff.Learned = true;
            fighter.Skills.Add(staff);

            var handToHand = HandToHand.HandToHandAb();
            handToHand.Learned = true;
            fighter.Skills.Add(handToHand);

            var lightArmour = LightArmour.LightArmourAb();
            lightArmour.Learned = true;
            fighter.Skills.Add(lightArmour);



            #endregion

            #region  Lvl 2 skills
            fighter.Skills.Add(HeavyArmour.HeavyArmourAb());
            fighter.Skills.Add(MediumArmour.MediumArmourAb());


            #endregion

            #region Lvl 3 skills
            fighter.Skills.Add(Trip.TripAb());
            #endregion

            #region Lvl 4
            fighter.Skills.Add(FastHealing.FastHealingAb());
            fighter.Skills.Add(Toughness.ToughnessAb());
            #endregion

            #region Lvl 5

            var parry = Parry.ParryAb();
            fighter.Skills.Add(parry);


            #endregion


            #region Lvl 6

            var shieldBlock = ShieldBlock.ShieldBlockAb();
            fighter.Skills.Add(shieldBlock);

            var dodge = Dodge.DodgeAb();
            fighter.Skills.Add(dodge);

            #endregion


            #region Lvl 7

            var dirtKick = DirtKick.DirtKickAb();
            fighter.Skills.Add(dirtKick);

            var kick = Kick.KickAb();
            fighter.Skills.Add(kick);

            #endregion

            #region Lvl 9

            var bash = Bash.BashAb();
            fighter.Skills.Add(bash);



            #endregion


            #region Lvl 10

            var rescue = Rescue.RescueAb();
            fighter.Skills.Add(rescue);



            #endregion

            #region Lvl 11

            var sneak = Sneak.SneakAb();
            fighter.Skills.Add(sneak);



            #endregion


            #region Lvl 12
            fighter.Skills.Add(SecondAttack.SecondAttackAb());



            #endregion


            #region Lvl 13

            var lunge = Lunge.LungeAb();
            fighter.Skills.Add(lunge);



            #endregion


            #region Lvl 14

            var sbash = ShieldBash.ShieldBashAb();
            fighter.Skills.Add(sbash);

            #endregion


            #region Lvl 15

            var disarm = Disarm.DisarmAb();
            fighter.Skills.Add(disarm);

            #endregion


            #region Lvl 16

            var enhancedDam = EnhancedDamage.EnhancedDamageAb();
            fighter.Skills.Add(enhancedDam);

            #endregion

            #region Lvl 18

            var mount = Mount.MountAb();
            fighter.Skills.Add(mount);

            #endregion

            #region Lvl 20

            var thirdAttk = ThirdAttack.ThirdAttackAb();
            fighter.Skills.Add(thirdAttk);

            #endregion



            fighter.ReclassOptions.Add(Ranger.RangerClass());

            return(fighter);
        }
Exemple #21
0
 private void EventBusOnRescueClosed(object sender, Rescue rescue)
 {
     RemoveRescue(rescue);
 }
Exemple #22
0
 private void AddRescue(Rescue rescue)
 {
     rescues.AddOrUpdate(rescue.Id, rescue, (guid, oldValue) => rescue);
 }
Exemple #23
0
 public RescueModel(Rescue rescue)
 {
     Rescue = rescue;
 }
Exemple #24
0
 private void RemoveRescue(Rescue rescue)
 {
     RemoveRescue(rescue.Id);
 }