protected override void GetRandomValues() { int speed = GlobalRandom.Next(3, 5); Pos = new Point(50, Game.Height / 2); Dir = new Point(0, 0); }
public void BreakWeapon(bool isExplosion) { IPlayer pl = User.GetPlayer(); if (pl != null && !pl.IsDead) { if (pl.CurrentWeaponDrawn == WeaponItemType.Rifle) { if (GlobalRandom.Next(0, 100) < (int)(WeaponBreakingChance * Armor.BreakWeaponFactor)) { Vector2 pos = pl.GetWorldPosition(); RifleWeaponItem weapon = pl.CurrentPrimaryWeapon; if ((weapon.WeaponItem == WeaponItem.BAZOOKA || weapon.WeaponItem == WeaponItem.GRENADE_LAUNCHER || weapon.WeaponItem == WeaponItem.FLAMETHROWER) && weapon.CurrentAmmo > 0 && (GlobalRandom.Next(0, 100) < WeaponExplosionChance || isExplosion)) { GlobalGame.TriggerExplosion(pos); } pl.RemoveWeaponItemType(WeaponItemType.Rifle); GlobalGame.PlayEffect("CFTXT", pl.GetWorldPosition(), "WEAPON BROKEN"); GlobalGame.CreateObject("MetalDebris00A", pos, (float)rnd.NextDouble()); pos.X += 5; GlobalGame.CreateObject("MetalDebris00B", pos, (float)rnd.NextDouble()); pos.X -= 10; GlobalGame.CreateObject("MetalDebris00C", pos, (float)rnd.NextDouble()); } } } }
public Vector2 GetRandomAirEnemy(PlayerTeam friendTeam, int id, ref int angle) { angle = 0; List <int> indexList = new List <int>(); for (int i = 0; i < AirPlayerList.Count; i++) { if (AirPlayerList[i].Player != null && (friendTeam != AirPlayerList[i].Player.GetTeam() || friendTeam == PlayerTeam.Independent) && !AirPlayerList[i].Player.IsDead) { for (int j = 0; j < AirPlayerList[i].StrikeList.Count; j++) { if (AirPlayerList[i].StrikeList[j].Id == id) { angle = AirPlayerList[i].StrikeList[j].Angle; indexList.Add(i); } } } } if (indexList.Count == 0) { return(new Vector2(0, 0)); } int rnd = GlobalRandom.Next(indexList.Count); return(AirPlayerList[indexList[rnd]].Player.GetWorldPosition()); }
private void RespawnUnknownObjects() { var unknownSpawnPositions = Game.GetObjectsByCustomId("SpawnUnknown"); if (unknownSpawnPositions.Length == 0) { return; } for (int i = 0; i < unknownSpawnPositions.Length; i++) { var trigger = unknownSpawnPositions[i]; if (trigger == null) { return; } var position = trigger.GetWorldPosition(); if (position == null) { return; } var index = GlobalRandom.Next(0, PossibleUnknownObjects.Count); var obj = Game.CreateObject(PossibleUnknownObjects[index], position); ObjectsToRemove.Add(obj); } }
public static Vector2 GetRandomWorldPoint() { Area area = GlobalGame.GetCameraArea(); return(new Vector2(GlobalRandom.Next((int)area.Left, (int)area.Right), GlobalRandom.Next((int)area.Bottom, (int)area.Top))); }
private static void Update() { Ship.Update(); foreach (BaseObject obj in BackgroundObjects) { obj.Update(); } foreach (BaseObject obj in Batteries) { obj.Update(); } foreach (BaseObject obj in Bullets) { obj.Update(); } foreach (BaseObject obj in Asteroids) { obj.Update(); } RemoveObjects(); PerformCollisions(); if (Batteries.Count < 3 && GlobalRandom.Next(0, 1000) < 100) { Battery battery = new Battery(); battery.BatterySpent += Battery_BatterySpent; battery.BatterySpent += Ship.Battery_BatterySpent; Batteries.Add(battery); } if (Score >= 10 * Level) { Level++; Asteroids.Add(new Asteroid()); } }
//functions public void Start() { CapturedBy = 0; CameraPosition = MapPosition; for (int i = 0; i < PointList.Count; i++) { PointList[i].Start(); } if (GlobalRandom.Next(0, 100) <= 20) { WeatherType weather = GlobalGame.GetWeatherType(); if (weather == WeatherType.None) { GlobalGame.SetWeatherType(WeatherType.Rain); return; } if (weather == WeatherType.Rain) { GlobalGame.SetWeatherType(WeatherType.Snow); return; } if (weather == WeatherType.Snow) { GlobalGame.SetWeatherType(WeatherType.None); return; } } }
public GameState(bool isFirst = false) { this.Statistics = new GameStatistics(); this.Level = new Level.Level(this, LevelGenerator.NewDefault.Silent); this.Level.GrowCrystals(); this.Player = new Wisp(this, Vector2.Zero); this.Camera = new Camera(this.Player); this.musicSettings = new MusicSettingsHud(this); this.ChasingEnemies = new HashSet <Monster>(); foreach (var tile in this.Level.Tilemap) { if (tile.Radius > 2 && tile.Info.Lightness < Settings.Game.Level.LightnessThreshold && GlobalRandom.NextBool(0.15)) { foreach (var i in Enumerable.Range(0, GlobalRandom.Next(1, 3))) { new Monster(this, this.Level.GetPosition(tile) + new Vector2(GlobalRandom.NextFloat(), GlobalRandom.NextFloat()) * 0.1f); } } } this.titleEndTime = isFirst ? 3 : 0; }
public bool CallAirstrike(TPlayer player) { int angle = 0; PlayerTeam team = player.Team; if (IsHacking(player.Team)) { team = GetEnemyTeam(player.Team); GlobalGame.RunCommand("MSG AIRSTRIKE HAS BEEN HACKED"); } Vector2 target = GetRandomAirEnemy(team, 2, ref angle); if (target.X == 0 && target.Y == 0) { if (IsHacking(player.Team)) { target = GetRandomWorldPoint(); } else { return(false); } } if (IsJamming(player.Team)) { target.X += GlobalRandom.Next(-99, 100); GlobalGame.RunCommand("MSG PINPOINT STRIKE HAS BEEN JAMMED"); } Vector2 position = GetBeginPointTarget(target, angle); TargetPosition = target; BeginPosition = position; return(true); }
public void CallAirDrop(TPlayer player, int count = 1) { Vector2 pos = player.User.GetPlayer().GetWorldPosition(); if (IsHacking(player.Team)) { TPlayer enemy = GetRandomPlayer(GetEnemyTeam(player.Team), true); if (enemy != null) { pos = enemy.User.GetPlayer().GetWorldPosition(); } else { pos = GetRandomWorldPoint(); } } pos.Y = WorldTop; int offset = 20; pos.X -= offset * (count - 1); for (int i = 0; i < count; i++) { GlobalGame.CreateObject("SupplyCrate00", pos); pos.X += offset; pos.Y += GlobalRandom.Next(-offset, offset); } }
public static Task[] Load() { return(File.ReadAllLines("assets/funny-task-names.txt").Select(taskName => { int taskDelay = GlobalRandom.Next(MIN_TASK_DELAY, MAX_TASK_DELAY); return Task.EmptyTask(taskName, taskDelay); }).ToArray()); }
protected override void GetRandomValues() { int speed = GlobalRandom.Next(3, 5); Pos = new Point(GlobalRandom.Next(Game.Width + 100, Game.Width + 500), GlobalRandom.Next(-500, -50)); Dir = new Point(speed, speed / 2); Size = new Size(speed * 10, speed * 10); }
/// <summary> /// Gibt ein zufälliges Loot-Objekt aus /// </summary> /// <param name="allLoot"></param> /// <returns>Ein zufälliges Loot-Objekt</returns> ///<exception cref="NoMatchingLootException">Bei leerem Inpu</exception> public ILootable <T> Loot(ILootable <T>[] allLoot) { if (allLoot.Length.Equals(0)) { throw new NoMatchingLootException("no input items"); } return(allLoot[GlobalRandom.Next(0, allLoot.Length)]); }
protected override void GetRandomValues() { int speed = GlobalRandom.Next(1, 15); Pos = new Point(0, GlobalRandom.Next(0, Game.Height)); Dir = new Point(speed, 0); Size = new Size(10, 4); }
protected override void GetRandomValues() { ResetPos(); Dir = new Point(GlobalRandom.Next(3, 7), GlobalRandom.Next(-3, 3)); int speed = (int)Math.Floor(Math.Sqrt(Math.Pow(Dir.X, 2) + Math.Pow(Dir.Y, 2))); Size = new Size(speed * 20, speed * 20); Damage = 5 * speed; }
public static int GetRandom(int min, int max) { if (_instance == null) { _instance = new GlobalRandom(); } return(_instance.Next(min, max)); }
public void SpawnDrone(TPlayer player, int id) { Area area = GlobalGame.GetCameraArea(); float x = GlobalRandom.Next((int)(area.Left + area.Width / 5), (int)(area.Right - area.Width / 5)); float y = area.Top + 10; CreateTurret(id, new Vector2(x, y), player.User.GetPlayer().FacingDirection, player.Team); GlobalGame.PlayEffect("EXP", new Vector2(x, y)); GlobalGame.PlaySound("Explosion", new Vector2(x, y), 1.0f); }
/// <summary> /// Играть в игру с ведущим /// </summary> /// <returns> true - выйграл, false - проиграл /// </returns> public bool Play() { Emcee emcee = new Emcee(); int choosedDoor = GlobalRandom.Next(0, 3); emcee.FirstChoice(choosedDoor); return(emcee.SecondChoice(strategy)); }
public static void SpawnDrone(int id, PlayerTeam team) { Area area = GlobalGame.GetCameraArea(); float x = GlobalRandom.Next((int)(area.Left + area.Width / 5), (int)(area.Right - area.Width / 5)); float y = area.Top - 10; CreateTurret(id, new Vector2(x, y), 1, team); GlobalGame.PlayEffect("EXP", new Vector2(x, y)); GlobalGame.PlaySound("Explosion", new Vector2(x, y), 1.0f); }
/// <summary> /// Wählt erst eine Seltenheit aus und dann durch den inneren Algorithmus das finale Loot-Objekt /// </summary> /// <param name="allLoot">Das ursprüngliche gesamte Loot</param> /// <returns>Das gelootete Objekt</returns> public ILootable <T> Loot(ILootable <T>[] allLoot) { int lowest = rarTable.Chain.Intervalls.First().X; int highest = rarTable.Chain.Intervalls.Last().Y; lastEntireRarRange = new Intervall(lowest, highest); lastRandomRoll = GlobalRandom.Next(lowest + 1, highest + 1); int intervallIndex = Array.FindIndex(rarTable.Chain.Intervalls, i => i.X <= lastRandomRoll && i.Y >= lastRandomRoll); lastRarRange = rarTable.Chain.Intervalls[intervallIndex]; lastProp = 100 / (double)(highest - lowest) * (double)lastRarRange.Range; lastRarName = rarTable.Values[intervallIndex]; return(lastLootingAlgorithm.Loot(allLoot.Where(i => i.Rarity > lastRarRange.X && i.Rarity <= lastRarRange.Y).ToArray())); }
public void Update(GameUpdateEventArgs e) { var detachCount = randomCount(this.turnOverRate * e.ElapsedTimeF); for (int j = 0; j < detachCount; j++) { var i = GlobalRandom.Next(particles.Count); this.particles[i].DetachFromParent(); this.particles[i].FadeAway(GlobalRandom.NextFloat(0.2f, 1f)); this.particles[i] = this.makeParticle(); } }
GameObject CoinChance() { GameObject c = new GameObject(); int coinchance = GlobalRandom.Next(0, 100); if (coinchance < 5) // Het diamandje heeft nu een kans van 5 procent als er een muntje word gespawnt, { c = Diamond; } else { c = Coin; } return(c); }
public object Execute(string script, string workDir = null) { var scriptPath = Path.Combine(PlaynitePaths.TempPath, $"BatchRuntime_{GlobalRandom.Next()}.bat"); FileSystem.PrepareSaveFile(scriptPath); FileSystem.WriteStringToFile(scriptPath, script); try { return(ExecuteFile(scriptPath, workDir)); } finally { FileSystem.DeleteFile(scriptPath); } }
public TShieldBlock(Vector2 position, float angle, PlayerTeam team) { Position = position; Angle = angle; Team = team; Sin = (float)Math.Sin(Angle); Cos = (float)Math.Cos(Angle); NSin = (float)Math.Sin(Angle + (float)Math.PI / 2); NCos = (float)Math.Cos(Angle + (float)Math.PI / 2); for (int i = 0; i < 2; i++) { ShieldGlass.Add(null); ShieldShard.Add(null); } AnimationTime = GlobalRandom.Next(50, 150); }
public void ContinueArtilleryStrike() { Stage++; int continuing = 100; int bulletPer = 10; if (Stage % bulletPer == 0) { Area area = GlobalGame.GetCameraArea(); Vector2 newPos = new Vector2(GlobalRandom.Next((int)area.Left, (int)area.Right), WorldTop); GlobalGame.SpawnProjectile(ProjectileItem.GRENADE_LAUNCHER, newPos, new Vector2(0, -1)); } if (Stage >= continuing) { MinusAmmo(); } }
public void ContinueMineStrike() { Stage++; int continuing = 70; int bulletPer = 10; if (Stage % bulletPer == 0) { Area area = GlobalGame.GetCameraArea(); Vector2 newPos = new Vector2(GlobalRandom.Next((int)area.Left, (int)area.Right), WorldTop); GlobalGame.CreateObject("WpnMineThrown", newPos); } if (Stage >= continuing) { MinusAmmo(); } }
// Functions /// <summary> /// Returns 4 random cards from the deck. /// </summary> /// <returns></returns> public IEnumerable <CardDrawed> DrawCards() { List <int> posiblePositions = new List <int>(Size); for (int i = 0; i < Size; i++) { posiblePositions.Add(i); } for (int i = 0; i < 4; i++) { int pos = GlobalRandom.Next(posiblePositions.Count - 1); yield return(new CardDrawed(_cards[posiblePositions.ElementAt <int>(pos)])); posiblePositions.RemoveAt(pos); } }
protected override void GetRandomValues() { int size = GlobalRandom.Next(20, 50); Pos = new Point(GlobalRandom.Next(0, Game.Width), GlobalRandom.Next(0, Game.Height / 20) * 20); Dir = new Point(GlobalRandom.Next(-3, 3), 0); Size = new Size(size, size); if (Dir.X < 0) { status = StarBStatus.RECESSION; } else { status = StarBStatus.GROWTH; } Dir.X = Math.Abs(Dir.X); }
public void CallReinforcement(TPlayer player) { Area area = GlobalGame.GetCameraArea(); for (int i = 0; i < PlayerList.Count; i++) { TPlayer pl = PlayerList[i]; if (pl != null && pl.IsActive() && pl != player && pl.Team == player.Team && !pl.IsAlive()) { float x = GlobalRandom.Next((int)(area.Left + area.Width / 5), (int)(area.Right - area.Width / 5)); float y = WorldTop + 50; IObject crate = GlobalGame.CreateObject("SupplyCrate00", new Vector2(x, y)); IObject platf = GlobalGame.CreateObject("Lift00A", new Vector2(x, y - 10)); IObject leftBorder = GlobalGame.CreateObject("Lift00A", new Vector2(x - 10, y), (float)Math.PI / -2); IObject rightBorder = GlobalGame.CreateObject("Lift00A", new Vector2(x + 10, y), (float)Math.PI / 2); leftBorder.SetBodyType(BodyType.Dynamic); rightBorder.SetBodyType(BodyType.Dynamic); IObjectDestroyTargets destroy = (IObjectDestroyTargets)GlobalGame.CreateObject("DestroyTargets", new Vector2(x, y)); platf.SetMass(1e-3f); leftBorder.SetMass(1e-3f); rightBorder.SetMass(1e-3f); IObjectWeldJoint joint = (IObjectWeldJoint)GlobalGame.CreateObject("WeldJoint", new Vector2(x, y)); joint.AddTargetObject(crate); joint.AddTargetObject(platf); joint.AddTargetObject(rightBorder); joint.AddTargetObject(leftBorder); destroy.AddTriggerDestroyObject(crate); destroy.AddObjectToDestroy(joint); destroy.AddObjectToDestroy(platf); destroy.AddObjectToDestroy(leftBorder); destroy.AddObjectToDestroy(rightBorder); ObjectsToRemove.Add(destroy); ObjectsToRemove.Add(platf); ObjectsToRemove.Add(joint); ObjectsToRemove.Add(leftBorder); ObjectsToRemove.Add(rightBorder); pl.Equipment.Clear(); pl.Armor.SetId(0); pl.Revive(100, false, true, x, y); player.AddExp(5, 5); } } }
public void Explode(float percentage, Vector3 impulse, float randomImpulse) { var detachCount = randomCount(this.particles.Count * percentage); for (int j = 0; j < detachCount; j++) { var i = GlobalRandom.Next(particles.Count); var oldParticle = this.particles[i]; oldParticle.DetachFromParent(); oldParticle.FadeAway(GlobalRandom.NextFloat(0.2f, 0.5f)); oldParticle.Push(impulse + GameMath.Vector2FromRotation(GlobalRandom.Angle(), GlobalRandom.NextFloat(randomImpulse)).WithZ(0)); this.particles[i] = this.makeParticle(); } }