Exemplo n.º 1
0
        public override Result OnAreaValid(Player player, Vector3i position, Quaternion rotation)
        {
            Deed deed = PropertyManager.FindNearbyDeedOrCreate(player.User, position.XZ);

            foreach (var plot in WorldObject.GetOccupiedPropertyPositions(typeof(StarterCampObject), position, rotation))
            {
                PropertyManager.Claim(deed.Id, player.User, player.User.Inventory, plot);
            }

            var camp      = WorldObjectManager.TryToAdd(typeof(CampsiteObject), player.User, position, rotation, false);
            var stockpile = WorldObjectManager.TryToAdd(typeof(TinyStockpileObject), player.User, position + rotation.RotateVector(Vector3i.Right * 3), rotation, false);

            player.User.OnWorldObjectPlaced.Invoke(camp);
            player.User.Markers.Add(camp.Position3i + Vector3i.Up, camp.UILinkContent());
            player.User.Markers.Add(stockpile.Position3i + Vector3i.Up, stockpile.UILinkContent());
            var storage   = camp.GetComponent <PublicStorageComponent>();
            var changeSet = new InventoryChangeSet(storage.Inventory);

            PlayerDefaults.GetDefaultCampsiteInventory().ForEach(x =>
            {
                changeSet.AddItems(x.Key, x.Value, storage.Inventory);
            });
            changeSet.Apply();
            return(Result.Succeeded);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Occurs when the time has passed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            DateTime currentTime = DateTime.Now;

            if (Affairs.Count > 0)
            {
                Deed compareTime = Affairs.ElementAtOrDefault(0);
                if (currentTime.Hour == compareTime.Time.Hour && currentTime.Minute == compareTime.Time.Minute && currentTime.Second == compareTime.Time.Second)
                {
                    timer.Stop();
                    try
                    {
                        UpdateCollection upd = RemoveFromCollection;
                        if (!dispatcher.CheckAccess())
                        {
                            dispatcher.Invoke(upd, Affairs);
                        }
                        Notify(compareTime);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Message", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private async Task AddDeed(Guid challengeId, DateTime deedTime, string location, double lat, double lon,
                                   string comment, int?rating,
                                   string recipient)
        {
            var deed = new Deed
            {
                CreatorId   = CurrentAccess.UserId,
                CreateDate  = DateTime.UtcNow,
                ChallengeId = challengeId,
                DeedId      = Guid.NewGuid(),
                DeedDate    = deedTime,
                Location    = location,
                Lat         = lat,
                Lon         = lon,
                Comment     = comment,
                Rating      = rating
            };


            if (!string.IsNullOrEmpty(recipient))
            {
                var recipientUser = await RepositoryProvider.UserStore.FindByIdAsync(recipient);

                if (recipientUser == null)
                {
                    return;
                }

                deed.TaggedUsers.Add(recipientUser);
            }
            RepositoryProvider.Get <DeedRepository>().Insert(deed);
        }
Exemplo n.º 4
0
 public Deed AddNewDeed(Deed deed)
 {
     if (!User.Identity.IsAuthenticated || !ModelState.IsValid || deed == null)
         return null;
     deed = db.AddDeed(new Employee(User), deed);
     return deed;
 }
Exemplo n.º 5
0
        public async Task <IActionResult> PutDeed([FromRoute] Guid id, [FromBody] Deed deed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != deed.DeedId)
            {
                return(BadRequest());
            }

            _context.Entry(deed).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeedExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 6
0
 public DeedUpdateResponseViewModel(Deed deed)
 {
     this.KidID       = deed.KidID;
     this.TimeOfDeed  = deed.TimeOfDeed;
     this.Description = deed.Description;
     this.Weight      = deed.Weight;
     this.IsNice      = deed.IsNice;
 }
Exemplo n.º 7
0
        public static InteractResult DoClaim(Deed deed, User actor, Vector2i position, bool notify = true)
        {   // Try to perform the claiming action
            Result claimResult = AtomicActions.ClaimPropertyNow(deed, actor, actor.Inventory, position, ClaimedOrUnclaimed.ClaimingLand, false, notify);

            if (!claimResult.Success && !deed.OwnedObjects.Any())
            {
                PropertyManager.TryRemoveDeed(deed);
            }
            return((InteractResult)claimResult);
        }
Exemplo n.º 8
0
        public async Task <Deed> UpdateAsync(Deed deed)
        {
            using (ApplicationContext db = new ApplicationContext())
            {
                db.Update(deed);
                await db.SaveChangesAsync();

                return(deed);
            }
        }
 public void UpdateDeedModel(Deed deed)
 {
     if (deed.KidID == 0)
     {
         deed.KidID      = this.KidID;
         deed.TimeOfDeed = this.TimeOfDeed;
     }
     deed.Description = this.Description;
     deed.Weight      = this.Weight;
     deed.IsNice      = this.IsNice;
 }
Exemplo n.º 10
0
        public async Task <Deed> CreateAsync(Deed deed)
        {
            using (ApplicationContext db = new ApplicationContext())
            {
                var entityEntry = await db.Deeds.AddAsync(deed);

                await db.SaveChangesAsync();

                return(entityEntry.Entity);
            }
        }
Exemplo n.º 11
0
        public bool CheckHit(Deed deed)
        {
            List <NameSearchResult> grantorHits = this.SelectedGrantors.FindAll(g => deed.Grantor.Contains(g.Name));
            List <NameSearchResult> granteeHits = this.SelectedGrantees.FindAll(g => deed.Grantee.Contains(g.Name));

            if (grantorHits.Count > 0 && granteeHits.Count > 0)
            {
                this.DeedResults.Add(deed);
            }

            return(grantorHits.Count > 0 && granteeHits.Count > 0);
        }
Exemplo n.º 12
0
        public async Task <IActionResult> PostDeed([FromBody] Deed deed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Deeds.Add(deed);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDeed", new { id = deed.DeedId }, deed));
        }
Exemplo n.º 13
0
        public DeedDetailsViewModel(Deed deed)
        {
            this.KidID       = deed.KidID;
            this.Description = deed.Description;
            this.TimeOfDeed  = deed.TimeOfDeed;
            this.Weight      = deed.Weight;
            this.IsNice      = deed.IsNice;

            var kid = KidsManager.GetByID(deed.KidID);

            this.KidName = kid.Name;
        }
Exemplo n.º 14
0
        private void ResultsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Deed deed = ((sender as ListBox).SelectedItem as Deed);

            this.GrantorResultList.ItemsSource = deed.Grantor;
            this.GranteeResultList.ItemsSource = deed.Grantee;
            this.CountyResult.Text             = deed.County;
            this.BookResult.Text       = deed.Book;
            this.PageResult.Text       = deed.Page;
            this.IssueResult.Text      = deed.DateFiled;
            this.TimeResult.Text       = deed.Time;
            this.InstrumentResult.Text = deed.InstrumentType;
        }
Exemplo n.º 15
0
        public override void OnExecute(IDialogueOwner dialogueOwner)
        {
//            var factionManager = QuestSystemLoveHateBridgeManager.factionManager;
            FactionMember factionMember = null;

            switch (ownerType)
            {
            case DialogueOwnerType.Player:
            {
                var p = PlayerManager.instance.currentPlayer;
                factionMember = p.GetComponent <FactionMember>();
                break;
            }

            case DialogueOwnerType.DialogueOwner:
            {
                var qg = QuestManager.instance.currentQuestGiver;
                if (qg != null)
                {
                    factionMember = qg.transform.GetComponent <FactionMember>();
                }

                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (factionMember != null)
            {
                var deed = Deed.GetNew(deedInfo.tag, factionMember.factionID, deedInfo.targetFactionID, deedInfo.impact, deedInfo.aggression, factionMember.GetPowerLevel(), deedInfo.traits);

//                int numPersonalityTraits = factionManager.factionDatabase.personalityTraitDefinitions.Length;
//                float[] traits = Traits.Allocate(numPersonalityTraits, true); // Optional values that describe personality of deed.

                QuestSystemLoveHateBridgeManager.factionManager.CommitDeed
                (
                    factionMember,
                    deed,
                    requiresSight,
                    dimension,
                    radius
                );

                Deed.Release(deed);
            }

            Finish(true);
        }
Exemplo n.º 16
0
 public static async void DeleteWithDialog(Player player, Deed deed)
 {
     try
     {
         if (await player?.ConfirmBox(Localizer.Do($"Do you wish to completely unclaim {deed?.MarkedUpName}?")))
         {
             deed?.DeleteDeed(player);
         }
     }
     catch (Exception e)
     {
         Log.WriteException(e);
     }
 }
        public ActionResult Create(DeedUpdateRequestViewModel requestModel) //Needs a request view model
        {
            var deed = new Deed();

            requestModel.UpdateDeedModel(deed);

            bool success = DeedsManager.Save(deed);

            var viewModel = new DeedUpdateResponseViewModel(deed);

            viewModel.UpdateSuccess = success;

            return(RedirectToAction("Details", new { kidId = deed.KidID, timeOfDeed = deed.TimeOfDeed }));
        }
Exemplo n.º 18
0
 public override void OnResponse(NetState state, RelayInfo info)
 {
     if (!state.Mobile.InRange(Point, 3))
     {
         state.Mobile.SendLocalizedMessage(500251); // That location is too far away.
     }
     else if (info.ButtonID == 1)
     {
         Deed.DeployAddon(true, Point, Map);
     }
     else if (info.ButtonID == 2)
     {
         Deed.DeployAddon(false, Point, Map);
     }
 }
Exemplo n.º 19
0
            public override void OnClick()
            {
                if (Deed.DeploymentType == DeploymentType.Proximaty)
                {
                    Deed.DeploymentType = DeploymentType.Tripwire;
                }
                else
                {
                    Deed.DeploymentType = DeploymentType.Proximaty;
                }

                Deed.InvalidateProperties();

                Clicker.PrivateOverheadMessage(Network.MessageType.Regular, 1154, 1155515, Clicker.NetState); // *You adjust the deployment mechanism*
            }
Exemplo n.º 20
0
        private void Image_Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.ResultsList.SelectedItem != null)
            {
                Deed deed = this.ResultsList.SelectedItem as Deed;

                if (!String.IsNullOrWhiteSpace(deed.ImageUrl))
                {
                    Log.Information($"Opening deed: {deed.ImageUrl}");

                    DeedImageWindow deedImage = new DeedImageWindow();
                    deedImage.Source = new Uri(deed.ImageUrl);
                    deedImage.Show();

                    //System.Diagnostics.Process.Start(deed.ImageUrl.Replace("&", "^&"));
                }
            }
        }
Exemplo n.º 21
0
        public static void OpenAuth(User user)
        {
            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }
            Deed deed = PropertyManager.GetDeed(user.Position.XZi);

            if (deed != null)
            {
                deed.OpenAuthorizationMenuOn(user.Player);
            }
            else
            {
                ChatUtils.SendMessage(user, "Plot is not claimed!", true);
            }
        }
Exemplo n.º 22
0
        // Interact to examine
        public override InteractResult OnActInteract(InteractionContext context)
        {
            Vector2i?position = ClaimingUtils.GetClaimingPosition(context);

            if (!position.HasValue)
            {
                return(InteractResult.NoOp);
            }

            Deed deed = PropertyManager.GetDeed(position.Value);

            if (deed != null)
            {
                deed.OpenAuthorizationMenuOn(context.Player);
                return(InteractResult.Success);
            }

            return(base.OnActLeft(context));
        }
Exemplo n.º 23
0
        public static DeedViewModel Create(Deed deed)
        {
            var model = new DeedViewModel
            {
                ChallengeId = deed.ChallengeId,
                DeedId      = deed.DeedId,
                DeedTime    = deed.DeedDate,
                Challenge   = deed.Challenge.Name,
                Location    = deed.Location
            };

            if (deed.Challenge != null)
            {
                model.Challenge            = deed.Challenge.Name;
                model.ChallengeDescription = deed.Challenge.Description;
            }

            return(model);
        }
Exemplo n.º 24
0
        public static void SetOwner(User user, string newowner)
        {
            User newowneruser = UserManager.FindUserByName(newowner);
            Deed deed         = PropertyManager.GetDeed(user.Position.XZi);

            if (deed == null)
            {
                ChatUtils.SendMessage(user, "Plot is not claimed!");
                return;
            }
            if (newowneruser != null)
            {
                deed.SetOwner(newowneruser);
                ChatUtils.SendMessage(user, newowneruser + " is now the owner of " + deed.Name);
            }
            else
            {
                ChatUtils.SendMessage(user, "User not found!", true);
            }
        }
        // Place to claim
        public override InteractResult OnActRight(InteractionContext context)
        {
            Vector2i?position = this.GetPosition(context);
            Player   player   = context.Player;

            if (!position.HasValue)
            {
                return(InteractResult.NoOp);
            }

            Deed   deed        = PropertyManager.FindNearbyDeedOrCreate(player.User, position.Value);
            Result claimResult = PropertyManager.Claim(deed.Id, player.User, position.Value);

            if (!claimResult.Success && !deed.OwnedObjects.Any())
            {
                PropertyManager.TryRemoveDeed(deed);
            }

            return((InteractResult)claimResult);
        }
        public static bool Save(Deed newData)
        {
            using (var context = new DataContext())
            {
                var table = context.Deeds;

                var oldData = table.SingleOrDefault(e => e.KidID == newData.KidID && e.TimeOfDeed == newData.TimeOfDeed);
                if (oldData == null)
                {
                    table.Add(newData);
                }
                else
                {
                    string[] dontAlter = new string[] { "KidID", "TimeOfDeed" };
                    ModelUtils.MergeChanges(ref newData, ref oldData, dontAlter);
                }

                return(context.SaveChanges() > 0);
            }
        }
        // Interact to examine
        public override InteractResult OnActInteract(InteractionContext context)
        {
            Vector2i?position = this.GetPosition(context);

            if (!position.HasValue)
            {
                return(InteractResult.NoOp);
            }

            Deed deed = PropertyManager.GetDeed(position.Value);

            if (deed == null)
            {
                return(InteractResult.NoOp);
            }
            else
            {
                deed.OpenAuthorizationMenuOn(context.Player);
                return(InteractResult.Success);
            }
        }
Exemplo n.º 28
0
    public IEnumerator DisplayDeedPopUp(Deed deed)
    {
        if (!deed.achieved)
        {
            deed.achieved = true;
            toDoDeeds.Remove(deed);
            doneDeeds.Add(deed);
        }
        deedTitle.text = deed.title;
        deedBlurb.text = deed.blurb;
        deedpopUpWindow.SetActive(true);
        yield return(new WaitForSeconds(5f));

        deedGreyScreen.SetActive(true);
        yield return(new WaitForSeconds(0.5f));

        deedpopUpWindow.SetActive(false);
        yield return(new WaitForSeconds(0.5f));

        deedGreyScreen.SetActive(false);
    }
        public override Result OnAreaValid(Player player, Vector3i position, Quaternion rotation)
        {
            Result authAtPosOne = AuthManager.IsAuthorized(position, player.User);
            Result authAtPosTwo = AuthManager.IsAuthorized((position + rotation.RotateVector(Vector3i.Right * 3)).Round, player.User);

            if (!authAtPosOne.Success)
            {
                return(authAtPosOne);
            }
            else if (!authAtPosTwo.Success)
            {
                return(authAtPosTwo);
            }

            Deed deed = PropertyManager.FindNearbyDeedOrCreate(player.User, position.XZ);
            var  dist = position.XZ - World.GetPropertyPos(position.XZ) - (World.PropertyPlotLength / 2);

            if (dist.x == 0 || dist.y == 0)
            {
                dist = rotation.RotateVector(new Vector3i(1, 0, 1)).XZi;
            }
            dist = new Vector2i(Math.Sign(dist.x), Math.Sign(dist.y));
            Vector2i.XYIter(2).ForEach(x => PropertyManager.Claim(deed.Id, player.User, position.XZ + (new Vector2i(dist.x * x.x, dist.y * x.y) * World.PropertyPlotLength)));

            var camp      = WorldObjectManager.TryToAdd(typeof(CampsiteObject), player.User, position, rotation, false);
            var stockpile = WorldObjectManager.TryToAdd(typeof(TinyStockpileObject), player.User, position + rotation.RotateVector(Vector3i.Right * 3), rotation, false);

            player.User.OnWorldObjectPlaced.Invoke(camp);
            player.User.Markers.Add(camp.Position3i + Vector3i.Up, camp.UILinkContent());
            player.User.Markers.Add(stockpile.Position3i + Vector3i.Up, stockpile.UILinkContent());
            var storage   = camp.GetComponent <PublicStorageComponent>();
            var changeSet = new InventoryChangeSet(storage.Inventory);

            PlayerDefaults.GetDefaultCampsiteInventory().ForEach(x =>
            {
                changeSet.AddItems(x.Key, x.Value, storage.Inventory);
            });
            changeSet.Apply();
            return(Result.Succeeded);
        }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        var h = Input.GetAxis("Horizontal");
        var v = Input.GetAxis("Vertical");

        var wasShooting = current == Deed.shoot;

        if (v < 0)
        {
            dir       = Direction.down;
            spr.flipX = false;
            current   = Deed.walk;
        }
        else if (v > 0)
        {
            dir       = Direction.up;
            spr.flipX = false;
            current   = Deed.walk;
        }
        else if (h > 0)
        {
            dir       = Direction.side;
            spr.flipX = false;
            current   = Deed.walk;
        }
        else if (h < 0)
        {
            dir       = Direction.side;
            spr.flipX = true;
            current   = Deed.walk;
        }
        else
        {
            current = Deed.idle;
        }
        if (wasShooting)
        {
            current = Deed.shoot;
        }

        if (Input.GetButtonDown("Switch"))
        {
            el = (el == Element.fire) ? Element.ice : ((el == Element.ice) ? Element.wind : Element.fire);
        }
        if (Input.GetButtonDown("Attack"))
        {
            frame   = 0;
            frAccum = 0;
            current = Deed.shoot;
        }

        frAccum += Time.deltaTime;
        switch (current)
        {
        case Deed.idle:
            frAccum = 0;
            frame   = 0;
            break;

        case Deed.walk:
            if (frAccum >= walkingFrameRate)
            {
                frame++;
                frAccum = 0;
            }
            frame %= 4;
            break;

        case Deed.shoot:
            if (frAccum >= shootingFrameRate)
            {
                frame++;
                frAccum = 0;
            }
            if (frame >= 3)
            {
                frame   = 0;
                current = Deed.idle;
            }
            break;
        }
        spr.sprite = animationSet[(int)dir + (int)el + (int)current + frame];
    }
Exemplo n.º 31
0
 public Deed EditDeed(int id, Deed deed)
 {
     if (!ModelState.IsValid)
         return null;
     return db.EditDeed(id, deed, new Employee(User));
 }
Exemplo n.º 32
0
 public DeedViewModel()
 {
     Affairs    = new ObservableCollection <Deed>();
     deed       = new Deed();
     dispatcher = Dispatcher.CurrentDispatcher;
 }