void genEnemy(MiniGameController.minigameType type) { float x = Random.Range(-3.5f * windowW / 10, 3.5f * windowW / 10); float y = Random.Range(-3.5f * windowH / 10, 3.5f * windowH / 10); GameObject thisEnemy = Instantiate(enemy); thisEnemy.transform.SetParent(panelParent.transform, false); thisEnemy.transform.localPosition = new Vector3(x, 6 * windowH / 10, 0); thisEnemy.transform.localScale = new Vector3(200, 200, 1); if (type == MiniGameController.minigameType.Asteroids || type == MiniGameController.minigameType.Jump) { float difficulty = -.14f; Rigidbody2D body = thisEnemy.GetComponent <Rigidbody2D> (); body.mass = 0; body.angularDrag = 0; body.gravityScale = 0; body.AddForce(new Vector2(difficulty, 0), ForceMode2D.Force); thisEnemy.transform.localPosition = new Vector3(6 * windowW / 10, y, 0); thisEnemy.transform.localScale = new Vector3(900, 900, 1); } }
public void setType(MiniGameController.minigameType type) { this.type = type; }
public void init(MiniGameController controllerPrime, MiniGameController.minigameType type) { this.controllerPrime = controllerPrime; setType(type); }