Sprite RandomSpriteByType(BadStuff.BadType Type) { switch (Type) { case global::BadStuff.BadType.Small: return(BadSpritesSmall[Random.Range(0, BadSpritesSmall.Length)]); break; case global::BadStuff.BadType.Medium: return(BadSpritesMedium[Random.Range(0, BadSpritesMedium.Length)]); break; case global::BadStuff.BadType.Big: return(BadSpritesBig[Random.Range(0, BadSpritesBig.Length)]); break; case global::BadStuff.BadType.Boss: return(BadSpritesBoss[Random.Range(0, BadSpritesBoss.Length)]); break; } return(null); }
GameObject GenerateRandomBadStuff(int line, BadStuff.BadType Type) { Sprite testSprite = RandomSpriteByType(Type); Vector2 Line = new Vector2((lineWidth + lineOffset) * line, HeightToSpawn); Vector2 SpriteSize = new Vector2(testSprite.rect.width / testSprite.pixelsPerUnit, testSprite.rect.height / testSprite.pixelsPerUnit); GameObject test = Instantiate(BaseStuffObject, Line - RandomOffset(SpriteSize, new Vector2(1, 1)), Quaternion.identity); test.GetComponent <SpriteRenderer>().sprite = testSprite; goDown sc = test.AddComponent <goDown>(); sc.moveSpeed = 2; bubbleButtMenu bb = test.AddComponent <bubbleButtMenu>(); bb.BubbleSize = (bubbleButtMenu.Size)ToLimit(((int)Type) + 1, 1, 3); bb.SpriteWidth = SpriteSize.x; test.SetActive(false); return(test); }
GameObject GenerateRandomBadStuff(int line, BadStuff.BadType Type) { Sprite testSprite = RandomSpriteByType(Type); Vector2 SpriteSize = new Vector2(testSprite.rect.width / testSprite.pixelsPerUnit, testSprite.rect.height / testSprite.pixelsPerUnit); GameObject test = Instantiate(BaseObj, SpawnCoordsByLine(line) - RandomOffset(SpriteSize, new Vector2(1, 1)), Quaternion.identity); test.GetComponent <SpriteRenderer>().sprite = testSprite; bubbleButt bb = test.AddComponent <bubbleButt>(); bb.BubbleSize = (bubbleButt.Size)SupportM.ToLimit(((int)Type) + 1, 1, 3); bb.SpawnMode = bubbleButt.Mode.Always; bb.SpriteWidth = SpriteSize.x; test.name = "BadStuff"; test.tag = "Stuff"; BadStuff temp; temp = test.AddComponent <BadStuff>(); temp.BadInfo = this.BadInfo; temp.badType = Type; test.GetComponent <BoxCollider2D>().size = SpriteSize; test.SetActive(false); return(test); }
GameObject GenerateRandomBadStuff(int line) { BadStuff.BadType Type = (BadStuff.BadType)Random.Range(0, 3); return(GenerateRandomBadStuff(line, Type)); }