Esempio n. 1
0
        private void Roll_RollUsed(Roll sender, Event.RollUsedEvent.RollUsedEventArgs e)
        {
            UpdateManager.BeginInvoke(650, () =>
            {
                var target = TargetSelector.CurrentTarget;
                var dist   = Owner.Distance2D(e.Destination);

                if (dist < 300)
                {
                    return;
                }

                var newTargetPos = PredictionManager.GetPrediction(e.PredictionInput).UnitPosition;

                if (StoneExtensions.FirstUnitBetween(Owner.Position, newTargetPos, StoneExtensions.StoneName, 250, 600) != null)
                {
                    return;
                }

                if (e.Destination.Distance2D(newTargetPos) > 200 + dist / 3)
                {
                    return;
                }

                UseAbility(Owner.Position.Extend(newTargetPos, 150));
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Main method for simulation orchestration
        /// </summary>
        /// <param name="simulation"></param>
        public static void StartOrchestration(Simulation simulation)
        {
            // init the simulation data path
            SetSimulationDataPath();

            // check for the last simulation
            if (File.Exists(_simulationFile))
            {
                Console.WriteLine("Reset the last simulation? Y/N");
                var userResponse = Console.ReadLine();
                if (userResponse?.ToLower() == "y" || userResponse?.ToLower() == "yes")
                {
                    StartSimulation(simulation);
                }
            }
            else
            {
                StartSimulation(simulation);
            }

            // build training and test dataset
            BuildMachineLearningSet(simulation.TrainingSetPercentage);

            // apply ML
            PredictionManager.StartPrediction(_trainingFile, _testFile, _simulationFile, simulation.PredictionSimulationTime);
        }
Esempio n. 3
0
        public static Vector3 MysticFlarePrediction(this MysticFlare mysticFlare, Unit target)
        {
            var dubleMysticFlare = false;
            var owner            = mysticFlare.Owner;

            if (mysticFlare.Owner.HasAghanimsScepter())
            {
                var localHero = EntityManager.LocalHero;
                dubleMysticFlare = EntityManager.GetEntities <Hero>().Count(x => !x.IsAlly(localHero) && !x.IsIllusion && x.IsVisible && x.IsAlive && x.Distance2D(target) <= 700) <= 1;
            }

            var input = new PredictionInput
            {
                Owner  = owner,
                Delay  = mysticFlare.CastPoint + mysticFlare.ActivationDelay,
                Range  = mysticFlare.CastRange,
                Radius = mysticFlare.Radius,
            };

            var output       = PredictionManager.GetPrediction(input.WithTarget(target));
            var castPosition = output.CastPosition;

            Vector3 position;

            if (target.NetworkActivity != NetworkActivity.Move || target.IsStunned() || target.IsRooted())
            {
                position = castPosition;
            }
            else
            {
                position = castPosition + (100 * target.Direction2D().ToVector3());
            }

            return(dubleMysticFlare ? castPosition + (175 * target.Direction2D().ToVector3()) : position);
        }
Esempio n. 4
0
        public ClientMainFeature(string name,
                                 IGameModule topLevelGameModule,
                                 SyncLastestManager netSyncManager,
                                 PlaybackManager playbackManager,
                                 PredictionManager userPredictionManager,
                                 AbstractPredictionProvider predicatoinProvider,
                                 ISimulationTimer simulationTimer,
                                 IVehicleCmdExecuteSystemHandler vehicleCmdExecuteSystemHandler,
                                 IVehicleExecutionSelector vehicleExecutionSelector,
                                 ICommonSessionObjects commonSessionObjects) : base(name)
        {
            topLevelGameModule.Init();

            Add(new ModuleInitSystem(topLevelGameModule, commonSessionObjects.AssetManager));
            Add(new EntityCreateSystem(topLevelGameModule));



            Add(new SyncLatestSystem(netSyncManager));
            if (!SharedConfig.IsOffline)
            {
                Add(new PlaybackInitSystem(playbackManager));
            }
            Add(new PlaybackExcuteSystem(topLevelGameModule));

            //添加游戏状态更新处理
            Add(new GameStateUpdateSystem(topLevelGameModule));

            // 需要在playback之后,因为要根据车的位置更新人的位置
            // 要在predicte之前,因为要根据车的位置,更像摄像机位置
            Add(new PhysicsInitSystem(topLevelGameModule));
            Add(new PhysicsUpdateSystem(topLevelGameModule));


            Add(new VehicleCmdExecuteManagerSystem(vehicleExecutionSelector, topLevelGameModule, vehicleCmdExecuteSystemHandler, simulationTimer, false, SharedConfig.ServerAuthorative));


            Add(new PhysicsPostUpdateSystem(topLevelGameModule));
            Add(new PredictionCompareSystem(userPredictionManager));
            Add(new UserPredictionSystem(topLevelGameModule,
                                         predicatoinProvider,
                                         userPredictionManager));


            Add(new ResourceLoadSystem(topLevelGameModule, commonSessionObjects.AssetManager));

            Add(new GamePlaySystem(topLevelGameModule));

            Add(new RenderSystem(topLevelGameModule));
            Add(new UiSystem(topLevelGameModule).WithExecFrameStep(EEcecuteStep.UIFrameStep));
            Add(new UiHfrSystem(topLevelGameModule));

            Add(new CommonLifeTimeSystem(commonSessionObjects.GameContexts));
            Add(new CommoTickImmutabblitySystem(commonSessionObjects.GameContexts));
            Add(new EntityCleanUpSystem(topLevelGameModule));

            Add(new CommonDestroySystem(commonSessionObjects));
        }
Esempio n. 5
0
 public Bus(string[] messages, int id, IGeoFence fence, int SequenceNr, string IconUrl, PredictionManager predictionManager = null)
 {
     _predictionManager = predictionManager;
     _geoFence          = fence;
     _messages          = messages;
     Id             = id;
     SequenceNumber = SequenceNr;
     this.IconUrl   = IconUrl;
 }
Esempio n. 6
0
        /// <summary>
        /// Private Methods Section
        /// </summary>

        ///Init method used to initialize subsystems to prevent having null objects
        private void InitSystems()
        {
            dailyMeteoSystem  = new DailyMeteoSystem();
            predictionManager = new PredictionManager();
            queryManager      = new QueryManager();
            dataRetreiver     = new DataRetreiver();
            resultHandler     = new ResultHandler();
            decisionMaker     = new DecisionMaker();
        }
        //        private PlayerStateCollectorPool gameStateProcessorFactory;
        //        private IStateProviderPool stateProviderPool;
        //        private IPlayerStateMap playerStateMap;

        public UserPredictionSystem(IGameModule gameModule, AbstractPredictionProvider provider,
                                    PredictionManager predictionManager)
        {
            logger.Info("start");
            this.provider          = provider;
            this.predictionManager = predictionManager;
            systems = gameModule.UserCmdExecuteSystems;
            //            gameStateProcessorFactory = gameStateProcessorFactory;
            //            stateProviderPool = gameStateProcessorFactory.GetProviderPool();
            //            playerStateMap = gameStateProcessorFactory.GetStatePool();
            Init();
        }
Esempio n. 8
0
    // Start is called before the first frame update
    void Start()
    {
        lineRenderer = GetComponent <LineRenderer>();
        GameObject _other = GameObject.Find("PredictionManager");

        predictionManager = _other.GetComponent <PredictionManager>();
        GameObject other = GameObject.Find("GameManager");

        gameManager        = other.GetComponent <GameManager>();
        rb                 = GetComponent <Rigidbody>();
        transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane + .2f));
    }
Esempio n. 9
0
        public Vector3 GetPrediction(Unit target)
        {
            var input = new PredictionInput
            {
                Owner = this.Owner,
                Range = 2000,
                Speed = this.Speed,
            };

            input = input.WithTarget(target);

            return(PredictionManager.GetPrediction(input).UnitPosition);
        }
Esempio n. 10
0
        public override bool UseAbility(Unit target)
        {
            if (!CanBeCasted() || target.IsMagicImmune())
            {
                return(false);
            }

            var rudePrediction = target.IsMoving ? target.InFront(target.Speed) : target.Position;

            float range = this.Range;
            float speed = this.Speed;

            bool willGetStoneBuff = (Owner.Spellbook.Spell4.CurrentCharges > 0 ||
                                     StoneExtensions.FirstUnitBetween(Owner.Position, rudePrediction, StoneExtensions.StoneName, 250, 400) != null);

            if (willGetStoneBuff)
            {
                range += 750;
                speed += 800;
            }

            if (range < Owner.Distance2D(target))
            {
                return(false);
            }

            var input = new PredictionInput
            {
                Delay  = Owner.TurnTime(rudePrediction) + 0.6f, // 0.6f is "cast point"
                Range  = range,
                Speed  = speed,
                Radius = this.Radius,
                Owner  = this.Owner
            };

            input = input.WithTarget(target);

            var predictionPoint = PredictionManager.GetPrediction(input).CastPosition;



            Base.Cast(predictionPoint);

            RollUsed?.Invoke(this, new RollUsedEventArgs(input, predictionPoint));

            return(true);
        }
Esempio n. 11
0
        private void OrderManager_OrderAdding(OrderAddingEventArgs e)
        {
            if (e.Order.Ability != Context.Dawnbreaker.Hammer)
            {
                return;
            }

            var Target = EntityManager.GetEntities <Hero>().Where(x => x.Position.Distance2D(GameManager.MousePosition) < 200 &&
                                                                  x.IsAlive &&
                                                                  x.IsEnemy(Context.Dawnbreaker.LocalHero) &&
                                                                  !x.IsIllusion).OrderBy(y => y.Position.Distance2D(GameManager.MousePosition));

            if (Target == null || Target.Count() == 0)
            {
                return;
            }

            var input = new PredictionInput
            {
                Owner = Context.Dawnbreaker.LocalHero,
                Speed = 1200,
                Delay = 0.6f,
                PredictionSkillshotType = PredictionSkillshotType.SkillshotLine
            };

            var range = HammerCastRange();

            input = input.WithTarget(Target.FirstOrDefault());

            var predictPos = PredictionManager.GetPrediction(input).CastPosition;
            var pos        = Context.Dawnbreaker.LocalHero.Distance2D(predictPos);
            var predict    = Context.Dawnbreaker.LocalHero.Position.Extend(predictPos, pos * 1.75f > range ? range : pos * 1.75f);

            Context.Dawnbreaker.Hammer.Cast(predict, false, true);

            UpdateManager.BeginInvoke((int)(Context.Dawnbreaker.LocalHero.Position.Distance2D(predict) > 800 ? Context.Dawnbreaker.LocalHero.Position.Distance2D(predict) : 800), () =>
            {
                Context.Dawnbreaker.Converge.Cast();
            });
        }
        public ActionResult GetCountryGroundWaterAvailabilityForFutureUse()
        {
            List <WaterPredictionModel> dataSet = Session["CompleteResultList"] as List <WaterPredictionModel>;

            var storageForFuture = dataSet.GroupBy(st => st.NameOfState)
                                   .Select(x => new {
                NameOfState = x.First().NameOfState,
                NetGroundWaterAvailabilityForFutureUse = x.Sum(xt => xt.NetGroundWaterAvailabilityForFutureUse.HasValue ?
                                                               (double?)Math.Round(xt.NetGroundWaterAvailabilityForFutureUse.Value) : 0)
            }).ToList();
            double?totalStorageForCountry = 0;

            foreach (var stateGroundWaterAvailabilityForFutureUse in storageForFuture)
            {
                totalStorageForCountry += stateGroundWaterAvailabilityForFutureUse.NetGroundWaterAvailabilityForFutureUse;
            }

            PredictionManager predictionManager           = new PredictionManager();
            List <AvarageYearlyCountryStorage> resultList = predictionManager.GetYearlyStorage(totalStorageForCountry, storageForFuture.Count);
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var resultJson = Json(serializer.Serialize(resultList), JsonRequestBehavior.AllowGet);

            return(resultJson);
        }
Esempio n. 13
0
 public virtual PredictionOutput GetPredictionOutput(PredictionInput input)
 {
     return(PredictionManager.GetPrediction(input));
 }
 public PredictionСheckSystem(ISnapshotBuffer snapshotBuffer, PredictionManager predictionManager)
 {
     this.snapshotBuffer    = snapshotBuffer;
     this.predictionManager = predictionManager;
 }
Esempio n. 15
0
        // private readonly MultiSleeper<string> _multiSleeper;

        public BombDamageManager(Updater updater)
        {
            _updater = updater;
            var me = updater._main.Me;

            DamageUpdater = UpdateManager.CreateUpdate(100, () =>
            {
                // O9K.Core.Managers.Entity.EntityManager9.EnemyHeroes
                foreach (var enemy in EntityManager.GetEntities <Hero>().Where(x =>
                                                                               x.IsValid && x.IsVisible && x.IsAlive && x.IsEnemy(me) && !x.IsIllusion))
                {
                    // var t = new O9K.Core.Entities.Heroes.Hero9(enemy);
                    var id                 = enemy.HeroId;
                    var landMineCount      = CalcLandMineCount(enemy);
                    var landMineCountMax   = CalcLandMineCount(enemy, false);
                    var removeMineCount    = CalcRemoteMineCount(enemy);
                    var removeMineCountMax = CalcRemoteMineCount(enemy, false);
                    var healthAfterSuicide = CalcHealthAfterSuicide(enemy);

                    if (DamageDictionary.TryGetValue(id, out var info))
                    {
                        info.UpdateInfo(landMineCount, landMineCountMax, removeMineCountMax, removeMineCount,
                                        healthAfterSuicide);
                    }
                    else
                    {
                        DamageDictionary.Add(id,
                                             new DamageInfo(landMineCount, landMineCountMax, removeMineCountMax, removeMineCount,
                                                            healthAfterSuicide));
                    }
                }
            });
            // var inActionSleeper = new MultiSleeper<uint>();
            UpdateManager.BeginInvoke(async() =>
            {
                while (true)
                {
                    var passedDelay = false;
                    starting:
                    var isForce = _updater.ForceStaff != null && _updater.ForceStaff.CanBeCasted();
                    var enemies = O9K.Core.Managers.Entity.EntityManager9.EnemyHeroes.OfType <Hero9>().Where(x =>
                                                                                                             x.IsValid && x.IsAlive && x.IsVisible && !x.IsIllusion && !x.IsMagicImmune && x.CanDie);
                    // var enemies = EntityManager.GetEntities<Hero>().Where(x =>
                    //     x.IsValid && x.IsVisible && x.IsAlive && x.IsEnemy(me) && !x.IsIllusion &&
                    //     !x.IsMagicImmune()/* &&
                    //     _updater._main.MenuManager.Targets.GetValue(x.HeroId)*/);
                    foreach (var enemy in enemies)
                    {
                        var handle = enemy.Handle;

                        if (MultiSleeper <uint> .Sleeping(handle))
                        {
                            continue;
                        }
                        if (enemy.HasModifier(new[]
                        {
                            "modifier_shredder_timber_chain", "modifier_storm_spirit_ball_lightning",
                            "modifier_item_aeon_disk_buff", "modifier_eul_cyclone",
                            "modifier_ember_spirit_sleight_of_fist_caster",
                            "modifier_ember_spirit_sleight_of_fist_caster_invulnerability",
                            "modifier_brewmaster_primal_split", "modifier_brewmaster_primal_split_delay",
                            "modifier_earth_spirit_rolling_boulder_caster", "modifier_morphling_waveform",
                            "modifier_phoenix_icarus_dive", "modifier_ursa_enrage"
                        }))
                        {
                            continue;
                        }
                        if (enemy.CanReincarnate && !_updater._main.MenuManager.DetonateOnAegis)
                        {
                            continue;
                        }

                        var itemBlink = enemy.Abilities.FirstOrDefault(x => x.Id == AbilityId.item_blink);
                        if (itemBlink != null)
                        {
                            if (itemBlink.Cooldown - itemBlink.RemainingCooldown <= 1 && itemBlink.Cooldown > 10)
                            {
                                continue;
                            }
                        }

                        var startManaCalc = 0f;
                        var threshold     = 0f;
                        var heroId        = enemy.Id;
                        var isDusa        = heroId == HeroId.npc_dota_hero_medusa;
                        var isAbba        = heroId == HeroId.npc_dota_hero_abaddon;
                        var health        = (float)enemy.Health;
                        if (isDusa)
                        {
                            startManaCalc = enemy.Mana;
                            var shield    = enemy.GetAbilityById(AbilityId.medusa_mana_shield);
                            if (shield.IsToggled)
                            {
                                threshold = shield.GetAbilitySpecialData("damage_per_mana");
                            }
                        }
                        else if (heroId == HeroId.npc_dota_hero_ember_spirit)
                        {
                            if (EmberShield == null)
                            {
                                EmberShield =
                                    enemy.GetAbilityById(AbilityId.ember_spirit_flame_guard);
                            }
                            if (enemy.HasModifier("modifier_ember_spirit_flame_guard"))
                            {
                                var extraLife = EmberShield.GetAbilitySpecialData("absorb_amount");
                                var talant    = enemy.GetAbilityById(AbilityId.special_bonus_unique_ember_spirit_1);
                                extraLife    += talant?.Level > 0
                                    ? talant.GetAbilitySpecialData("value")
                                    : 0;
                                health += extraLife;
                            }
                        }
                        else if (isAbba)
                        {
                        }


                        var raindrop = enemy.Abilities.FirstOrDefault(x => x.Id == AbilityId.item_infused_raindrop);
                        if (raindrop != null && raindrop.CanBeCasted())
                        {
                            var extraHealth = raindrop.BaseAbility.GetAbilitySpecialData("magic_damage_block");
                            health         += extraHealth;
                        }

                        var blockCount         = enemy.GetModifierStacks("modifier_templar_assassin_refraction_absorb");
                        var graveKeeper        = enemy.GetModifier("modifier_visage_gravekeepers_cloak");
                        var graveKeeperCount   = graveKeeper?.StackCount;
                        var aeon               = enemy.Abilities.FirstOrDefault(x => x.Id == AbilityId.item_aeon_disk);
                        var breakHealthForAeon = enemy.MaximumHealth * .7f;
                        var input              = new PredictionInput
                        {
                            Owner                   = me,
                            AreaOfEffect            = false,
                            CollisionTypes          = CollisionTypes.None,
                            Delay                   = 0.25f,
                            Speed                   = float.MaxValue,
                            Range                   = float.MaxValue,
                            Radius                  = 420,
                            PredictionSkillshotType = PredictionSkillshotType.SkillshotCircle
                        };
                        input          = input.WithTarget(enemy.BaseHero);
                        var prediction = PredictionManager.GetPrediction(input);
                        // ParticleManager.CircleParticle("123", prediction.CastPosition, 150, Color.Red);
                        var predictedPosition = prediction.CastPosition;
                        var pos     = /*_updater._main.MenuManager.UsePrediction ? predictedPosition :*/ enemy.Position;
                        var detList = new List <RemoteMine>();
                        var bombs   = updater
                                      .BombManager
                                      .RemoteMines
                                      .Where(x =>
                                             x.IsActive &&
                                             _updater._main.MenuManager.UsePrediction
                                    ? x.Position.IsInRange(pos, 420) && x.Position.IsInRange(predictedPosition, 420)
                                    : x.Position.IsInRange(pos, 420))
                                      .ToList();
                        var underStasisTrap = enemy.HasModifier("modifier_techies_stasis_trap_stunned");
                        foreach (var remoteMine in bombs.Where(x =>
                                                               x.StackerMain == null && x.Stacker.DetonateDict.TryGetValue(heroId, out var isEnable) &&
                                                               isEnable ||
                                                               x.StackerMain != null &&
                                                               x.StackerMain.Stacker.DetonateDict.TryGetValue(heroId, out var isEnable2) && isEnable2))
                        {
                            var damage = _updater._main.RemoteMine.GetDamage(remoteMine.Damage, enemy);
                            if (isDusa)
                            {
                                DamageCalcHelpers.CalcDamageForDusa(ref damage, ref startManaCalc, threshold);
                            }
                            detList.Add(remoteMine);
                            if (blockCount > 0)
                            {
                                blockCount--;
                            }
                            else if (graveKeeperCount > 0)
                            {
                                var percentBlock =
                                    (float)(enemy.GetAbilityById(AbilityId.visage_gravekeepers_cloak)
                                            .GetAbilitySpecialData("damage_reduction") *
                                            graveKeeperCount);
                                // TechiesCrappahilationPaid.Log.Warn(
                                //     $"Block:  {damage * (percentBlock / 100)}({percentBlock} %). Left blocks: {graveKeeperCount} " +
                                //     $"Damage changed: {damage} -> {damage - damage * (percentBlock / 100)}");
                                health -= damage - damage * (percentBlock / 100);
                                graveKeeperCount--;
                            }
                            else
                            {
                                health -= damage;
                            }

                            var extraDetonateTime = 0.25f * detList.Count;
                            var aeonByPass        = aeon != null && aeon.CanBeCasted() && health < breakHealthForAeon;


                            if (health + enemy.HealthRegeneration * extraDetonateTime < 0 || aeonByPass)
                            {
                                if (_updater._main.MenuManager.CameraMove)
                                {
                                    var heroPos         = enemy.Position;
                                    var consolePosition = $"{heroPos.X} {heroPos.Y}";
                                    GameManager.ExecuteCommand($"dota_camera_set_lookatpos {consolePosition}");
                                }

                                if (_updater._main.MenuManager.DelayOnDetonate.Value > 0 && !passedDelay &&
                                    !underStasisTrap)
                                {
                                    if (!MultiSleeper <string> .Sleeping("heroAfterForce" + heroId))
                                    {
                                        // TechiesCrappahilationPaid.Log.Warn(
                                        //     "delay on detonation start for " +
                                        //     _updater._main.MenuManager.DelayOnDetonate.Value.Value);
                                        await Task.Delay(_updater._main.MenuManager.DelayOnDetonate.Value);
                                        // TechiesCrappahilationPaid.Log.Warn("delay end");
                                        passedDelay = true;
                                        goto starting;
                                    }
                                }

                                await Task.Delay((int)(25 + GameManager.Ping));
                                if (_updater._main.MenuManager.DetonateAllInOnce && !aeonByPass)
                                {
                                    if (_updater._main.MenuManager.UseFocusedDetonation)
                                    {
                                        var minesToDetonate = bombs.FirstOrDefault();
                                        if (minesToDetonate != null)
                                        {
                                            _updater._main.FocusedDetonate.Cast(minesToDetonate.Position);
                                        }
                                    }
                                    else
                                    {
                                        foreach (var mine in bombs)
                                        {
                                            mine.Owner.Select(true);
                                        }

                                        await Task.Delay((int)(25 + GameManager.Ping));
                                        // OrderManager.CreateOrder(OrderType.Cast, bombs.Select(x => x.Owner), 0,
                                        //     bombs.FirstOrDefault().Owner.Spellbook.Spell1.AbilityIndex, Vector3.Zero,
                                        //     false, false, false);
                                        foreach (var mine in bombs)
                                        {
                                            mine.Owner.Spellbook.Spell1.Cast();
                                            mine.IsActive = false;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (var mine in detList)
                                    {
                                        mine.Owner.Select(true);
                                    }

                                    await Task.Delay((int)(25 + GameManager.Ping));
                                    // OrderManager.CreateOrder(OrderType.Cast, detList.Select(x => x.Owner).FirstOrDefault(), 0,
                                    //     detList.FirstOrDefault().Owner.Spellbook.Spell1.AbilityIndex, Vector3.Zero,
                                    //     false, false, false);
                                    foreach (var mine in detList)
                                    {
                                        mine.Owner.Spellbook.Spell1.Cast();
                                        mine.IsActive = false;
                                    }
                                }

                                MultiSleeper <uint> .Sleep(handle, extraDetonateTime + GameManager.Ping + 1500);


                                ////TODO: delay on detonation
                                goto EndOfActions;
                            }
                        }

                        if (isDusa)
                        {
                            startManaCalc = enemy.Mana;
                        }

                        if (isForce && _updater.ForceStaff.CanHit(enemy) && !enemy.IsRotating)
                        {
                            var isLinken = enemy.IsLinkensProtected;
                            if (isLinken && (_updater.Eul == null || !_updater.Eul.CanBeCasted()))
                            {
                                continue;
                            }

                            health            = enemy.Health;
                            var afterForcePos = enemy.BaseEntity.InFrontSuper(600);
                            foreach (var remoteMine in updater
                                     .BombManager.RemoteMines
                                     .Where(x => x.IsActive &&
                                            x.Position.IsInRange(
                                                afterForcePos,
                                                420) &&
                                            (
                                                x.StackerMain == null &&
                                                x.Stacker.DetonateDict.TryGetValue(heroId, out var isEnable) &&
                                                isEnable ||
                                                x.StackerMain != null &&
                                                x.StackerMain.Stacker.DetonateDict.TryGetValue(heroId,
                                                                                               out var isEnable2) && isEnable2
                                            )))
                            {
                                var damage = _updater._main.RemoteMine.GetDamage(remoteMine.Damage, enemy);
                                if (isDusa)
                                {
                                    DamageCalcHelpers.CalcDamageForDusa(ref damage, ref startManaCalc, threshold);
                                }
                                detList.Add(remoteMine);
                                health -= damage;
                                if (health + enemy.HealthRegeneration * 0.25f * detList.Count < 0)
                                {
                                    if (MultiSleeper <string> .Sleeping("force" + heroId))
                                    {
                                        continue;
                                    }
                                    if (isLinken)
                                    {
                                        _updater.Eul.UseAbility(enemy);
                                    }
                                    _updater.ForceStaff.UseAbility(enemy);

                                    if (enemy.CanBecomeMagicImmune && _updater.Hex != null &&
                                        _updater.Hex.CanHit(enemy) &&
                                        _updater.Hex.CanBeCasted())
                                    {
                                        _updater.Hex.UseAbility(enemy);
                                    }

                                    MultiSleeper <string> .Sleep("heroAfterForce" + heroId, 500);
                                    MultiSleeper <string> .Sleep("force" + heroId, 500);
                                }
                            }
                        }

                        EndOfActions:;
                    }

                    await Task.Delay(1);
                }
            });
        }
Esempio n. 16
0
        private Entitas.Systems CreateSystems(UdpSendUtils udpSendUtils, BattleRoyaleClientMatchModel matchModel,
                                              PingStatisticsStorage statisticsStorage)
        {
            GameSceneFactory gameSceneFactory = new GameSceneFactory();
            var            matchScene         = gameSceneFactory.Create();
            PhysicsSpawner physicsSpawner     = new PhysicsSpawner(matchScene);

            contexts = Contexts.sharedInstance;
            var updatePlayersSystem = new UpdatePlayersSystem(contexts, matchModel);

            playersStorage = updatePlayersSystem;
            var healthUpdaterSystem = new HealthUpdaterSystem(contexts);

            healthPointsStorage = healthUpdaterSystem;
            var maxHealthUpdaterSystem = new MaxHealthUpdaterSystem(contexts);

            maxHealthPointsMessagePackStorage = maxHealthUpdaterSystem;
            Vector3 cameraShift = new Vector3(0, 60, -30);
            ushort  playerTmpId = matchModel.PlayerTemporaryId;
            int     matchId     = matchModel.MatchId;
            Text    pingText    = battleUiController.GetPingText();

            pingSystem = new PingSystem(pingText, statisticsStorage);
            ClientInputMessagesHistory clientInputMessagesHistory = new ClientInputMessagesHistory(playerTmpId, matchId);
            ClientPrefabsStorage       clientPrefabsStorage       = new ClientPrefabsStorage();
            PhysicsVelocityManager     physicsVelocityManager     = new PhysicsVelocityManager();

            ArrangeTransformSystem[] arrangeCollidersSystems =
            {
                new WithHpArrangeTransformSystem(contexts)
            };
            PhysicsRollbackManager physicsRollbackManager = new PhysicsRollbackManager(arrangeCollidersSystems);
            PhysicsRotationManager physicsRotationManager = new PhysicsRotationManager();
            SnapshotFactory        snapshotFactory        = new SnapshotFactory(contexts.serverGame);
            PlayerPredictor        playerPredictor        = new PlayerPredictor(physicsRollbackManager, matchScene,
                                                                                contexts.serverGame, physicsVelocityManager, physicsRotationManager, snapshotFactory);
            PlayerEntityComparer      playerEntityComparer      = new PlayerEntityComparer();
            PredictedSnapshotsStorage predictedSnapshotsStorage = new PredictedSnapshotsStorage();
            AverageInputManager       averageInputManager       = new AverageInputManager();
            PredictionChecker         predictionChecker         = new PredictionChecker(playerEntityComparer, predictedSnapshotsStorage);
            SimulationCorrector       simulationCorrector       = new SimulationCorrector(playerPredictor, averageInputManager,
                                                                                          clientInputMessagesHistory, predictedSnapshotsStorage);
            var                predictionManager    = new PredictionManager(predictionChecker, simulationCorrector);
            Joystick           movementJoystick     = battleUiController.GetMovementJoystick();
            Joystick           attackJoystick       = battleUiController.GetAttackJoystick();
            LastInputIdStorage lastInputIdStorage   = new LastInputIdStorage();
            SnapshotBuffer     snapshotBuffer       = new SnapshotBuffer();
            var                snapshotInterpolator = new SnapshotInterpolator(snapshotBuffer);
            var                consoleStub          = new ConsoleNetworkProblemWarningView();
            NetworkTimeManager timeManager          = new NetworkTimeManager(pingStatisticsStorage, snapshotBuffer,
                                                                             consoleStub);
            INetworkTimeManager networkTimeManager = timeManager;
            ITimeUpdater        timeUpdater        = timeManager;

            snapshotManager  = new SnapshotManager(snapshotBuffer, snapshotInterpolator);
            transformStorage = new TransformMessageHandler(snapshotBuffer, timeUpdater);
            MatchTimeSystem   matchTimeSystem  = new MatchTimeSystem(networkTimeManager);
            IMatchTimeStorage matchTimeStorage = matchTimeSystem;
            var          updateTransformSystem = new UpdateTransformSystem(contexts, snapshotManager, matchTimeStorage);
            SpawnManager spawnManager          = new SpawnManager(clientPrefabsStorage, physicsSpawner);

            var killsIndicatorSystem = new KillsIndicatorSystem(battleUiController.GetKillMessage(), battleUiController.GetKillIndicator(),
                                                                battleUiController.GetKillsText(), battleUiController.GetAliveText(), matchModel.PlayerModels.Length,
                                                                new PlayerNameHelper(matchModel));

            killMessageStorage = killsIndicatorSystem;

            systems = new Entitas.Systems()
                      .Add(matchTimeSystem)
                      .Add(new ServerGameStateDebugSystem(snapshotBuffer, clientPrefabsStorage))
                      .Add(new PredictionСheckSystem(snapshotBuffer, predictionManager))
                      .Add(updateTransformSystem)
                      .Add(updatePlayersSystem)

                      .Add(new PrefabSpawnerSystem(contexts, spawnManager))
                      .Add(new InputSystem(movementJoystick, attackJoystick, clientInputMessagesHistory, snapshotManager,
                                           matchTimeStorage, lastInputIdStorage))

                      .Add(new PlayerStopSystem(contexts))
                      .Add(new PlayerPredictionSystem(contexts, clientInputMessagesHistory, playerPredictor))

                      .Add(new CameraMoveSystem(contexts, battleUiController.GetMainCamera(), cameraShift))
                      .Add(new LoadingImageSwitcherSystem(contexts, battleUiController.GetLoadingImage()))

                      .Add(killsIndicatorSystem)

                      .Add(healthUpdaterSystem)
                      .Add(maxHealthUpdaterSystem)

                      .Add(new HealthBarSpawnSystem(contexts, new HealthBarStorage()))
                      .Add(new HealthBarSliderUpdaterSystem(contexts))
                      .Add(new HealthBarPositionUpdaterSystem(contexts))
                      .Add(new HealthBarRotatingSystem(contexts, cameraShift))
                      .Add(new HealthTextUpdatingSystem(contexts))


                      .Add(new HealthBarDestroyHelperSystem(contexts))
                      .Add(new DestroyViewSystem(contexts))



                      .Add(new InputSenderSystem(udpSendUtils, clientInputMessagesHistory))
                      .Add(new RudpMessagesSenderSystem(udpSendUtils))
                      .Add(new GameContextClearSystem(contexts))
                      .Add(new PredictedSnapshotHistoryUpdater(contexts, predictedSnapshotsStorage, matchTimeStorage, lastInputIdStorage))
            ;
            return(systems);
        }