public Asteroid(Asteroid copy) : base(copy.CurrentLocation) { _size = copy._size; RandomVelocity(); InitPoints(); }
public void CreateAsteroid(AsteroidSize asteroidSize, Vector2 position, Vector2 parentVelocity) { GameObject asteroidToInstantiate = asteroidPrefabs[Random.Range(0, asteroidPrefabs.Length)]; GameObject go = Instantiate(asteroidToInstantiate, position, Quaternion.Euler(0, 0, Random.Range(0f, 360f))); if (asteroidSize == AsteroidSize.Medium) { go.transform.localScale = go.transform.localScale / 2; } else if (asteroidSize == AsteroidSize.Small) { go.transform.localScale = go.transform.localScale / 3; } //Setting asteroid as a child is an alternative for storing them in List or using Find function in future to delete all exisiting instances go.transform.SetParent(transform); Rigidbody2D asteroidRigidbody = go.GetComponent <Rigidbody2D>(); if (asteroidRigidbody == null) { Debug.Log("asteroid's rigibody == null"); Destroy(go); return; } go.GetComponent <AsteroidLogic>().AsteroidSize = asteroidSize; asteroidRigidbody.velocity = Random.Range(0.8f, 1.2f) * parentVelocity; asteroidRigidbody.AddForce(go.transform.right * Random.Range(-1f, 1f), ForceMode2D.Impulse); asteroidRigidbody.AddTorque(Random.Range(-1f, 1f) * GameManager.instance.AsteroidMaxTurnSpeed, ForceMode2D.Impulse); }
public void Initialize(AsteroidSize size) { int index; switch (size) { case AsteroidSize.Small: index = Random.Range(0, SmallSprites.Length); GetComponent<SpriteRenderer>().sprite = SmallSprites[index]; GetComponent<Rigidbody2D>().mass = Random.Range(SmallMinWeight, SmallMaxWeight); GetComponent<CircleCollider2D>().radius = SmallColRadius; break; case AsteroidSize.Medium: index = Random.Range(0, MediumSprites.Length); GetComponent<SpriteRenderer>().sprite = MediumSprites[index]; GetComponent<Rigidbody2D>().mass = Random.Range(MediumMinWeight, MediumMaxWeight); GetComponent<CircleCollider2D>().radius = MediumColRadius; break; case AsteroidSize.Large: index = Random.Range(0, LargeSprites.Length); GetComponent<SpriteRenderer>().sprite = LargeSprites[index]; GetComponent<Rigidbody2D>().mass = Random.Range(LargeMinWeight, LargeMaxWeight); GetComponent<CircleCollider2D>().radius = LargeColRadius; break; default: throw new System.Exception("Invalid asteroid size"); break; } }
public AsteroidComponent(Game game, AsteroidSize size, float direction, Vector2 position) : base(game) { this.size = size; base.direction = direction; base.position = position; }
public void Breakdown(Collision2D coll) { // Reduce size if(Size == AsteroidSize.Small) { gameObject.SetActive(false); Destroy(gameObject); return; } Size = Size - 1; Initialize(Size); // Make asteroid move in the opposite direction of the collision Vector2 dir = Vector2.zero; if(coll != null) { dir = transform.position; dir -= coll.contacts[0].point; dir.Normalize(); } else { dir = new Vector2(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f)); dir.Normalize(); } GetComponent<Rigidbody2D>().velocity = dir * BreakdownVelocity; }
private void CreateAsteroid(Entity oldAsteroid, AsteroidSize size, Vector2 vec) { var newAsteroid = _pool.CreateAsteroid(oldAsteroid.position.x + vec.x, oldAsteroid.position.y + vec.y, size); ImpartInitialForce(oldAsteroid, newAsteroid, vec); }
public Entity CreateAsteroid(AsteroidSize size, Vector3 pos) { var asteroid = LoadPrefabEntity("Prefabs/Asteroid " + size, "asteroid"); asteroid.transform.position = pos; return(asteroid); }
Asteroid CreateAsteroid(AsteroidSize size) { GameObject go = null; switch (size) { case AsteroidSize.big: go = Instantiate(prefab_big[Random.Range(0, prefab_big.Length)], transform); break; case AsteroidSize.medium: go = Instantiate(prefab_med[Random.Range(0, prefab_med.Length)], transform); break; case AsteroidSize.small: go = Instantiate(prefab_small[Random.Range(0, prefab_small.Length)], transform); break; case AsteroidSize.tiny: go = Instantiate(prefab_tiny[Random.Range(0, prefab_tiny.Length)], transform); break; } var shot = new Asteroid(go, size); activeList.Add(shot); return(shot); }
public void Init(AsteroidSize size, Vector3 target, bool fromBreak, float normalizedExtraScreen) { breakPartner = null; currentSize = size; mRigidbody.velocity = Vector3.zero; mRigidbody.rotation = Quaternion.identity; this.normalizedExtraScreen = normalizedExtraScreen; transform.rotation = Quaternion.identity; rotateDirection = Random.insideUnitCircle.normalized; ApplySize(); if (!fromBreak) { Vector3 targetOffseted = target + new Vector3(Random.Range(-offsetDirection, offsetDirection), 0, Random.Range(-offsetDirection, offsetDirection)); targetDir = targetOffseted - transform.position; } else { targetDir = target; } ready = true; gameObject.SetActive(true); }
public void HandleChildAsteroid(AsteroidTypes asteroidType, AsteroidSize asteroidSize, Vector3 startPosition) { var childAsteroid = asteroidSize == AsteroidSize.Large ? AsteroidSize.Medium : AsteroidSize.Small; GenerateChildAsteroid(asteroidType, childAsteroid, startPosition); GenerateChildAsteroid(asteroidType, childAsteroid, startPosition); }
public void Setup(Vector2 position, AsteroidSize size, Sprite newSprite) { transform.position = position; SetSize (size); MovementController.RendererBehaviour.TryChangeSprite (newSprite); }
/// <summary> /// Creates an asteroid /// </summary> /// <param name="size">Size of the asteroid</param> /// <param name="verts">Vertices defining the shape of the asteroid</param> /// <param name="indices">Indices defining the shape of the asteroid</param> /// <param name="pos">Initial position of the asteroid</param> /// <param name="rot">Initial rotation of the asteroid (in radians)</param> /// <param name="dir">Initial direction of the asteroid</param> /// <param name="linSpeed">Linear speed of the asteroid</param> /// <param name="scale">Scale to apply to the vertices</param> public Asteroid(AsteroidSize size, Shape s, Vector2 pos, float rot, Vector2 dir, float linSpeed, float scale) : base(s, rot, dir, scale) { Position = pos; Size = size; LinSpeed = linSpeed; }
public void Setup(Vector2 position, AsteroidSize size, Sprite newSprite) { transform.position = position; SetSize(size); MovementController.RendererBehaviour.TryChangeSprite(newSprite); }
public Asteroid(int x, int y, int direction, Color colour, AsteroidSize size) : base(x, y, direction, colour) { _size = size; _xVel = 2; _yVel = 2; _active = true; }
public static void CheckAsteroids(Asteroid origin, AsteroidSize size) { Instance.m_asteroidsSpawner.TrySpawnInPieces(origin, size); if (Instance.m_asteroidsSpawner.CheckAllDestroyed()) { Instance.NextLevel(); } }
public void Initialize(Vector3 position, float speed, Vector2 heading, AsteroidSize size, int type, AsteroidSpawner asteroidSpawner) { transform.position = position; Heading = heading; Size = size; Type = type; this.speed = speed; this.asteroidSpawner = asteroidSpawner; }
public Asteroid(Texture2D image, Vector2 position, float rotationAngle, AsteroidSize size) : base(image, position) { this.rotationAngle = rotationAngle; velocity.X = (float)(Math.Sin((double)rotationAngle) * ASTEROIDS_SPEED); velocity.Y = (float)(Math.Cos((double)rotationAngle) * ASTEROIDS_SPEED); this.size = size; this.isSlow = false; IsUIObserver = false; }
public void Spawn(Vector2 pos, AsteroidSize size) { Asteroid asteroid = Instantiate(asteroidPrefab, pos, Quaternion.identity).GetComponent <Asteroid>(); asteroid.size = size; asteroid.transform.localScale = Vector3.one * GetScaleFromSize(size); asteroid.GetComponent <Rigidbody2D>().AddForce(Random.insideUnitCircle.normalized * 50f); asteroid.GetComponent <Rigidbody2D>().AddTorque(3); }
public void Spawn(Vector2 pos, Vector2 dir, AsteroidSize size) { Asteroid asteroid = Instantiate(asteroidPrefab, pos, Quaternion.identity).GetComponent <Asteroid>(); asteroid.size = size; asteroid.transform.localScale = Vector3.one * GetScaleFromSize(size); asteroid.GetComponent <Rigidbody2D>().AddForce(dir); asteroid.GetComponent <Rigidbody2D>().AddTorque(3); }
public Asteroid(AsteroidSize size) : base(new Point(0, 0)) { _size = size; CurrentLocation.X = RndGen.Next(2) * 9999; CurrentLocation.Y = RndGen.Next(7499); RandomVelocity(); InitPoints(); }
IEnumerator AttackersAssigner() { while (true) { if (Random.value > 0.75f) { shipAI.Sort((x, y) => (x.transform.position - Ship.PLAYER.transform.position).magnitude.CompareTo((y.transform.position - Ship.PLAYER.transform.position).magnitude)); } currAttackers = 0; for (int i = 0; i < shipAI.Count; i++) { var sh = shipAI[i]; if (sh.isPlayer || sh.health <= 0) { sh.isAttacker = false; continue; } if (currAttackers < maxAttackers) { currAttackers++; sh.isAttacker = true; } else { sh.isAttacker = false; } yield return(0); } Vector3 circle = Random.insideUnitCircle.normalized; AsteroidSize size = AsteroidSize.big; float rng = Random.value; if (rng > 0.25f) { size = AsteroidSize.tiny; } if (rng > 0.50f) { size = AsteroidSize.small; } if (rng > 0.75f) { size = AsteroidSize.medium; } if (Ship.PLAYER != null) { AsteroidSystem.current.SpawnAsteroid(Ship.PLAYER.transform.position + circle * 40f, size, true); } yield return(new WaitForSeconds(1f)); } }
/// <summary> /// Creates the asteroid. /// </summary> /// <returns>The asteroid.</returns> /// <param name="size">Size.</param> /// <param name="pos">Position.</param> public Entity CreateAsteroid(AsteroidSize size, Vector3 pos) { var prefab = prefabs.GetAsteroid(size); var asteroid = Instantiate(prefab); asteroid.transform.position = pos; asteroid.GetComponent <Hitpoints>().ResetToStart(); return(asteroid); }
public static Entity CreateAsteroid(this Pool pool, float x, float y, AsteroidSize size) { return pool.CreateEntity() .AddAsteroid(size) .AddPosition(x, y) .AddHitpoints(1) .AddCollisionRadius(AsteroidData.Radii[size]) .IsWrappedAroundGameBounds(true) .AddResource("Prefabs/" + AsteroidData.Resources[size]); }
public AsteroidSize ReduceSize() { if (_size != AsteroidSize.Dne) { _size -= (int)AsteroidSize.Small; } InitPoints(); RandomVelocity(); return(_size); }
/// <summary> /// Basic setup asteroid object /// Sets size of asteroid, set sprite, generate direction and add force /// </summary> /// <param name="size">Size of Asteroid</param> public void Init(AsteroidSize size) { // set size asteroidSize = size; // set spite spriteRenderer.sprite = mainScript.AsteroidSizeToSprite[size][ Random.Range(0, mainScript.AsteroidSizeToSprite[size].Length)]; gameObject.name = "Asteroid"; }
//Overload, in case I need to create an asteroid of a specific size public void NewAsteroid(int num, AsteroidSize size) { for (int i = 0; i < num; i++) { int x = -100; int y = -100; int dir = _random.Next(359); _asteroids.Add(new Asteroid(x, y, dir, Color.White, size)); } }
public Asteroid(Texture2D spriteStrip, AsteroidSize size, Vector2 position, Vector2 velocity, SoundEffect bounceSound) { _spriteStrip = spriteStrip; _velocity = velocity; _bounceSound = bounceSound; _size = size; _isActive = true; SetHealthBySize(); SetRectangles(position); }
public static Entity CreateAsteroid(this Pool pool, float x, float y, AsteroidSize size) { return(pool.CreateEntity() .AddAsteroid(size) .AddPosition(x, y) .AddHitpoints(1) .AddCollisionRadius(AsteroidData.Radii[size]) .IsWrappedAroundGameBounds(true) .AddResource("Prefabs/" + AsteroidData.Resources[size])); }
Asteroid GetAsteroid(AsteroidSize size) { if (inactiveDict[size].Count > 0) { return(inactiveDict[size][0]); } else { return(null); } }
internal void StartBelt(int numAsteroids, AsteroidSize minSize) { var rndGen = new Random(); _asteroids = new List <Asteroid>(numAsteroids); for (var i = 0; i < numAsteroids; i++) { var size = (AsteroidSize)3 - rndGen.Next(3 - (int)minSize + 1); _asteroids.Add(new Asteroid(size)); } }
public static AsteroidSize GetNextSizeDown(AsteroidSize size) { if (size == AsteroidSize.Large) return AsteroidSize.Medium; if (size == AsteroidSize.Medium) return AsteroidSize.Small; if (size == AsteroidSize.Small) return AsteroidSize.Tiny; throw new Exception("Nothing smaller!"); }
/// <summary> /// Creates a new instance of <see cref="Asteroid"/>. /// </summary> /// <param name="size">Initial <see cref="AsteroidSize"/>.</param> public Asteroid(AsteroidSize size) : base(new Point(0, 0)) { Size = size; // Can't place the object randomly in constructor - stinky CurrLoc.X = RandomizeHelper.Random.Next(2) * (ScreenCanvas.CanvasWidth - 1); CurrLoc.Y = RandomizeHelper.Random.Next(ScreenCanvas.CanvasHeight - 1); RandomVelocity(); InitPoints(); }
/// <summary> /// Gets the force multiplier. /// </summary> /// <returns>The force multiplier.</returns> /// <param name="size">Size.</param> private float GetForceMultiplier(AsteroidSize size) { if (size == AsteroidSize.Small) { return(0.2f); } else { return(0.5f); } }
/// <summary> /// Gets the size of the split. /// </summary> /// <returns>The split size.</returns> /// <param name="size">Size.</param> private AsteroidSize GetSplitSize(AsteroidSize size) { if (size == AsteroidSize.Medium) { return(AsteroidSize.Small); } else { return(AsteroidSize.Medium); } }
/// <summary> /// Creates the child asteroid. /// </summary> /// <param name="dir">Dir.</param> /// <param name="asteroidPos">Asteroid position.</param> /// <param name="newSize">New size.</param> private void CreateChildAsteroid(Vector2 dir, Vector2 asteroidPos, AsteroidSize newSize) { var pos = new Vector3(asteroidPos.x + dir.x, asteroidPos.y + dir.y); var a = _creator.CreateAsteroid(newSize, pos); var multiplier = GetForceMultiplier(newSize); var rb = a.GetComponent <Rigidbody2D>(); var force = new Vector2(dir.x, dir.y) * multiplier; rb.AddForce(force, ForceMode2D.Impulse); rb.AddTorque(force.x * multiplier * multiplier, ForceMode2D.Impulse); }
/// <summary> /// Reduce the size by one level. /// </summary> /// <returns>The new reduce size.</returns> public AsteroidSize ReduceSize() { if (Size != AsteroidSize.Dne) { Size -= 1; } InitPoints(); RandomVelocity(); return(Size); }
public Asteroid(Texture2D image, Vector2 position, AsteroidSize size) : base(image, position) { this.size = size; if (size == AsteroidSize.BIG) { asteroids[0] = new Asteroid(image, position, AsteroidSize.MEDIUM); asteroids[1] = new Asteroid(image, position, AsteroidSize.MEDIUM); } else if (size == AsteroidSize.MEDIUM) { asteroids[0] = new Asteroid(image, position, AsteroidSize.SMALL); asteroids[1] = new Asteroid(image, position, AsteroidSize.SMALL); } }
public Asteroid(Texture2D texture, AsteroidSize size, Vector2 position) { Texture = texture; Rotation = 0; Direction = new Vector2((float)Math.Cos(RandomGenerator.Get.Next(-100, 100)), (float)Math.Sin(RandomGenerator.Get.Next(-100, 100))); if (position == Vector2.Zero) { Position = new Vector2(RandomGenerator.Get.Next(0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width), RandomGenerator.Get.Next(0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height)); } else { Position = position; } Direction.Normalize(); switch (size) { case AsteroidSize.Small: { Size = 1; break; } case AsteroidSize.Medium: { Size = 3; break; } case AsteroidSize.Large: { Size = 5; break; } } Speed = (RandomGenerator.Get.Next(10, 1000) * 0.01f) / Size; RotationSpeed = RandomGenerator.Get.Next(-100, 100) * 0.002f / Size; CalculateMass(); }
public AsteroidModel(Model m, Random random, Vector3 direction, AsteroidSize size) : base(m) { this.random = random; // Initialize random rotation speed randomRotation = new Vector3( (float)random.NextDouble() * maxRotationSpeed - (maxRotationSpeed / 2), (float)random.NextDouble() * maxRotationSpeed - (maxRotationSpeed / 2), (float)random.NextDouble() * maxRotationSpeed - (maxRotationSpeed / 2)); this.size = size; // Initialize random scale if (size == AsteroidSize.LARGE) { scale = new Vector3(((float)random.NextDouble() * .005f) + .035f, ((float)random.NextDouble() * .005f) + .035f, ((float)random.NextDouble() * .005f) + .035f); } else if (size == AsteroidSize.MEDIUM) { scale = new Vector3(((float)random.NextDouble() * .005f) + .015f, ((float)random.NextDouble() * .005f) + .015f, ((float)random.NextDouble() * .005f) + .015f); } else { scale = new Vector3(((float)random.NextDouble() * .005f) + .005f, ((float)random.NextDouble() * .005f) + .005f, ((float)random.NextDouble() * .005f) + .005f); } // Initialize random speed this.direction = direction * ((float)random.NextDouble() + 1f); position = new Vector3(-300, ((float)random.NextDouble() * 100) - 50, 0); }
public Asteroid(InGameState Game, Vector2 StartPosition, AsteroidSize size) : base(Game, new LineModel(AsteroidLarge1Vectors), StartPosition) { this.size = size; Velocity = Vector2.RandomVector2(new Vector2(-50, -50), new Vector2(50, 50)).Normalise() * 2; switch (size) { case AsteroidSize.Large: this.Model.Scale = 1; break; case AsteroidSize.Medium: this.Model.Scale = 0.5; break; case AsteroidSize.Small: this.Model.Scale = 0.35; break; } hitbox = new CircleHitbox(this, Model.GetRadius()); }
public Asteroid(InGameState Game, Vector2 StartPosition, Vector2 velocity, AsteroidSize size) : base(Game, new LineModel(AsteroidLarge1Vectors), StartPosition) { this.size = size; Velocity = velocity; switch (size) { case AsteroidSize.Large: this.Model.Scale = 1; break; case AsteroidSize.Medium: this.Model.Scale = 0.5; break; case AsteroidSize.Small: this.Model.Scale = 0.35; break; } hitbox = new CircleHitbox(this, Model.GetRadius()); }
void SetCharacteristics(bool setRandomNewSize) { myCollider.enabled =true; myRenderer.enabled =true; myRenderer.color = startColor; coloringSpeed = Mathf.Abs (coloringSpeed); rotateSpeed = Random.Range (-180, 180); pushDirection = Random.insideUnitCircle; force = Random.Range (minRange, maxRange); myRigidbody.AddForce (pushDirection * force); //brightnessLevel = Random.Range (100, 255); //brightnessLevel /= 255; //myRenderer.color = new Color (brightnessLevel, brightnessLevel, brightnessLevel); if(setRandomNewSize) asteroidSize = allSizes[Random.Range(0, allSizes.Length)]; if(asteroidSize == AsteroidSize.Large) { transform.localScale = new Vector2 (3, 3); myRigidbody.mass = startingMass * 3; //should be squared, but I double so largest asteroids don't kill you outright health = startingHealth * 3; //again, should be squared, but for pity's sake... it's not } else if(asteroidSize == AsteroidSize.Medium) { transform.localScale = new Vector2 (2, 2); myRigidbody.mass = startingMass * 2; health = startingHealth * 2; } else if(asteroidSize == AsteroidSize.Small) { transform.localScale = new Vector2 (1, 1); myRigidbody.mass = startingMass; health = startingHealth; } }
void SpawnGibs(AsteroidSize whichSize, int numberOfGibs) { for (int i = 0; i < numberOfGibs; i++) { Vector3 spawnPosition = transform.position; GameObject obj = asteroidPoolerScript.current.GetPooledObject (); obj.transform.position = spawnPosition; obj.SetActive (true); obj.GetComponent<Asteroid> ().asteroidSize = whichSize; obj.GetComponent<Asteroid> ().SetCharacteristics(false); obj.GetComponent<Asteroid>().myAsteroidSpawner = this.myAsteroidSpawner; myAsteroidSpawner.asteroidCount ++; } }
public AsteroidModel(Model m, Random random, Vector3 direction, AsteroidSize size, Vector3 position) : this(m, random, direction, size) { this.position = position; }
public Entity CreateAsteroid(AsteroidSize size, Vector3 pos) { var asteroid = LoadPrefabEntity("Prefabs/Asteroid "+size, "asteroid"); asteroid.transform.position = pos; return asteroid; }
/// <summary> /// transforms bigger asteroids into smaller asteroids /// </summary> /// <param name="size">The size.</param> /// <param name="bulletRotationAngle">The bullet rotation angle.</param> private void AddSmallerAsteroid(AsteroidSize size, float bulletRotationAngle) { float newRotationAngle = (float)((Math.PI * 2) / 3); Asteroid newAst1; Asteroid newAst2; LevelManager.GetInstance().DeadAsteroids.Add(this); if (size == AsteroidSize.medium) { newAst1 = new Asteroid(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\asteroid_medium"), this.position, bulletRotationAngle + newRotationAngle, size); newAst2 = new Asteroid(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\asteroid_medium"), this.position, bulletRotationAngle - newRotationAngle, size); } else { newAst1 = new Asteroid(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\asteroid_small"), this.position, bulletRotationAngle + newRotationAngle, size); newAst2 = new Asteroid(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\asteroid_small"), this.position, bulletRotationAngle - newRotationAngle, size); } LevelManager.GetInstance().Asteroids.Add(newAst1); LevelManager.GetInstance().Asteroids.Add(newAst2); }
//This funtions is called whenever we want to Instantiate a smaller asteroid when a larger asteroid is destroyed. //It takes three arguments 1)The asteroid Type 2)its size void InstantiateAsteroid(AsteroidType AsType, AsteroidSize AsSize) { ///<summary> /// What you are doing here is that you are basically checking is there any collider2D within the radius calculated as the maximum of the /// (x,y) of the collider attached to the current gameObject(asteroid) + some arbitrary value. Around the point of the current /// random position generated above i.e pos. So if there is no Colider2D in this radius that means we have an empty spot where we can /// succesfully spawn a asteroid prefab. /// </summary> float arbValue = (AsSize == AsteroidSize.HUGE || AsSize == AsteroidSize.MEDIUM) ? 0.5F : 0.3F; if (!Physics2D.OverlapCircle (new Vector2 (pos.x, pos.y), Mathf.Max (gameObject.GetComponent<Collider2D> ().bounds.size.x, gameObject.GetComponent<Collider2D> ().bounds.size.y) + arbValue)) { //If the asteroid type to which it is attached to is of brown type if (AsType == AsteroidType.BROWN) { //If the asteroid size is HUGE if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.brownMedium [Random.Range (0, astList.brownMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.brownSmall [Random.Range (0, astList.brownSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.brownTiny [Random.Range (0, astList.brownTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.GREY) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.greyMedium [Random.Range (0, astList.greyMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.greySmall [Random.Range (0, astList.greySmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.greyTiny [Random.Range (0, astList.greyTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.FERROUS) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.ferrousMedium [Random.Range (0, astList.ferrousMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.ferrousSmall [Random.Range (0, astList.ferrousSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.ferrousTiny [Random.Range (0, astList.ferrousTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.TIN) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.tinMedium [Random.Range (0, astList.tinMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.tinSmall [Random.Range (0, astList.tinSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.tinTiny [Random.Range (0, astList.tinTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.COBALT) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.cobaltMedium [Random.Range (0, astList.cobaltMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.cobaltSmall [Random.Range (0, astList.cobaltSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.cobaltTiny [Random.Range (0, astList.cobaltTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.INDIUM) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.indiumMedium [Random.Range (0, astList.indiumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.indiumSmall [Random.Range (0, astList.indiumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.indiumTiny [Random.Range (0, astList.indiumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.GOLD) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.goldMedium [Random.Range (0, astList.goldMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.goldSmall [Random.Range (0, astList.goldSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.goldTiny [Random.Range (0, astList.goldTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.YTTRIUM) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.yttriumMedium [Random.Range (0, astList.yttriumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.yttriumSmall [Random.Range (0, astList.yttriumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.yttriumTiny [Random.Range (0, astList.yttriumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.URANIUM) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.uraniumMedium [Random.Range (0, astList.uraniumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.uraniumSmall [Random.Range (0, astList.uraniumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.uraniumTiny [Random.Range (0, astList.uraniumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.REQUILIUM) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.requiliumMedium [Random.Range (0, astList.requiliumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.requiliumSmall [Random.Range (0, astList.requiliumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.requiliumTiny [Random.Range (0, astList.requiliumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } else if (AsType == AsteroidType.XERINIUM) { if (AsSize == AsteroidSize.HUGE) { Instantiate (astList.xeriniumMedium [Random.Range (0, astList.xeriniumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.MEDIUM) { Instantiate (astList.xeriniumSmall [Random.Range (0, astList.xeriniumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.SMALL) { Instantiate (astList.xeriniumTiny [Random.Range (0, astList.xeriniumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation); breakOut = true; } else if (AsSize == AsteroidSize.TINY) { //If its tiny just destroy it and do nothing. } } } }
private void SetSize(AsteroidSize size) { m_size = size; switch (m_size) { case AsteroidSize.Large: transform.localScale = Vector2.one * 2; break; case AsteroidSize.Medium: transform.localScale = Vector2.one * 1.5f; break; case AsteroidSize.Small: transform.localScale = Vector2.one; break; } }
public void Initialize() { Size = (AsteroidSize)Random.Range (0, System.Enum.GetNames(typeof(AsteroidSize)).Length); Initialize(Size); }
public Entity CreateAsteroid(AsteroidSize size, Transform at) { var asteroid = LoadNetworkEntity ("Prefabs/Asteroid "+size, "asteroid", at); //asteroid.transform.position = pos; return asteroid; }