protected override void GetRandomValues() { int speed = GlobalRandom.Next(3, 5); Pos = new Point(50, Game.Height / 2); Dir = new Point(0, 0); }
public override void Draw(SpriteManager sprites) { if (this.game.DrawDebug) { var v = this.game.Level.GetPosition(this.Tile); var geo = sprites.EmptyHexagon; geo.Color = new Color(Color.Green, 0); geo.DrawSprite(v, 0, Settings.Game.Level.HexagonDiameter); } this.particles.Draw(sprites); var healthPercentage = this.HealthPercentage; var light = GlobalRandom.NextFloat(healthPercentage * healthPercentage, healthPercentage); sprites.PointLight.Draw(this.position.WithZ(1.5f), Color.LightYellow, 1f, 5 + 10 * light); var blink = sprites.Blink; blink.Color = Color.LightYellow.WithAlpha(0.5f) * 0.3f; blink.DrawSprite(this.position.WithZ(1.5f), 0, 1 + light * 2); }
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 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); } }
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 void NextDouble() { // no params int count = 30, minVal = 0, maxVal = 1; var nums = new List <double>(ArrayBuilder.repeat(() => GlobalRandom.NextDouble(), count)); foreach (var num in nums) { Assert.IsTrue(num >= minVal && num < maxVal); } // count nums = new List <double>(GlobalRandom.NextDoubleArr(count)); Assert.IsTrue(nums.Count == count); foreach (var num in nums) { Assert.IsTrue(num >= minVal && num < maxVal); } // count, min, max minVal = -2; maxVal = 2; nums = new List <double>(GlobalRandom.NextDoubleArr(count, minVal, maxVal)); Assert.IsTrue(nums.Count == count); foreach (var num in nums) { Assert.IsTrue(num >= minVal && num < maxVal); } }
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 Egg LayEgg(Vector3 position) { var resource = Resources.Load("Prefabs/Food/egg"); if (resource == null) { Debug.Log("알이 없어.."); return(null); } GameObject objectBase = Instantiate(resource, position, Quaternion.identity) as GameObject; string objID = $"egg_{s_uniqueID++}"; Egg egg = objectBase.GetComponent <Egg>(); egg.ObjectID = objID; int r = GlobalRandom.GetRandom(0, 10); Debug.Log($"랜덤 {r}"); bool male = r < 5; egg.male = male; foodsList.Add(objID, egg); eggCount++; return(egg); }
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()); }
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))); }
public B_Brain(int inputCount, int outputCount, int numberOfIntermediateLayers, int intermediateLayerCount) { int nid = 0; Neurons = new B_Neuron[numberOfIntermediateLayers + 2][]; Neurons[0] = new B_Neuron[inputCount]; for (int i = 0; i < inputCount; i++) { Neurons[0][i] = new B_Neuron(nid++); } for (int layer = 0; layer < numberOfIntermediateLayers; layer++) { Neurons[layer + 1] = new B_Neuron[intermediateLayerCount]; for (int i = 0; i < intermediateLayerCount; i++) { Neurons[layer + 1][i] = new B_Neuron(nid++); } } Neurons[numberOfIntermediateLayers + 1] = new B_Neuron[outputCount]; for (int i = 0; i < outputCount; i++) { Neurons[numberOfIntermediateLayers + 1][i] = new B_Neuron(nid++); } for (int layer = 1; layer < Neurons.Length; layer++) { for (int i = 0; i < Neurons[layer - 1].Length; i++) { for (int j = 0; j < Neurons[layer].Length; j++) { Neurons[layer][j].AddConnection(Neurons[layer - 1][i], GlobalRandom.NextBetween(-1, 1)); } } } M_NeuronID = nid; }
//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 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()); }
public void CreateAndCompileModel3() { Console.WriteLine("Creating model"); GlobalRandom.InitializeRandom(); int imgSize = 75; ReluActivation reluActivation = new ReluActivation(); SoftmaxActivation softmaxActivation = new SoftmaxActivation(); model = new ConvolutionalNeuralNetwork(imgSize, "rgb"); model.Add(new ConvolutionalLayer(5, 5, reluActivation, "valid")); model.Add(new MaxPoolingLayer()); model.Add(new ConvolutionalLayer(5, 3, reluActivation, "valid")); model.Add(new MaxPoolingLayer()); model.Add(new DropoutLayer(0.2)); model.Add(new FlattenLayer()); model.Add(new DropoutLayer(0.5)); model.Add(new DenseLayer(26, softmaxActivation)); Console.WriteLine("Model created"); model.Compile(); Console.WriteLine("Model compiled"); }
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; }
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()); } }
/// <summary> /// Fires the weapon /// </summary> public override void Fire() { var facingRightFactor = this.Mech.IsFacingRight ? 1 : -1; // Set overriding animation this.Animatable.PlayClip("fire", 1, true); this.EquippedOnArm.PlayClip(this.ArmAnimationClipName, 1, true); // Set shoot pellet count int shootCount = (int)this.PelletCount; float diff = this.PelletCount - shootCount; if (GlobalRandom.NextFloat() < diff) { shootCount++; } // Camera shake MainCamera.CurrentInstance.Shake(this.ScreenShake); // Adjust knock back var hitX = this.BaseHit.KnockBack.x * facingRightFactor; var adjustedHit = new WeaponHitStat(this.BaseHit); adjustedHit.KnockBack = new Vector2(hitX, this.BaseHit.KnockBack.y); // Apply recoil var recoilX = -this.BaseStats.Recoil * facingRightFactor; this.Mech.ApplyKnockback(new Vector2(recoilX, 0), this.BaseStats.Recoil, 0); // Fire all pellets for (int shoot = 0; shoot < shootCount; shoot++) { // Determine inaccuracy var inaccuracy = (100 - this.BaseStats.Accuracy) / 200 * GlobalRandom.NextFloat() * Mathf.PI; if (GlobalRandom.NextBool()) { inaccuracy *= -1; } var shootX = Mathf.Cos(inaccuracy) * facingRightFactor; var shootY = Mathf.Sin(inaccuracy); var rayCastHits = Physics2D.RaycastAll(this.MuzzleLocation.transform.position, new Vector2(shootX, shootY)); for (var i = 0; i < rayCastHits.Length; i++) { var curHit = rayCastHits[i]; var hittable = curHit.collider.GetComponent <IHittable>(); if (hittable != null && hittable.Faction != adjustedHit.Faction) { hittable.OnHit(adjustedHit); var newBullet = Instantiate(this.BulletLinePrefab); newBullet.OnBulletHit(this.MuzzleLocation.transform.position, curHit); break; } } } }
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)]); }
public static GlobalRandom getInstance() { if (instance == null) { instance = new GlobalRandom(); } return(instance); }
public void SpawnReset(GameTimer timer) { fallingItems.Add(new LunchItem(new Vector2((float)GlobalRandom.NextBetween(0, Settings.GP_X - LunchItem.Width), -LunchItem.Height), GlobalRandom.RandomFrom(Goodies))); if (keepSpawning) { GameTimer.AddStaticTimer(Last, new TimeSpan(0, 0, 0, 0, GlobalRandom.random.Next(MAX_TIME - MIN_TIME) + MIN_TIME), SpawnReset); } }
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); }
private Particle makeParticle() { return(new Particle(this.game, this.parent, GameMath.Vector3FromRotation(GlobalRandom.Angle(), GlobalRandom.Angle(), this.size) * new Vector3(1, 1, 0.5f), new Vector3(), color, GlobalRandom.NextFloat(0.8f, 1.2f) * this.size)); }
public Crystal(GameState game, Vector2 position) : base(game, position, 0) { var tileLight = this.Tile.Info.Lightness; this.range = (0.5f + tileLight) * GlobalRandom.NextFloat(8, 9); this.color = Color.FromHSVA(GlobalRandom.NextFloat(0.6f, 0.8f) * GameMath.TwoPi, 0.1f, 1f); }
public static int GetRandom(int min, int max) { if (_instance == null) { _instance = new GlobalRandom(); } return(_instance.Next(min, max)); }
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 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> /// Играть в игру с ведущим /// </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 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); }
private static int randomCount(float randomCountFloat) { var randomCount = (int)randomCountFloat; if (GlobalRandom.NextBool(randomCountFloat - randomCount)) { randomCount++; } return(randomCount); }