コード例 #1
0
        public void Perform()
        {
            _v.Target.Flags |= CalcFlag.HpAlteration;
            if (_v.Caster.CurrentHp % 10 != 7)
            {
                _v.Target.HpDamage = 1;
                return;
            }

            switch (GameRandom.Next8() % 4)
            {
            case 0:
                _v.Target.HpDamage = 7;
                break;

            case 1:
                _v.Target.HpDamage = 77;
                break;

            case 2:
                _v.Target.HpDamage = 777;
                break;

            default:
                _v.Target.HpDamage = 7777;
                break;
            }
        }
コード例 #2
0
    public override void Execute(MinEventParams _params)
    {
        Debug.Log("Executing Random Loot");
        EntityAliveSDX entity = _params.Self as EntityAliveSDX;

        // Only EntityAliveSDX
        if (entity == null)
        {
            return;
        }

        GameRandom _random = GameManager.Instance.World.GetGameRandom();
        float      Count   = 1f;

        if (entity.Buffs.HasCustomVar("spLootExperience"))
        {
            Count = entity.Buffs.GetCustomVar("spLootExperience");
        }

        Count = MathUtils.Clamp(Count, 1, 5);
        int MaxCount = (int)Math.Round(Count);

        // Loot group
        if (this.lootgroup.Length > 0)
        {
            Debug.Log("Generating Items : " + MaxCount);
            for (int x = 0; x < MaxCount; x++)
            {
                ItemStack item = LootContainer.GetRewardItem(lootgroup, Count);
                Debug.Log("Adding Item: " + item.ToString());
                entity.lootContainer.AddItem(item);
            }
        }
    }
コード例 #3
0
        public void Die()
        {
            if (currentState == MonsterAiState.StateDead)
            {
                return;
            }

            currentState    = MonsterAiState.StateDead;
            Character.State = CharacterState.Dead;

            CombatEntity.DistributeExperience();

            Character.IsActive = false;
            Character.Map.RemoveEntity(ref Entity, CharacterRemovalReason.Dead);

            if (SpawnEntry == null)
            {
                ServerLogger.LogWarning("Attempting to remove entity without spawn data! How?? " + Character.ClassId);
                World.Instance.RemoveEntity(ref Entity);
            }
            else
            {
                var min = SpawnEntry.SpawnTime;
                var max = SpawnEntry.SpawnTime + SpawnEntry.SpawnVariance;
                deadTimeout = GameRandom.NextFloat(min / 1000f, max / 1000f);
                if (deadTimeout < 0.4f)
                {
                    deadTimeout = 0.4f;                     //minimum respawn time
                }
                nextAiUpdate = Time.ElapsedTimeFloat + deadTimeout + 0.1f;
                deadTimeout += Time.ElapsedTimeFloat;
            }
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new EntityComposer class.
        /// </summary>
        public EntityComposer()
        {
            Projectiles      = new List <Projectile>();
            Enemies          = new List <Enemy>();
            Explosions       = new List <Explosion>();
            Input            = SGL.QueryComponents <InputManager>();
            _scoreIndicators = new List <ScoreIndicator>();
            Score            = 0;
            _random          = new GameRandom();

            var contentManager = SGL.QueryComponents <ContentManager>();

            var playerTexture = contentManager.Load <Texture2D>("shipAnimation.png");

            _projectileTexture = contentManager.Load <Texture2D>("laser.png");
            _enemyTexture      = contentManager.Load <Texture2D>("mineAnimation.png");
            _explosionTexture  = contentManager.Load <Texture2D>("explosion.png");
            EnableHPBars       = true;

            _laserFire = new SoundEffect(SGL.QueryResource <Sound>("laserFire.wav"),
                                         AudioManager.Instance.SoundEffectGroups[0]);
            _explosion = new SoundEffect(SGL.QueryResource <Sound>("explosion.wav"),
                                         AudioManager.Instance.SoundEffectGroups[0]);

            AudioManager.Instance.SoundEffectGroups[0].MasterVolume = 0.05f;

            Player = new Player(playerTexture);
        }
コード例 #5
0
ファイル: Vectors.cs プロジェクト: Zipcore/7Dmods
 public static Vector3 Randomize(GameRandom rand, Vector3 center, Vector3 radius) {
     return new Vector3(
         center.x + radius.x * (-1 + 2 * rand.RandomFloat),
         center.y + radius.y * (-1 + 2 * rand.RandomFloat),
         center.z + radius.z * (-1 + 2 * rand.RandomFloat)
     );
 }
コード例 #6
0
        public static bool Prefix(Archetype __result, string _name, List <Archetype> ___archetypes)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            if (DisplayLogs)
            {
                Debug.Log("GetArchetype(): " + _name);
            }
            int MaxArchetypes = ___archetypes.Count - 1;

            if (_name == "Random")
            {
                GameRandom random = GameRandomManager.Instance.CreateGameRandom();
                if (DisplayLogs)
                {
                    Debug.Log("GetArcheType(): Randomizing UMA. Randomized Pool Size: " + ___archetypes.Count);
                }

                int intRandom = random.RandomRange(0, MaxArchetypes);
                if (DisplayLogs)
                {
                    Debug.Log("Random Range: " + intRandom);
                }
                __result = ___archetypes[intRandom].Clone();

                return(false);
            }

            return(true);
        }
コード例 #7
0
    private IEnumerator Explode()
    {
        Vector3 pos = this.GetPosition();

        Vector3i where = V3i(pos);

        World world = GameManager.Instance.World;

        SpawnItem(pos, "thrownAmmoMolotovCocktail", new Vector3(0f, -0.1f, 0f));

        // world.SetBlockRPC(0, where, BlockValue.Air);  /// Fails to oestroy crate - matter of V3/V3i conversion ?
        this.Kill(DamageResponse.New(true));

        GameRandom random = AIAirDrop.controller.Random;

        for (int k = 0; k < 10; k++)
        {
            SpawnItem(
                pos + new Vector3(random.RandomRange(-3f, 3f), random.RandomRange(1f, 3f), random.RandomRange(-3f, 3f)),
                "rockBomb",
                new Vector3(random.RandomRange(-5f, 5f), random.RandomRange(-2f, 2f), random.RandomRange(-5f, 5f))
                );
            yield return(new WaitForSeconds(0.2f));

            SpawnItem(
                pos + new Vector3(random.RandomRange(-3f, 3f), random.RandomRange(1f, 3f), random.RandomRange(-3f, 3f)),
                "thrownAmmoMolotovCocktail",
                new Vector3(random.RandomRange(-5f, 5f), random.RandomRange(2f, 4f), random.RandomRange(-5f, 5f))
                );
            float dt = AIAirDrop.controller.Random.RandomRange(0.1f, 1f);
            yield return(new WaitForSeconds(dt));
        }
    }
コード例 #8
0
        public void Perform()
        {
            const UInt32 alteringStatuses = (UInt32)
                                            (BattleStatus.Petrify | BattleStatus.Silence | BattleStatus.Blind | BattleStatus.Trouble | BattleStatus.Zombie
                                             | BattleStatus.Death | BattleStatus.Confuse | BattleStatus.Berserk | BattleStatus.Stop | BattleStatus.Poison
                                             | BattleStatus.Sleep | BattleStatus.Heat | BattleStatus.Freeze | BattleStatus.Doom | BattleStatus.Mini);

            if (!_v.Target.CanBeAttacked())
            {
                return;
            }

            UInt32 status = 1;

            for (Int32 i = 0; i < 32; i++, status <<= 1)
            {
                if (GameRandom.Next8() >> 5 != 0)
                {
                    continue;
                }

                if ((status & alteringStatuses) != 0)
                {
                    _v.Target.AlterStatus((BattleStatus)status);
                }
                else if ((status & (UInt32)BattleStatus.LowHP) != 0 && !_v.Target.IsUnderStatus(BattleStatus.Death))
                {
                    _v.Context.Flags   |= BattleCalcFlags.DirectHP;
                    _v.Target.CurrentHp = (UInt16)(1 + GameRandom.Next8() % 9);
                }
            }
        }
コード例 #9
0
 public MinEventActionExplodeEntity() : base()
 {
     if (random == null)
     {
         random = GameRandomManager.Instance.CreateGameRandom();
     }
 }
コード例 #10
0
        public void GetSpecialAward()
        {
            int awardPoint = 0;

            foreach (var girl in FightingGirls)
            {
                awardPoint += (int)(girl.Attr1A * GetSpecilGuest().Attr1APoint);
                awardPoint += (int)(girl.Attr1B * GetSpecilGuest().Attr1BPoint);
                awardPoint += (int)(girl.Attr2A * GetSpecilGuest().Attr2APoint);
                awardPoint += (int)(girl.Attr2B * GetSpecilGuest().Attr2BPoint);
                awardPoint += (int)(girl.Attr3A * GetSpecilGuest().Attr3APoint);
                awardPoint += (int)(girl.Attr3B * GetSpecilGuest().Attr3BPoint);
            }

            int goldAward = ((awardPoint / 10000) + 1) * 200;

            PlayerData.Instance.AddCurrency(CURRENCY_TYPE.GOLD, goldAward);

            //equip
            int rateQ0 = Math.Max(10000 - awardPoint, 0);
            int rateQ1 = Math.Max(awardPoint - 40000, 0);
            int rateQ2 = Math.Max(awardPoint - 60000, 0);
            int rateQ3 = Math.Max(awardPoint - 80000, 0);

            int equipLevel = GameRandom.GetRandomLevel(rateQ0, rateQ1, rateQ2, rateQ3);

            if (equipLevel > 0)
            {
                var equipRecord = DropManager.GetRandomEquip(equipLevel);
                EquipPack.Instance.AddEquip(equipRecord);
            }
        }
コード例 #11
0
        private bool OutWaitStart()
        {
            target         = EcsEntity.Null;
            nextMoveUpdate = Time.ElapsedTimeFloat + GameRandom.NextFloat(3f, 6f);

            return(true);
        }
コード例 #12
0
        private void StealItem(BattleEnemy enemy, Int32 itemIndex)
        {
            Byte itemId = enemy.StealableItems[itemIndex];

            if (itemId == Byte.MaxValue)
            {
                UiState.SetBattleFollowFormatMessage(BattleMesages.CouldNotStealAnything);
                return;
            }

            enemy.StealableItems[itemIndex] = Byte.MaxValue;
            GameState.Thefts++;

            BattleItem.AddToInventory(itemId);
            UiState.SetBattleFollowFormatMessage(BattleMesages.Stole, FF9TextTool.ItemName(itemId));
            if (_v.Caster.HasSupportAbility(SupportAbility2.Mug))
            {
                _v.Target.Flags   |= CalcFlag.HpAlteration;
                _v.Target.HpDamage = (Int16)(GameRandom.Next16() % (_v.Caster.Level * _v.Target.Level >> 1));
            }

            if (_v.Caster.HasSupportAbility(SupportAbility1.StealGil))
            {
                GameState.Gil += (UInt32)(GameRandom.Next16() % (1 + _v.Caster.Level * _v.Target.Level / 4));
            }
        }
コード例 #13
0
        public void OnGlobalPostUpdate()
        {
            BallSpawningData spawningData = GlobalEntity.Current <BallSpawningData>();

            // can we spawn?
            if (spawningData.Remaining <= 0)
            {
                // create a new ball
                IEntity spawned = spawningData.Ball.Instantiate();

                // it isn't necessary to set the position of the spawned object to zero, but it
                // demos how to initialize a newly created entity
                PositionData spawnedPosition = spawned.AddOrModify <PositionData>();
                spawnedPosition.Position = new Bound(0, 0, spawnedPosition.Position.Radius);

                // reset the ticks until the next spawn
                GlobalEntity.Modify <BallSpawningData>().Remaining =
                    GameRandom.Range(spawningData.MinTicks, spawningData.MaxTicks);
            }

            // can't spawn yet; decrement the number of ticks until we can spawn again
            else
            {
                GlobalEntity.Modify <BallSpawningData>().Remaining--;
            }
        }
コード例 #14
0
        public void AiStateMachineUpdate()
        {
#if DEBUG
            if (!Character.IsActive && currentState != MonsterAiState.StateDead)
            {
                ServerLogger.LogWarning($"Monster was in incorrect state {currentState}, even though it should be dead (character is not active)");
                currentState = MonsterAiState.StateDead;
            }
#endif

            Profiler.Event(ProfilerEvent.MonsterStateMachineUpdate);

            for (var i = 0; i < aiEntries.Count; i++)
            {
                var entry = aiEntries[i];

                if (entry.InputState != currentState)
                {
                    continue;
                }

                if (!InputStateCheck(entry.InputCheck))
                {
                    continue;
                }

                if (!OutputStateCheck(entry.OutputCheck))
                {
                    continue;
                }

                //ServerLogger.Log($"Monster from {entry.InputState} to state {entry.OutputState} (via {entry.InputCheck}/{entry.OutputCheck})");

                Profiler.Event(ProfilerEvent.MonsterStateMachineChangeSuccess);

                currentState = entry.OutputState;
            }

            Character.LastAttacked = EcsEntity.Null;

            if (Character.Map != null && Character.Map.PlayerCount == 0)
            {
                nextAiUpdate = Time.ElapsedTimeFloat + 2f + GameRandom.NextFloat(0f, 1f);
            }
            else
            {
                if (nextAiUpdate < Time.ElapsedTimeFloat)
                {
                    if (nextAiUpdate + Time.DeltaTimeFloat < Time.ElapsedTimeFloat)
                    {
                        nextAiUpdate = Time.ElapsedTimeFloat + aiTickRate;
                    }
                    else
                    {
                        nextAiUpdate += aiTickRate;
                    }
                }
            }
        }
コード例 #15
0
 public void Perform()
 {
     if (_v.Target.CheckUnsafetyOrMiss() && _v.Target.CanBeAttacked())
     {
         _v.Context.Flags   |= BattleCalcFlags.DirectHP;
         _v.Target.CurrentHp = (UInt16)(1 + GameRandom.Next8() % 9);
         _v.Target.TryAlterStatuses(_v.Command.AbilityStatus, false);
     }
 }
コード例 #16
0
ファイル: ArrayExtensions.cs プロジェクト: n4gava/road-runner
    public static T[] Shuffle <T>(this T[] array)
    {
        if (array == null || array.Length == 0)
        {
            throw new Exception("O array deve possuir valores");
        }

        return(array.OrderBy(x => GameRandom.Get()).ToArray());
    }
コード例 #17
0
 /// <summary>
 ///     Initializes a new PipeManager class.
 /// </summary>
 /// <param name="pipeBody">The PipeBody.</param>
 /// <param name="pipeBottom">The PipeBottom head.</param>
 /// <param name="pipeTop">The PipeTop head.</param>
 public PipeManager(Texture2D pipeBody, Texture2D pipeBottom, Texture2D pipeTop)
 {
     _pipes      = new List <Pipe>();
     _pipeBody   = pipeBody;
     _pipeBottom = pipeBottom;
     _pipeTop    = pipeTop;
     _random     = new GameRandom();
     Opacity     = 1f;
 }
コード例 #18
0
ファイル: Vectors.cs プロジェクト: Zipcore/7Dmods
 public static Vector3 Randomize(GameRandom rand, float ray, Vector3 center) {
     /// GameRandom random = GameRandomManager.Instance.CreateGameRandom();
     // GameManager.Instance.World.GetGameRandom().RandomFloat
     return new Vector3(
         center.x + ray * (2 * rand.RandomFloat -1),
         center.y + ray * (2 * rand.RandomFloat -1),
         center.z + ray * (2 * rand.RandomFloat -1)
     );
 }
コード例 #19
0
    public static StageLogic RandomMonsters(string stageID, List <ELEMENT_TYPE> skillElement, List <ELEMENT_TYPE> monsterEle)
    {
        StageLogic stageLogic = new StageLogic();

        stageLogic._Waves = new List <WaveInfo>();

        int        randomWave  = GameRandom.GetRandomLevel(10, 60, 35) + 1;
        List <int> waves       = GetRandomValue(randomWave, 3, 3, 1);
        int        stageIdInt  = int.Parse(stageID);
        string     stageBaseID = (stageIdInt + 1000).ToString();

        for (int i = 0; i < randomWave; ++i)
        {
            WaveInfo waveInfo = new WaveInfo();
            stageLogic._Waves.Add(waveInfo);
            waveInfo.NPCs = new List <string>();

            int atkTotal     = 12;
            int randomNpcCnt = GameRandom.GetRandomLevel(10, 45, 45) + 1;
            for (int j = 0; j < randomNpcCnt; ++j)
            {
                MonsterInfo monster = new MonsterInfo();
                monster.ID = stageBaseID + i + j;
                int isBoxSkill = Random.Range(0, 10000);
                if (skillElement.Count > 0 && stageIdInt >= MAX_LEVEL * 0.1f && isBoxSkill < 3333)
                {
                    int randomEleIdx = Random.Range(0, skillElement.Count);
                    monster.Element = skillElement[randomEleIdx];
                    monster.ExSkill = GetRandomBoxSkill(stageIdInt, BattleField.ElementTypeToTrapType(monster.Element), monster.ID);
                }
                else
                {
                    int randomEleIdx = Random.Range(0, skillElement.Count + monsterEle.Count);
                    if (randomEleIdx > skillElement.Count - 1)
                    {
                        monster.Element = monsterEle[randomEleIdx - skillElement.Count];
                    }
                    else
                    {
                        monster.Element = skillElement[randomEleIdx];
                    }
                }
                monster.AttackSkill = Random.Range(1, 10).ToString();
                int atkMax = Mathf.Min(atkTotal, 10);
                monster.AttackRate = Random.Range(1, atkMax);
                atkTotal          -= monster.AttackRate;
                atkTotal           = Mathf.Max(1, atkTotal);
                monster.HpRate     = Random.Range(1, 11);

                waveInfo.NPCs.Add(monster.ID);
                RandomMonsterList.Add(monster.ID, monster);
            }
        }

        return(stageLogic);
    }
コード例 #20
0
        public void Perform()
        {
            _v.Target.Flags |= CalcFlag.MpAlteration;
            if (_v.Target.CurrentMp == 0)
            {
                return;
            }

            _v.Target.MpDamage = (Int16)Math.Min(9999, GameRandom.Next16() % _v.Target.CurrentMp);
        }
コード例 #21
0
        private void InitDaylyMission()
        {
            var randomIdxs = GameRandom.GetIndependentRandoms(0, TableReader.MissionInfo.DaylyMissionRecords.Count, _DaylyMissionCount);

            _DaylyMissions.Clear();
            foreach (var randomIdx in randomIdxs)
            {
                _DaylyMissions.Add(new MissionInfo(TableReader.MissionInfo.DaylyMissionRecords[randomIdx], MissionInfo.MISSION_STATUES.MISSION_ACCEPT));
            }
        }
コード例 #22
0
 private void TryAddWeaponStatus()
 {
     if (_v.Caster.HasSupportAbility(SupportAbility1.AddStatus))
     {
         _v.Context.StatusRate = _v.Caster.WeaponRate;
         if (_v.Context.StatusRate > GameRandom.Next16() % 100)
         {
             _v.Context.Flags |= BattleCalcFlags.AddStat;
         }
     }
 }
コード例 #23
0
        public void MultiThread_NumbersAreUnique()
        {
            var collection = new BlockingCollection <int>();

            Parallel.ForEach(Enumerable.Range(0, 1000), i =>
            {
                var random = GameRandom.Between(int.MinValue, int.MaxValue);
                collection.Add(random);
            });
            output.WriteLine($"Repeated values: {collection.Count() - collection.Distinct().Count()}");
            Assert.True(collection.Distinct().Count() == collection.Count());
        }
コード例 #24
0
    public BlockDefinition GetRandomNormal(int level, int width, GameRandom gameRandom = null,
                                           List <BlockDefinition> excludedDef          = null)
    {
        var n = GetNormalBlocks();

        if (excludedDef != null && excludedDef.Count > 0)
        {
            n.RemoveAll(b => excludedDef.Contains(b));
        }

        return(n[Random.Range(0, n.Count)]);
    }
コード例 #25
0
    private IEnumerator UpdateDestination()
    {
        while (true)
        {
            ProgressPath = 0;
            //NavAgent.CalculatePath (PlayerPosition.position, Path);

            //Debug.Log ("Calculating path to: " + PlayerPosition.position + ", Path length: " + Path.corners.Length);

            yield return(new WaitForSeconds(GameRandom.NextFloat(0.9f, 1.1f) * UpdateDestinationDelay));
        }
    }
コード例 #26
0
    private static bool IsInit = false; // prevent on 2nd game ?
    public static void Init(int playerId)
    {
        /*
         * Should be safe to do multiple calls ...
         * - Depends on Map so need re apply on game change
         * - Should only be called once per game (mostly because of thread start)
         *
         * - Check: multiplayer local
         *  - Called twice with 2 local players -> if below
         *  - Each player triggers on connect ?
         */

        /* I should put this all in the buff ?? Anythin here may be duplicate */
        if (IsInit)
        {
            Printer.Write("Zombiome is already init !", playerId);
            // if (AutoStart) {
            //     ZombiomeManager.Reset(playerId, "");
            // }
            return;
        }

        Printer.Write("Zombiome.Init():", playerId);

        CSutils.Routines.Sanitizer.Fixer = () => ZombiomeManager._Reset(-1);
        CSutils.Catcher.SwallowErrors    = SwallowError;

        rand      = GameRandomManager.Instance.CreateGameRandom();
        worldSeed = GamePrefs.GetString(EnumGamePrefs.WorldGenSeed);
        worldSize = GamePrefs.GetInt(EnumGamePrefs.WorldGenSize);

        ZBiomeInfo.Define();

        if (nz4)
        {
            Zone.Get = Zone.GetFour;
        }
        else
        {
            Zone.Get = position => new Zone[] { Zone.GetSingle(position) }
        };
        ZBActivity.ZombiomeActivitySelector.Initialize();

        if (AutoStart)
        {
            ZombiomeManager.Reset(playerId, "");
        }
        IsInit = true; // bugs on restart new game coz no one set to none - use World hash ?

        Printer.Write("Zombiome..Init: Done");
        // ZombiomeManager.Start(playerId); // manually until release
    }
コード例 #27
0
 private static Vector3 Upward(GameRandom rand, int wgt) {
     // gen is 1.1 Up + Rdm 1
     Vector3 dir = Vectors.Float.Randomize(rand, 0.5f, Vectors.Float.UnitY);
     dir = dir.normalized;
     // dir.y = (0.5f + Math.Abs(dir.y)) / 2;
     dir = dir.normalized;
     // dir = dir * wgt * 0.5f;    // mass dependant !  still make a bit random and wgt dependant ?
     dir = dir * 10;
     // dir = dir * (float) Math.Sqrt(wgt); 
     dir = dir * 2.5f; // too small for tree (m=20-50), too large for boulder (m=100) ?
     dir = dir * (1f + rand.RandomFloat);
     return dir;
 }
コード例 #28
0
        public void Reset()
        {
            Entity       = EcsEntity.Null;
            Character    = null;
            aiEntries    = null;
            SpawnEntry   = null;
            CombatEntity = null;
            searchTarget = null;
            aiTickRate   = 0.1f;
            nextAiUpdate = Time.ElapsedTimeFloat + GameRandom.NextFloat(0, aiTickRate);

            target = EcsEntity.Null;
        }
コード例 #29
0
        public List <GirlInfoRecord> GetRandomGirlInStar(int star, int num)
        {
            var girlList   = Tables.TableReader.GirlInfo.GetStarGirls(star);
            var randomList = GameRandom.GetIndependentRandoms(0, girlList.Count, num);

            List <GirlInfoRecord> randomGirlList = new List <GirlInfoRecord>();

            foreach (var randomIdx in randomList)
            {
                randomGirlList.Add(girlList[randomIdx]);
            }

            return(randomGirlList);
        }
コード例 #30
0
    private IEnumerator SpawnerWorking()
    {
        while (true)
        {
            yield return(new WaitForSeconds(GameRandom.NextFloat(0.5f, 1.5f) * SpawnDelay));

            while (SpawnerAreaOccupied)
            {
                yield return(new WaitForSeconds(0.3f));
            }

            GameObject enemy = Instantiate(ChooseMonsterToSpawn(), transform.position, new Quaternion());
        }
    }