/// <summary> /// This creates random size in random location /// TODO: Look at existing sizes more carefully to see what size to create /// TODO: Don't create something near the player - take a list of spheres to avoid (or maybe cubes) /// TODO: Have certain features of the map be sources - maybe a couple hidden moving sources that slowly move around the edge of the map /// TODO: When creating asteroids, create a small stream of them /// </summary> private static ChangeInstruction[] ExamineAsteroids_Add1(int count, Boundry boundry) { ChangeInstruction[] retVal = new ChangeInstruction[count]; for (int cntr = 0; cntr < count; cntr++) { //asteroidSize = 4 + (rand.NextDouble() * 6); // medium //asteroidSize = 9 + (rand.NextDouble() * 10); // large double asteroidSize = 4 + StaticRandom.NextDouble(16); Point3D position = Math3D.GetRandomVector(boundry.Outer_Min, boundry.Outer_Max, boundry.Inner_Min, boundry.Inner_Max).ToPoint(); Vector3D velocity = Math3D.GetRandomVector_Circular(6d); Vector3D angVel = Math3D.GetRandomVector_Spherical(1d); AsteroidDNA asteroid = new AsteroidDNA() { PartType = Asteroid.PARTTYPE, Radius = asteroidSize, Position = position, //NOTE: These are duplication and aren't used, but storing them anyway Velocity = velocity, AngularVelocity = angVel, }; retVal[cntr] = new ChangeInstruction(position, velocity, angVel, asteroid); } return(retVal); }
public void AddRow(Boundry row) { this.Rows.Add(row); this.Size = new Size { Height = Rows.Max(x => x.Index + x.Length), Width = Size.Width }; }
public void AddColumn(Boundry column) { this.Columns.Add(column); this.Size = new Size { Height = Size.Height, Width = Columns.Max(x => x.Index + x.Length) }; }
protected virtual void Start() { boundryPosition = GameMaster.instance.boundry; // set boundry form GameMaster rigidbody = GetComponent<Rigidbody>(); // get reference to health bar currentHealth = maxHealth; if (visualWeapons.Count > 0) // get Reference to all Weapons for (int i = 0; i < visualWeapons.Count; i++) visualWeapons[i].weaponScripts = WeaponCreator(ref visualWeapons[i].weapon, ref visualWeapons[i].weaponSpawn); }
private float objectsTimeLeft, asteroidsTimeLeft, nebulasTimeLeft, spaceRocketsTimeLeft; // how many times left to spawn objects void Start() { if (!spawnObjects) { return; // if there is no spawnObjets, do nothing } boundryMap = GameMaster.instance.boundry; CreateObjectOnStart(2); // create objets that will appeare on screen from begining StartCoroutine(SpawnObjectUpdate()); // start loop that create objects on background }
IEnumerator RandomObjectSpawner(GameObject objectToSpawn, Boundry objectsPosition, float objectSpawnTime) // method for only one gameobject { while (IsPlayerAlive) // spawn objects all the time { yield return new WaitForSeconds(objectSpawnTime); Vector3 randPosition = new Vector3(Random.Range(-objectsPosition.left, objectsPosition.right), 0, objectsPosition.up); // choose random object position GameObject newObject = Instantiate(objectToSpawn, randPosition, Quaternion.identity) as GameObject; // create new object objectsList.Add(newObject.transform); // add object to list newObject.transform.SetParent(hierarchyGuard); // parent Enemy to hierarchyGuard } }
IEnumerator RandomEnemiesSpawner(GameObject[] objectsToSpawn, Boundry objectsPosition, float objectSpawnTime) { while (IsPlayerAlive) // spawn objects all the time { yield return new WaitForSeconds(objectSpawnTime); GameObject randObject = objectsToSpawn[Random.Range(0, objectsToSpawn.Length)]; // choose random object Vector3 randPosition = new Vector3(Random.Range(objectsPosition.left, objectsPosition.right), 0, objectsPosition.up); // choose random object position GameObject newObject = Instantiate(randObject, randPosition, Quaternion.identity) as GameObject; // create new object objectsList.Add(newObject.transform); // add object to list newObject.transform.SetParent(hierarchyGuard); // parent Enemy to hierarchyGuard if (!isEnemyShooting) // if flag means that enemy shouldn't shoot newObject.GetComponent<EnemyController>().SetShooting(false); // enemy after spawn won't be eable to shoot } }
public void Start(bool?opulsate, bool?ocenter, TouchPoint point, Boundry boundry) { var pulsate = opulsate ?? false; var center = ocenter ?? (Center || pulsate); double rippleX, rippleY, rippleSize; double?clientX = point.ClientX; double?clientY = point.ClientY; if (center || (clientX is null || clientX.Value == 0) || !point.IsTouch) { rippleX = boundry.Width / 2; rippleY = boundry.Height / 2; }
internal Cell( IReadOnlyCollection <int> allowedValues, Boundry row, Boundry column, Boundry subGrid, int value) { _allowedValues = allowedValues; if (value != 0 && !_allowedValues.Contains(value)) { throw new ArgumentException($"Invalid value {value}", nameof(value)); } _boundries = new[] { row, column, subGrid }; foreach (var boundry in _boundries) { boundry.Append(this); } Value = value; }
public MapPopulationManager(Map map, World world, Point3D boundryMin, Point3D boundryMax, int material_Asteroid, int material_Mineral, Func <double, ITriangleIndexed[], double> getAsteroidMassByRadius, Func <double, MineralDNA[]> getMineralsByDestroyedMass, double minChildAsteroidRadius) { _map = map; _world = world; _boundry = new Boundry(boundryMin, boundryMax); _material_Asteroid = material_Asteroid; _material_Mineral = material_Mineral; _getAsteroidMassByRadius = getAsteroidMassByRadius; _getMineralsByDestroyedMass = getMineralsByDestroyedMass; _minChildAsteroidRadius = minChildAsteroidRadius; _mineralTypesByValue = ((MineralType[])Enum.GetValues(typeof(MineralType))). Select(o => new { Type = o, Value = ItemOptionsAstMin2D.GetCredits_Mineral(o) }). OrderBy(o => o.Value). Select(o => o.Type). ToArray(); }
private static ChangeInstruction[] ExamineMinerals(IEnumerable <MapObjectInfo> allItems, Boundry boundry, MineralType[] mineralTypesByValue) { var minerals = allItems. Where(o => o.MapObject is Mineral). ToArray(); //TODO: Add minerals if too few if (minerals.Length > MAX_MINERALS) { #region Remove // Figure out how many to remove int count = minerals.Length - MAX_MINERALS; if (count > MAXCHANGES) { count = MAXCHANGES; } return(ExamineMinerals_Remove1(minerals, count)); #endregion } else { return(null); } }
/// <summary> /// This creates random size in random location /// TODO: Look at existing sizes more carefully to see what size to create /// TODO: Don't create something near the player - take a list of spheres to avoid (or maybe cubes) /// TODO: Have certain features of the map be sources - maybe a couple hidden moving sources that slowly move around the edge of the map /// TODO: When creating asteroids, create a small stream of them /// </summary> private static ChangeInstruction[] ExamineAsteroids_Add1(int count, Boundry boundry) { ChangeInstruction[] retVal = new ChangeInstruction[count]; for (int cntr = 0; cntr < count; cntr++) { //asteroidSize = 4 + (rand.NextDouble() * 6); // medium //asteroidSize = 9 + (rand.NextDouble() * 10); // large double asteroidSize = 4 + StaticRandom.NextDouble(16); Point3D position = Math3D.GetRandomVector(boundry.Outer_Min, boundry.Outer_Max, boundry.Inner_Min, boundry.Inner_Max).ToPoint(); Vector3D velocity = Math3D.GetRandomVector_Circular(6d); Vector3D angVel = Math3D.GetRandomVector_Spherical(1d); AsteroidDNA asteroid = new AsteroidDNA() { PartType = Asteroid.PARTTYPE, Radius = asteroidSize, Position = position, //NOTE: These are duplication and aren't used, but storing them anyway Velocity = velocity, AngularVelocity = angVel, }; retVal[cntr] = new ChangeInstruction(position, velocity, angVel, asteroid); } return retVal; }
private static ChangeInstruction[] ExamineMinerals(IEnumerable<MapObjectInfo> allItems, Boundry boundry, MineralType[] mineralTypesByValue) { var minerals = allItems. Where(o => o.MapObject is Mineral). ToArray(); //TODO: Add minerals if too few if (minerals.Length > MAX_MINERALS) { #region Remove // Figure out how many to remove int count = minerals.Length - MAX_MINERALS; if (count > MAXCHANGES) { count = MAXCHANGES; } return ExamineMinerals_Remove1(minerals, count); #endregion } else { return null; } }
// method for only one gameobject IEnumerator RandomObjectSpawner(GameObject objectToSpawn, Boundry objectsPosition, float objectSpawnTime) { while (IsPlayerAlive) // spawn objects all the time { yield return new WaitForSeconds(objectSpawnTime); Vector3 randPosition = new Vector3(Random.Range(-objectsPosition.left, objectsPosition.right), 0, objectsPosition.up); // choose random object position GameObject newObject = Instantiate(objectToSpawn, randPosition, Quaternion.identity) as GameObject; // create new object objectsList.Add(newObject.transform); // add object to list newObject.transform.SetParent(hierarchyGuard); // parent Enemy to hierarchyGuard } }
IEnumerator RandomEnemiesSpawner(GameObject[] objectsToSpawn, Boundry objectsPosition, float objectSpawnTime) { while (IsPlayerAlive) // spawn objects all the time { yield return new WaitForSeconds(objectSpawnTime); GameObject randObject = objectsToSpawn[Random.Range(0, objectsToSpawn.Length)]; // choose random object Vector3 randPosition = new Vector3(Random.Range(-objectsPosition.left, objectsPosition.right), 0, objectsPosition.up); // choose random object position GameObject newObject = Instantiate(randObject, randPosition, Quaternion.identity) as GameObject; // create new object objectsList.Add(newObject.transform); // add object to list newObject.transform.SetParent(hierarchyGuard); // parent Enemy to hierarchyGuard if (!isEnemyShooting) // if flag means that enemy shouldn't shoot newObject.GetComponent<EnemyController>().SetShooting(false); // enemy after spawn won't be eable to shoot } }
void Start() { if (!spawnObjects) return; // if there is no spawnObjets, do nothing boundryMap = GameMaster.instance.boundry; CreateObjectOnStart(2); // create objets that will appeare on screen from begining StartCoroutine(SpawnObjectUpdate()); // start loop that create objects on background }
private static ChangeInstruction[] ExamineAsteroids(IEnumerable<MapObjectInfo> allItems, Boundry boundry) { var asteroids = allItems. Where(o => o.MapObject is Asteroid). ToArray(); if (asteroids.Length < MIN_ASTEROIDS) { #region Add // Figure out how many to add int count = MIN_ASTEROIDS - asteroids.Length; if (count < MAXCHANGES) { count = StaticRandom.Next(count, MAXCHANGES + 1); } else if (count > MAXCHANGES) { count = MAXCHANGES; } // Define new asteroids return ExamineAsteroids_Add1(count, boundry); #endregion } else if (asteroids.Length > MAX_ASTEROIDS) { #region Remove // Figure out how many to remove int count = asteroids.Length - MAX_ASTEROIDS; if (count > MAXCHANGES) { count = MAXCHANGES; } return ExamineAsteroids_Remove1(asteroids, count); #endregion } else { return null; } }
public void Pulsate(TouchPoint point, Boundry boundry) { Start(true, null, point, boundry); }
private static ChangeInstruction[] ExamineAsteroids(IEnumerable <MapObjectInfo> allItems, Boundry boundry) { var asteroids = allItems. Where(o => o.MapObject is Asteroid). ToArray(); if (asteroids.Length < MIN_ASTEROIDS) { #region Add // Figure out how many to add int count = MIN_ASTEROIDS - asteroids.Length; if (count < MAXCHANGES) { count = StaticRandom.Next(count, MAXCHANGES + 1); } else if (count > MAXCHANGES) { count = MAXCHANGES; } // Define new asteroids return(ExamineAsteroids_Add1(count, boundry)); #endregion } else if (asteroids.Length > MAX_ASTEROIDS) { #region Remove // Figure out how many to remove int count = asteroids.Length - MAX_ASTEROIDS; if (count > MAXCHANGES) { count = MAXCHANGES; } return(ExamineAsteroids_Remove1(asteroids, count)); #endregion } else { return(null); } }
private void filterVar_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (((ComboBox)sender).SelectedValue == null) { DataHelper.FilterSelectedBoundry = -1; } object tag = ((ComboBox)sender).Tag; List <string> values = new List <string>(); string variableColumnName = ""; if (((ComboBox)sender).SelectedValue is string) { if (((string)((ComboBox)sender).SelectedValue) == "") { if (((Dictionary <string, ComboBox>)((ComboBox)sender).Tag).ContainsKey("combine")) { ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["combine"]).SelectedItem = null; } ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["op"]).SelectedItem = null; ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["val"]).SelectedItem = null; return; } variableColumnName = (string)((ComboBox)sender).SelectedValue; int boundryAggregate; if (int.TryParse(variableColumnName, out boundryAggregate)) { Boundry boundry = null; if (DataHelper.BoundaryAggregation.TryGetValue(boundryAggregate, out boundry)) { variableColumnName = boundry.ColumnName; } } else { Dictionary <string, string> objectColumnName = new Dictionary <string, string>(); objectColumnName.Add("ContactVM.Team", "Team"); objectColumnName.Add("ContactVM.HCWFacility", "ContactHCWFacility"); variableColumnName = objectColumnName[variableColumnName]; } } values = DataHelper.ColumnValues(variableColumnName); if (tag is Dictionary <string, ComboBox> ) { ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["val"]).ItemsSource = null; ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["val"]).ItemsSource = values; if (((Dictionary <string, ComboBox>)((ComboBox)sender).Tag).ContainsKey("op")) { if (((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["op"]).SelectedItem == null) { ComboBox op = ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["op"]); op.SelectedIndex = 1; } } if (((Dictionary <string, ComboBox>)((ComboBox)sender).Tag).ContainsKey("combine")) { if (((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["combine"]).SelectedItem == null) { ComboBox combine = ((ComboBox)((Dictionary <string, ComboBox>)((ComboBox)sender).Tag)["combine"]); combine.SelectedIndex = 1; } } } }
public MapPopulationManager(Map map, World world, Point3D boundryMin, Point3D boundryMax, int material_Asteroid, int material_Mineral, Func<double, ITriangleIndexed[], double> getAsteroidMassByRadius, Func<double, MineralDNA[]> getMineralsByDestroyedMass, double minChildAsteroidRadius) { _map = map; _world = world; _boundry = new Boundry(boundryMin, boundryMax); _material_Asteroid = material_Asteroid; _material_Mineral = material_Mineral; _getAsteroidMassByRadius = getAsteroidMassByRadius; _getMineralsByDestroyedMass = getMineralsByDestroyedMass; _minChildAsteroidRadius = minChildAsteroidRadius; _mineralTypesByValue = ((MineralType[])Enum.GetValues(typeof(MineralType))). Select(o => new { Type = o, Value = ItemOptionsAstMin2D.GetCredits_Mineral(o) }). OrderBy(o => o.Value). Select(o => o.Type). ToArray(); }