예제 #1
0
        private void Credit(Account account, Movement movement)
        {
            MovementHelpers.Credit(HistoricMovementRepository, movement.Amount, account.Id, ObjectType.Account, account.CurrentBalance);

            account.CurrentBalance += movement.Amount;
            BankAccountRepository.Update(account);
        }
예제 #2
0
        IEnumerable <TickTimer> _RuneE()
        {
            float    attackRadius   = 8f; // value is not in formulas, just a guess
            Vector3D castedPosition = new Vector3D(User.Position);
            float    castAngle      = MovementHelpers.GetFacingAngle(castedPosition, TargetPosition);
            float    waveOffset     = 0f;

            int flyerCount = (int)ScriptFormula(15);

            for (int n = 0; n < flyerCount; ++n)
            {
                waveOffset += 3.0f;
                var wavePosition  = PowerMath.TranslateDirection2D(castedPosition, TargetPosition, castedPosition, waveOffset);
                var flyerPosition = RandomDirection(wavePosition, 0f, attackRadius);
                var flyer         = SpawnEffect(200561, flyerPosition, castAngle, WaitSeconds(ScriptFormula(20)));
                flyer.OnTimeout = () =>
                {
                    flyer.PlayEffectGroup(200819);
                    AttackPayload attack = new AttackPayload(this);
                    attack.Targets = GetEnemiesInRadius(flyerPosition, attackRadius);
                    attack.AddWeaponDamage(ScriptFormula(11), DamageType.Physical);
                    attack.OnHit = (hitPayload) => { Knockback(hitPayload.Target, 90f); };
                    attack.Apply();
                };

                yield return(WaitSeconds(ScriptFormula(4)));
            }
        }
        private void Debit(Account account, Account internalAccount, Movement movement)
        {
            MovementHelpers.Debit(HistoricMovementRepository, movement.Amount, account.Id, ObjectType.Account, account.CurrentBalance, internalAccount.Id, ObjectType.Account, internalAccount.CurrentBalance);

            account.CurrentBalance -= movement.Amount;
            BankAccountRepository.Update(account);

            internalAccount.CurrentBalance += movement.Amount;
            BankAccountRepository.Update(internalAccount);

            if (!movement.TargetAccountId.HasValue)
            {
                throw new ArgumentException("Target Income ID should not be null.");
            }

            var income = new Income
            {
                Description = "Transfer: " + movement.Description,
                Cost        = movement.Amount,
                AccountId   = movement.TargetAccountId.Value,
                DateIncome  = movement.Date
            };
            var mappedIncome = IncomeRepository.Create(income);

            movement.TargetIncomeId = mappedIncome.Id;
        }
        private async Task <bool> RepairItems(Game game, MovementMode movementMode)
        {
            if (NPCHelpers.ShouldGoToRepairNPC(game))
            {
                var repairNPC = NPCHelpers.GetRepairNPC(game.Act);
                Log.Information($"Client {game.Me.Name} moving to {repairNPC} for repair/arrows");
                var pathRepairNPC = repairNPC == NPCCode.Hratli ? await _pathingService.GetPathToObject(game, EntityCode.Hratli, movementMode)
                 : await _pathingService.GetPathToNPC(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, repairNPC, movementMode);

                if (pathRepairNPC.Count > 0 && await MovementHelpers.TakePathOfLocations(game, pathRepairNPC, movementMode))
                {
                    var uniqueNPC = NPCHelpers.GetUniqueNPC(game, repairNPC);
                    if (uniqueNPC == null)
                    {
                        Log.Warning($"Client {game.Me.Name} Did not find {repairNPC} at {game.Me.Location}");
                        return(false);
                    }

                    if (!NPCHelpers.RepairItemsAndBuyArrows(game, uniqueNPC))
                    {
                        Log.Warning($"Client {game.Me.Name} Selling items and refreshing potions to {repairNPC} failed at {game.Me.Location}");
                    }
                }
                else
                {
                    Log.Warning($"Client {game.Me.Name} {movementMode} to {repairNPC} failed at {game.Me.Location}");
                }
            }

            return(true);
        }
예제 #5
0
        public static GameEntity CreateEnemy(Contexts contexts, Vector2 pos)
        {
            var enemy = contexts.game.CreateEntity();

            enemy.AddPrefab("Prefabs/Enemies/spider");
            enemy.AddPosition(pos);
            enemy.isEnemy           = true;
            enemy.isRemovedWhenDead = true;

            MovementHelpers.AddMovementComponents(enemy, 2f, .25f, .5f, .8f, 1f);
            SightHelpers.AddSightComponents(enemy, 50);
            CombatHelpers.AddCombatComponents(enemy, 5f, 3f, .5f);

            var agent = new EntityGoapAgent(contexts, enemy);

            agent.AddAction(new CloseRangeAttackAction());
            agent.AddAction(new GetCloseToTargetAction());
            agent.AddAction(new TargetMinersAction());
            agent.AddGoal(new DestroyMineGoal());
            enemy.AddGoapAgent(agent);


            var animDirector = new AnimationDirector(enemy);

            enemy.AddAnimationDirector(animDirector);

            var combatDirector = new CombatDirector(enemy);

            combatDirector.AddAttack(new MeleeAttack(enemy, "spider_walk", new [] { 24 }));
            enemy.AddCombatDirector(combatDirector);

            return(enemy);
        }
        private async Task <bool> IdentifyItems(Game game, MovementMode movementMode)
        {
            var unidentifiedItemCount = game.Inventory.Items.Count(i => !i.IsIdentified) +
                                        game.Cube.Items.Count(i => !i.IsIdentified);

            if (unidentifiedItemCount > 6)
            {
                Log.Information($"Visiting Deckard Cain with {unidentifiedItemCount} unidentified items");
                var deckhardCainCode = NPCHelpers.GetDeckardCainForAct(game.Act);

                var deckardCain     = NPCHelpers.GetUniqueNPC(game, deckhardCainCode);
                var pathDeckardCain = new List <Point>();
                if (deckardCain != null)
                {
                    pathDeckardCain = await _pathingService.GetPathToLocation(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, deckardCain.Location, movementMode);
                }
                else
                {
                    pathDeckardCain = await _pathingService.GetPathToNPC(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, deckhardCainCode, movementMode);
                }

                if (!await MovementHelpers.TakePathOfLocations(game, pathDeckardCain, movementMode))
                {
                    Log.Warning($"Client {game.Me.Name} {movementMode} to deckard cain failed at {game.Me.Location}");
                    return(false);
                }

                return(NPCHelpers.IdentifyItemsAtDeckardCain(game));
            }

            return(true);
        }
예제 #7
0
        private void _SpawnBolt()
        {
            var eff = SpawnEffect(176247, User.Position, 0, WaitSeconds(10f));

            World.BroadcastIfRevealed(new ACDTranslateDetPathMessage
            {
                Id     = 118,
                Field0 = (int)eff.DynamicID,
                Field1 = 1,                                                              // 0 - crashes client
                                                                                         // 1 - random scuttle (charged bolt effect)
                                                                                         // 2 - random movement, random movement pauses (toads hopping)
                                                                                         // 3 - clockwise spiral
                                                                                         // 4 - counter-clockwise spiral
                                                                                         // >=5 - nothing it seems
                Field2  = Rand.Next(),                                                   // RNG seed for style 1 and 2
                Field3  = Rand.Next(),                                                   // RNG seed for style 1 and 2
                Field4  = new Vector3D(0.0f, 0.3f, 0),                                   // length of this vector is amount moved for style 1 and 2,
                Field5  = MovementHelpers.GetFacingAngle(User.Position, TargetPosition), // facing angle
                Field6  = User.Position,
                Field7  = 1,
                Field8  = 0,
                Field9  = -1,
                Field10 = PowerSNO, // power sno
                Field11 = 0,
                Field12 = 0f,       // spiral control?
                Field13 = 0f,       // spiral control? for charged bolt this is facing angle again, but seems to effect nothing.
                Field14 = 0f,       // spiral control? for charged bolt this is Position.X and seems to effect nothing
                Field15 = 0f        // spiral control? for charged bolt this is Position.Y and seems to effect nothing
            }, eff);
        }
        private async Task <bool> RefreshAndSellItems(Game game, MovementMode movementMode, TownManagementOptions options)
        {
            var sellItemCount = game.Inventory.Items.Count(i => !Pickit.Pickit.ShouldKeepItem(game, i)) + game.Cube.Items.Count(i => !Pickit.Pickit.ShouldKeepItem(game, i));

            if (NPCHelpers.ShouldRefreshCharacterAtNPC(game) || sellItemCount > 5 || options.ItemsToBuy?.Count > 0)
            {
                var sellNpc = NPCHelpers.GetSellNPC(game.Act);
                Log.Information($"Client {game.Me.Name} moving to {sellNpc} for refresh and selling {sellItemCount} items");
                var pathSellNPC = await _pathingService.GetPathToNPC(game.MapId, Difficulty.Normal, WayPointHelpers.MapTownArea(game.Act), game.Me.Location, sellNpc, movementMode);

                if (pathSellNPC.Count > 0 && await MovementHelpers.TakePathOfLocations(game, pathSellNPC, movementMode))
                {
                    var uniqueNPC = NPCHelpers.GetUniqueNPC(game, sellNpc);
                    if (uniqueNPC == null)
                    {
                        Log.Warning($"Client {game.Me.Name} Did not find {sellNpc} at {game.Me.Location}");
                        return(false);
                    }

                    if (!NPCHelpers.SellItemsAndRefreshPotionsAtNPC(game, uniqueNPC, options.ItemsToBuy))
                    {
                        Log.Warning($"Client {game.Me.Name} Selling items and refreshing potions failed at {game.Me.Location}");
                        return(false);
                    }
                }
                else
                {
                    Log.Warning($"Client {game.Me.Name} {movementMode} to {sellNpc} failed at {game.Me.Location}");
                    return(false);
                }
            }

            return(true);
        }
예제 #9
0
        private async Task <bool> KillDiablo(Client client, CSManager csManager, Action <uint> setTeleportId)
        {
            var pathToDiabloStar = await _pathingService.GetPathToObject(client.Game.MapId, Difficulty.Normal, Area.ChaosSanctuary, client.Game.Me.Location, EntityCode.DiabloStar, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToDiabloStar, MovementMode.Teleport))
            {
                Log.Warning($"Client {client.Game.Me.Name} Teleporting to {EntityCode.DiabloStar} failed at location {client.Game.Me.Location}");
                return(false);
            }

            if (!_townManagementService.CreateTownPortal(client))
            {
                return(false);
            }

            var myPortal = client.Game.GetEntityByCode(EntityCode.TownPortal).First(t => t.TownPortalOwnerId == client.Game.Me.Id);

            setTeleportId.Invoke(myPortal.Id);
            var action = GetSorceressKillAction(client);

            if (!await KillBosses(client, csManager, null, client.Game.Me.Location, action, 0, () => 0))
            {
                return(false);
            }
            return(true);
        }
예제 #10
0
        private void Credit(AtmWithdraw atmWithdraw, Movement movement)
        {
            MovementHelpers.Credit(HistoricMovementRepository, movement.Amount, atmWithdraw.Id, ObjectType.AtmWithdraw, atmWithdraw.CurrentAmount);

            atmWithdraw.CurrentAmount += movement.Amount;
            AtmWithdrawRepository.Update(atmWithdraw);
        }
        private async Task <bool> GambleItems(Client client, MovementMode movementMode)
        {
            bool shouldGamble = client.Game.Me.Attributes[D2NG.Core.D2GS.Players.Attribute.GoldInStash] > 7_000_000;

            if (shouldGamble && System.Threading.Interlocked.Exchange(ref isAnyClientGambling, 1) == 0)
            {
                var gambleNPC = NPCHelpers.GetGambleNPC(client.Game.Act);
                Log.Information($"Gambling items at {gambleNPC}");
                var pathToGamble = await _pathingService.GetPathToNPC(client.Game, gambleNPC, movementMode);

                if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToGamble, movementMode))
                {
                    Log.Warning($"{movementMode} to {gambleNPC} failed at {client.Game.Me.Location}");
                    return(false);
                }

                var uniqueNPC = NPCHelpers.GetUniqueNPC(client.Game, gambleNPC);
                if (uniqueNPC == null)
                {
                    Log.Warning($"{gambleNPC} not found at {client.Game.Me.Location}");
                    return(false);
                }

                NPCHelpers.GambleItems(client.Game, uniqueNPC);
                System.Threading.Interlocked.Exchange(ref isAnyClientGambling, 0);
            }

            return(true);
        }
        public async Task <bool> TakeWaypoint(Client client, Waypoint waypoint)
        {
            var movementMode       = GetMovementMode(client.Game);
            var pathToTownWayPoint = await _pathingService.ToTownWayPoint(client.Game, movementMode);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToTownWayPoint, movementMode))
            {
                Log.Information($"Walking to {client.Game.Act} waypoint failed");
                return(false);
            }

            WorldObject townWaypoint = null;

            GeneralHelpers.TryWithTimeout((retryCount) =>
            {
                townWaypoint = client.Game.GetEntityByCode(client.Game.Act.MapTownWayPointCode()).Single();
                return(townWaypoint != null);
            }, TimeSpan.FromSeconds(2));

            if (townWaypoint == null)
            {
                Log.Error("No waypoint found");
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(retryCount) =>
            {
                while (client.Game.Me.Location.Distance(townWaypoint.Location) > 5)
                {
                    if (client.Game.Me.HasSkill(Skill.Teleport))
                    {
                        await client.Game.TeleportToLocationAsync(townWaypoint.Location);
                    }
                    else
                    {
                        await client.Game.MoveToAsync(townWaypoint);
                    }
                }
                client.Game.TakeWaypoint(townWaypoint, waypoint);
                return(GeneralHelpers.TryWithTimeout((retryCount) => client.Game.Area == waypoint.ToArea(), TimeSpan.FromSeconds(2)));
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(retryCount) =>
            {
                client.Game.RequestUpdate(client.Game.Me.Id);
                var isValidPoint = await _pathingService.IsNavigatablePointInArea(client.Game.MapId, Difficulty.Normal, waypoint.ToArea(), client.Game.Me.Location);
                return(isValidPoint);
            }, TimeSpan.FromSeconds(3.5)))
            {
                Log.Error("Checking whether moved to area failed");
                return(false);
            }

            return(true);
        }
예제 #13
0
    // Update is called once per frame
    void Update()
    {
        float targetSpeed = Input.GetAxisRaw("Vertical") * speed;

        currentSpeed = MovementHelpers.IncrementToward(currentSpeed, targetSpeed, acceleration);

        Vector2 amountToMove = new Vector2(0, currentSpeed);

        playerPhysics.Move(amountToMove * Time.deltaTime);
    }
예제 #14
0
        public void DeleteIncome(int id)
        {
            var income = _incomeRepository.GetById(id);

            var account = _bankAccountRepository.GetById(income.AccountId);

            MovementHelpers.Debit(_historicMovementRepository, income.Cost, account.Id, ObjectType.Account, account.CurrentBalance);
            account.CurrentBalance -= income.Cost;
            _bankAccountRepository.Update(account);

            _incomeRepository.Delete(income);
        }
        public async Task <bool> TakeTownPortalToArea(Client client, Player player, Area area)
        {
            var portal = client.Game.GetEntityByCode(EntityCode.TownPortal).FirstOrDefault(t => t.TownPortalArea == area && t.TownPortalOwnerId == player.Id);

            if (portal == null)
            {
                return(false);
            }

            var movementMode = GetMovementMode(client.Game);
            var pathToPortal = await _pathingService.GetPathToLocation(client.Game, portal.Location, movementMode);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToPortal, movementMode))
            {
                Log.Information($"Moving to {portal.Location} failed");
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(retryCount) =>
            {
                if (retryCount > 0 && retryCount % 5 == 0)
                {
                    client.Game.RequestUpdate(client.Game.Me.Id);
                }

                client.Game.InteractWithEntity(portal);
                return(await GeneralHelpers.TryWithTimeout(async(retryCount) =>
                {
                    await Task.Delay(50);
                    return client.Game.Area == area;
                }, TimeSpan.FromSeconds(0.5)));
            }, TimeSpan.FromSeconds(10)))
            {
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(retryCount) =>
            {
                if (retryCount > 0 && retryCount % 5 == 0)
                {
                    client.Game.RequestUpdate(client.Game.Me.Id);
                }

                await Task.Delay(100);

                return(await _pathingService.IsNavigatablePointInArea(client.Game.MapId, Difficulty.Normal, area, client.Game.Me.Location));
            }, TimeSpan.FromSeconds(10)))
            {
                return(false);
            }

            return(true);
        }
예제 #16
0
        public void DeleteAtmWithdraw(int id)
        {
            var atmWithdraw = _atmWithdrawRepository.GetById(id);

            var account = _bankAccountRepository.GetById(atmWithdraw.AccountId);

            MovementHelpers.Debit(_historicMovementRepository, atmWithdraw.InitialAmount, account.Id, ObjectType.Account, account.CurrentBalance);
            account.CurrentBalance += atmWithdraw.InitialAmount;
            _bankAccountRepository.Update(account);

            _atmWithdrawRepository.Delete(atmWithdraw);
        }
예제 #17
0
        public void CreateIncome(IncomeDetails incomeDetails)
        {
            var income = Mapper.Map <Income>(incomeDetails);

            _incomeRepository.Create(income);

            var account = _bankAccountRepository.GetById(income.AccountId);

            MovementHelpers.Credit(_historicMovementRepository, income.Cost, account.Id, ObjectType.Account, account.CurrentBalance);

            account.CurrentBalance += incomeDetails.Cost;
            _bankAccountRepository.Update(account);
        }
예제 #18
0
        public void CreateAtmWithdraw(AtmWithdrawDetails atmWithdrawDetails)
        {
            var atmWithdraw = Mapper.Map <AtmWithdraw>(atmWithdrawDetails);

            atmWithdraw.CurrentAmount = atmWithdrawDetails.InitialAmount;
            atmWithdraw.IsClosed      = false;
            _atmWithdrawRepository.Create(atmWithdraw);

            var account = _bankAccountRepository.GetById(atmWithdraw.AccountId);

            MovementHelpers.Debit(_historicMovementRepository, atmWithdraw.InitialAmount, account.Id, ObjectType.Account, account.CurrentBalance);

            account.CurrentBalance -= atmWithdraw.InitialAmount;
            _bankAccountRepository.Update(account);
        }
예제 #19
0
        private List <Player> GetPlayersInRange(Mooege.Core.GS.Map.World world)
        {
            // Not as clean and fancy as quadtreee, but the cost is like alot less.
            // Quadtree avg's 0.134ms vs 0.004ms for this. Probably could stick to the Quadtree by just only checking every X seconds.
            List <Player> playerList = new List <Player>();

            foreach (var p in world.Players.Values)
            {
                if (MovementHelpers.GetDistance(this.Body.Position, p.Position) < 240f)
                {
                    playerList.Add(p);
                }
            }
            return(playerList);
        }
예제 #20
0
        private async Task <bool> UseFindItemOnCouncilMembers(Game game)
        {
            List <WorldObject> councilMembers = GetCouncilMembers(game);
            var nearestMembers = councilMembers.OrderBy(n => game.Me.Location.Distance(n.Location));

            foreach (var nearestMember in nearestMembers)
            {
                await PickupNearbyItems(game, 10);

                bool result = await GeneralHelpers.TryWithTimeout(async (retryCount) =>
                {
                    if (!game.IsInGame())
                    {
                        return(false);
                    }

                    if (nearestMember.Location.Distance(game.Me.Location) > 5)
                    {
                        var pathNearest = await _pathingService.GetPathToLocation(game.MapId, Difficulty.Normal, Area.Travincal, game.Me.Location, nearestMember.Location, MovementMode.Walking);
                        await MovementHelpers.TakePathOfLocations(game, pathNearest, MovementMode.Walking);
                    }

                    if (nearestMember.Location.Distance(game.Me.Location) <= 5)
                    {
                        if (game.UseFindItem(nearestMember))
                        {
                            return(nearestMember.Effects.Contains(EntityEffect.CorpseNoDraw));
                        }
                    }

                    return(false);
                }, TimeSpan.FromSeconds(5));

                if (!result)
                {
                    Log.Warning("Failed to do find item on corpse");
                }

                if (!game.IsInGame())
                {
                    return(false);
                }
            }

            return(true);
        }
        private void Credit(Account account, Account internalAccount, Movement movement)
        {
            MovementHelpers.Credit(HistoricMovementRepository, movement.Amount, account.Id, ObjectType.Account, account.CurrentBalance, internalAccount.Id, ObjectType.Account, internalAccount.CurrentBalance);

            account.CurrentBalance += movement.Amount;
            BankAccountRepository.Update(account);

            internalAccount.CurrentBalance -= movement.Amount;
            BankAccountRepository.Update(internalAccount);

            if (!movement.TargetIncomeId.HasValue)
            {
                throw new ArgumentException("Target Income ID should not be null.");
            }

            var income = IncomeRepository.GetById(movement.TargetIncomeId.Value);

            IncomeRepository.Delete(income);
        }
예제 #22
0
        public static GameEntity CreateMiner(Contexts contexts, Vector2 pos)
        {
            var e = contexts.game.CreateEntity();

            e.AddPrefab("Prefabs/Miners/miner_grunt");
            e.AddPosition(pos);
            MovementHelpers.AddMovementComponents(e, 3f, .25f, .5f, .5f, .8f);
            SightHelpers.AddSightComponents(e, 10f);
            e.isMiner = true;

            var health   = StatCalculator.Calculate(BaseHealth, 1);
            var damage   = StatCalculator.Calculate(BaseMiningDamage, 1);
            var cooldown = StatCalculator.Calculate(BaseMiningSpeed, 1);

            CombatHelpers.AddCombatComponents(e, health, damage, cooldown);

            var animDirector = new AnimationDirector(e);

            e.AddAnimationDirector(animDirector);
            e.isKillable = true;


            var agent = new EntityGoapAgent(contexts, e);

            agent.AddAction(new CloseRangeAttackAction());
            agent.AddAction(new GetCloseToTargetAction());
            agent.AddAction(new TargetOreBranchAction());
            agent.AddAction(new MineAction());
            agent.AddGoal(new AcquireOreGoal());
            e.AddGoapAgent(agent);


            var combatDirector = new CombatDirector(e);

            combatDirector.AddAttack(new MeleeAttack(e, "miner_grunt_mine_regular", new[] { 24 }));
            e.AddCombatDirector(combatDirector);

            e.AddBag(new List <int>());

            return(e);
        }
예제 #23
0
        private async Task <bool> PickupNearbyItems(Game game, double distance)
        {
            var pickupItems = game.Items.Where(i =>
            {
                return(i.Ground && game.Me.Location.Distance(i.Location) < distance && Pickit.Pickit.ShouldPickupItem(game, i));
            }).OrderBy(n => game.Me.Location.Distance(n.Location));

            foreach (var item in pickupItems)
            {
                if (!game.IsInGame())
                {
                    return(false);
                }

                InventoryHelpers.MoveInventoryItemsToCube(game);
                if (game.Inventory.FindFreeSpace(item) == null)
                {
                    continue;
                }

                await GeneralHelpers.TryWithTimeout(async (retryCount) =>
                {
                    if (game.Me.Location.Distance(item.Location) >= 5)
                    {
                        var pathNearest = await _pathingService.GetPathToLocation(game.MapId, Difficulty.Normal, Area.Travincal, game.Me.Location, item.Location, MovementMode.Walking);
                        await MovementHelpers.TakePathOfLocations(game, pathNearest, MovementMode.Walking);
                        return(false);
                    }

                    return(true);
                }, TimeSpan.FromSeconds(3));

                if (game.Me.Location.Distance(item.Location) < 5)
                {
                    game.PickupItem(item);
                }
            }

            InventoryHelpers.MoveInventoryItemsToCube(game);
            return(true);
        }
예제 #24
0
        public ActionResult Create(NewOrderView view)
        {
            if (ModelState.IsValid)
            {
                var response =
                    MovementHelpers.
                    NewOrder(
                        view,
                        User.Identity.Name);

                if (response.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError(
                    string.Empty, response.Message);
            }

            var user =
                db.Users.
                Where(us => us.UserName == User.Identity.Name).
                FirstOrDefault();

            ViewBag.CustomerId =
                new SelectList(
                    ComboBoxHelpers.
                    GetCustomers(
                        user.CompanyId),
                    "CustomerID",
                    "FullName",
                    view.CustomerId);

            view.Details =
                db.OrderDetailTmps.
                Where(odt => odt.UserName ==
                      User.Identity.Name).
                ToList();

            return(View(view));
        }
예제 #25
0
        public void EditIncome(IncomeDetails incomeDetails)
        {
            var income = _incomeRepository.GetById(incomeDetails.Id);

            var oldCost = income.Cost;

            income.Description = incomeDetails.Description;
            income.Cost        = incomeDetails.Cost;
            income.AccountId   = incomeDetails.AccountId;
            income.DateIncome  = incomeDetails.DateIncome;
            _incomeRepository.Update(income);

            if (oldCost != income.Cost)
            {
                var account = _bankAccountRepository.GetById(income.AccountId);
                MovementHelpers.Debit(_historicMovementRepository, oldCost, account.Id, ObjectType.Account, account.CurrentBalance);
                account.CurrentBalance -= oldCost;
                MovementHelpers.Credit(_historicMovementRepository, income.Cost, account.Id, ObjectType.Account, account.CurrentBalance);
                account.CurrentBalance += income.Cost;
                _bankAccountRepository.Update(account);
            }
        }
예제 #26
0
        public void EditAtmWithdraw(AtmWithdrawDetails atmWithdrawDetails)
        {
            var atmWithdraw = _atmWithdrawRepository.GetById(atmWithdrawDetails.Id);

            var oldCost = atmWithdraw.InitialAmount;

            atmWithdraw.InitialAmount         = atmWithdrawDetails.InitialAmount;
            atmWithdraw.CurrentAmount         = atmWithdrawDetails.InitialAmount;
            atmWithdraw.DateExpense           = atmWithdrawDetails.DateExpense;
            atmWithdraw.HasBeenAlreadyDebited = atmWithdrawDetails.HasBeenAlreadyDebited;

            _atmWithdrawRepository.Update(atmWithdraw);

            if (oldCost != atmWithdraw.InitialAmount)
            {
                var account = _bankAccountRepository.GetById(atmWithdraw.AccountId);
                MovementHelpers.Credit(_historicMovementRepository, oldCost, account.Id, ObjectType.Account, account.CurrentBalance);
                account.CurrentBalance += oldCost;
                MovementHelpers.Debit(_historicMovementRepository, atmWithdraw.InitialAmount, account.Id, ObjectType.Account, account.CurrentBalance);
                account.CurrentBalance -= atmWithdraw.InitialAmount;
                _bankAccountRepository.Update(account);
            }
        }
예제 #27
0
    // Update is called once per frame
    void Update()
    {
        if (!GameProperties.GetCurrentGame().gameStarted)
        {
            return;
        }

        GameObject ball = GameObject.FindGameObjectWithTag("Ball");

        float distance    = ball.transform.position.y - transform.position.y;
        float targetSpeed = Mathf.Sign(distance) * speed;

        if (Mathf.Abs(distance) < slowThreshold)
        {
            targetSpeed /= slowCurve;
        }


        currentSpeed = MovementHelpers.IncrementToward(currentSpeed, targetSpeed, acceleration);

        Vector2 amountToMove = new Vector2(0, currentSpeed);

        AIPhysics.Move(amountToMove * Time.deltaTime);
    }
예제 #28
0
        public EffectActor SpawnEffect(int actorSNO, Vector3D position, Vector3D facingTarget, TickTimer timeout = null)
        {
            float angle = MovementHelpers.GetFacingAngle(User.Position, facingTarget);

            return(SpawnEffect(actorSNO, position, angle, timeout));
        }
예제 #29
0
        private async Task <bool> KillLeftSeal(Client client, CSManager csManager, Action <uint> setTeleportId)
        {
            Log.Information($"Teleporting to {EntityCode.LeftSeal1}");
            var pathToLeftSeal = await _pathingService.GetPathToObject(client.Game.MapId, Difficulty.Normal, Area.ChaosSanctuary, client.Game.Me.Location, EntityCode.LeftSeal1, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToLeftSeal, MovementMode.Teleport))
            {
                Log.Warning($"Teleporting to {EntityCode.LeftSeal1} failed at location {client.Game.Me.Location}");
                return(false);
            }

            var leftSeal1            = client.Game.GetEntityByCode(EntityCode.LeftSeal1).First();
            var leftSeal2            = client.Game.GetEntityByCode(EntityCode.LeftSeal2).First();
            var leftSealKillLocation = leftSeal1.Location.Y > leftSeal2.Location.Y ? leftSeal1.Location.Add(26, -21) : leftSeal1.Location.Add(20, 40);

            if (!await GeneralHelpers.TryWithTimeout(async(_) =>
            {
                return(await client.Game.TeleportToLocationAsync(leftSealKillLocation));
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            if (!_townManagementService.CreateTownPortal(client))
            {
                return(false);
            }

            var myPortal = client.Game.GetEntityByCode(EntityCode.TownPortal).First(t => t.TownPortalOwnerId == client.Game.Me.Id);

            setTeleportId.Invoke(myPortal.Id);

            if (!await GeneralHelpers.TryWithTimeout(async(_) =>
            {
                return(await client.Game.TeleportToLocationAsync(leftSeal1.Location));
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            if (!GeneralHelpers.TryWithTimeout((_) =>
            {
                client.Game.InteractWithEntity(leftSeal1);
                return(leftSeal1.State == EntityState.Enabled);
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(_) =>
            {
                return(await client.Game.TeleportToLocationAsync(leftSeal2.Location));
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            if (!GeneralHelpers.TryWithTimeout((_) =>
            {
                client.Game.InteractWithEntity(leftSeal2);
                return(leftSeal2.State == EntityState.Enabled);
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(_) =>
            {
                return(await client.Game.TeleportToLocationAsync(leftSealKillLocation));
            }, TimeSpan.FromSeconds(5)))
            {
                return(false);
            }

            var action = GetSorceressKillAction(client);

            if (!await KillBosses(client, csManager, null, leftSealKillLocation, action, 0, () => 0))
            {
                return(false);
            }

            return(true);
        }
예제 #30
0
        private async Task <bool> KillTopSeal(Client client, CSManager csManager, Action <uint> setTeleportId)
        {
            Log.Information($"Teleporting to {EntityCode.TopSeal}");
            var pathToTopSeal = await _pathingService.GetPathToObject(client.Game.MapId, Difficulty.Normal, Area.ChaosSanctuary, client.Game.Me.Location, EntityCode.TopSeal, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToTopSeal, MovementMode.Teleport))
            {
                Log.Warning($"Teleporting to {EntityCode.TopSeal} failed at location {client.Game.Me.Location}");
                return(false);
            }

            var topSeal             = client.Game.GetEntityByCode(EntityCode.TopSeal).First();
            var toLeftOfSealIsValid = await _pathingService.IsNavigatablePointInArea(client.Game.MapId, Difficulty.Normal, Area.ChaosSanctuary, topSeal.Location.Add(-20, 0));

            var killLocation          = toLeftOfSealIsValid ? topSeal.Location.Add(-37, 31) : topSeal.Location.Add(0, 70);
            var pathToKillingLocation = await _pathingService.GetPathToLocation(client.Game, killLocation, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToKillingLocation, MovementMode.Teleport))
            {
                Log.Warning($"Teleporting to {pathToKillingLocation} failed at location {client.Game.Me.Location}");
                return(false);
            }

            if (!_townManagementService.CreateTownPortal(client))
            {
                return(false);
            }

            var myPortal = client.Game.GetEntityByCode(EntityCode.TownPortal).First(t => t.TownPortalOwnerId == client.Game.Me.Id);

            setTeleportId.Invoke(myPortal.Id);

            var pathToTopSeal2 = await _pathingService.GetPathToObject(client.Game.MapId, Difficulty.Normal, Area.ChaosSanctuary, client.Game.Me.Location, EntityCode.TopSeal, MovementMode.Teleport);

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToTopSeal2, MovementMode.Teleport))
            {
                Log.Warning($"Teleporting to {pathToKillingLocation} failed at location {client.Game.Me.Location}");
                return(false);
            }

            if (!await GeneralHelpers.TryWithTimeout(async(_) =>
            {
                client.Game.InteractWithEntity(topSeal);
                await Task.Delay(100);
                return(client.Game.GetEntityByCode(EntityCode.TopSeal).First().State == EntityState.Enabled);
            }, TimeSpan.FromSeconds(5)))
            {
                Log.Warning($"Opening {EntityCode.TopSeal} failed at location {client.Game.Me.Location}");
                return(false);
            }

            if (!await MovementHelpers.TakePathOfLocations(client.Game, pathToKillingLocation, MovementMode.Teleport))
            {
                Log.Warning($"Teleporting to {pathToKillingLocation} failed at location {client.Game.Me.Location}");
                return(false);
            }

            var action = GetSorceressKillAction(client);

            if (!await KillBosses(client, csManager, null, killLocation, action, 0, () => 0))
            {
                return(false);
            }

            return(true);
        }