// Update is called once per frame void FixedUpdate() { InputManage(); if (transform.position.x < AreaLimits.LeftLimit() + size_sprite) { if (transform.position.x < AreaLimits.LeftLimit() - size_sprite) { transform.position = new Vector3(AreaLimits.RightLimit() - size_sprite, transform.position.y); } } else if (transform.position.x > AreaLimits.RightLimit() - size_sprite) { if ((transform.position.x > AreaLimits.RightLimit() + size_sprite)) { transform.position = new Vector3(AreaLimits.LeftLimit() + size_sprite, transform.position.y); } } if (transform.position.y < AreaLimits.BottomLimit() - size_sprite) { transform.GetComponentInChildren <Animator> ().enabled = false; transform.GetComponentInChildren <SpriteRenderer> ().color = new Color(0, 0, 0); Camera.main.gameObject.GetComponent <SoundManager> ().MakeDeathFishSound(); Camera.main.gameObject.GetComponent <GameLogicManager> ().EndGame(true); } }
void FixedUpdate() { if (transform.position.y > AreaLimits.UpLimit() + 1F || transform.position.y < AreaLimits.BottomLimit() - 1F) { Destroy(gameObject); } }
// Use this for initialization void Start() { transform.position = new Vector3((AreaLimits.LeftLimit() + AreaLimits.RightLimit()) / 2, AreaLimits.BottomLimit() + 1f, 0); enabled = false; sprites = Resources.LoadAll("pipette-sprites-02"); nb_bullet = 0; nbBulletThrown = 0; }
// Use this for initialization void Start() { transform.position = new Vector3(AreaLimits.CenterX(), AreaLimits.CenterY() + 2, 0); rb = GetComponent <Rigidbody2D>(); is_jump = false; enabled = false; }
// Update is called once per frame void FixedUpdate() { rb.velocity = new Vector2(0, vitesse * Time.fixedDeltaTime); if (transform.position.y > AreaLimits.UpLimit() + 1F) { Destroy(gameObject); } }
// Update is called once per frame void FixedUpdate() { InputM(); if (transform.position.x + speed * Time.fixedDeltaTime > AreaLimits.LeftLimit() + size_sprite && transform.position.x + speed * Time.fixedDeltaTime < AreaLimits.RightLimit() - size_sprite) { transform.position = new Vector3(transform.position.x + speed * Time.fixedDeltaTime, transform.position.y); } else { speed = -(speed / 2); } }
void InitSpawn() { Vector3 pos = new Vector3(ConvertColumnToPos(AreaLimits.BlockColumnsCount() / 2), AreaLimits.UpLimit() + 1 + spawnTimer * downSpeed, 0); GameObject g; g = (GameObject)GameObject.Instantiate(Resources.Load("BlockLong")); g.transform.position = pos; g.transform.SetParent(transform); lastColumnSpawned = AreaLimits.BlockColumnsCount() / 2; lastSizeSpawned = 3; isLastEmpty = true; for (int i = 0; i < AreaLimits.SizeY() / 2; ++i) { UpdateGen(spawnInterval / downSpeed); } spawnTimer = spawnInterval / downSpeed; }
public void Damage(int dmg) { health -= dmg; if (health <= 0) { float rand = Random.value; if (rand < bonusBourrinWeight && transform.position.y - 1 > AreaLimits.BottomLimit()) { GameObject g = (GameObject)GameObject.Instantiate(Resources.Load("BonusBourrin")); g.transform.position = transform.position; } else if (rand < (bonusBourrinWeight + bonusCannonWeight) && transform.position.y - 1 > AreaLimits.BottomLimit()) { GameObject g = (GameObject)GameObject.Instantiate(Resources.Load("BonusCannon")); g.transform.position = transform.position; } GameObject.Destroy(gameObject); } else { linear_color(); } }
void UpdateGen(float deltaTime) { for (int i = 0; i < transform.childCount; ++i) { Transform t = transform.GetChild(i); if (t.position.y - 1 < AreaLimits.BottomLimit()) { t.GetComponent <Block> ().Damage(1); } t.position += Vector3.down * downSpeed * deltaTime; } if (spawnTimer <= 0) { downSpeed += downSpeedIncrement; spawnTimer += spawnInterval / downSpeed; float randEmptyLane = Random.value; if (randEmptyLane >= emptyLaneWeight || isLastEmpty) { isLastEmpty = false; int x = 0; Vector3 pos = new Vector3(0, AreaLimits.UpLimit() + 1 + spawnTimer * downSpeed, 0); float randBlock = Random.value; string chosenBlock; if (randBlock < BlockWeightShort) { //Bloc court couvrant bloc court : pas possible if (lastSizeSpawned == 1) { x = Random.Range(0, AreaLimits.BlockColumnsCount() - 1); if (x >= lastColumnSpawned) { ++x; } } else { x = Random.Range(0, AreaLimits.BlockColumnsCount()); } chosenBlock = "BlockShort"; lastSizeSpawned = 1; } else if (randBlock < BlockWeightShort + BlockWeightMedium) { //Bloc medium couvrant bloc medium : pas possible if (lastSizeSpawned == 2) { x = Random.Range(0, AreaLimits.BlockColumnsCount() - 2); if (x >= lastColumnSpawned) { ++x; } } else if (lastSizeSpawned == 1) { //Bloc medium couvrant bloc court : pas possible x = Random.Range(0, AreaLimits.BlockColumnsCount() - 3); if (x >= lastColumnSpawned - 1) { x += 2; } ; } else { x = Random.Range(0, AreaLimits.BlockColumnsCount() - 1); } pos.x += 0.5f; chosenBlock = "BlockMedium"; lastSizeSpawned = 2; } else { //Bloc long couvrant bloc long : pas possible if (lastSizeSpawned == 3) { x = Random.Range(0, AreaLimits.BlockColumnsCount() - 3); if (x >= lastColumnSpawned) { ++x; } } else if (lastSizeSpawned == 2) { //Bloc long couvrant bloc medium : pas possible x = Random.Range(0, AreaLimits.BlockColumnsCount() - 4); if (x >= lastColumnSpawned - 1) { x += 2; } ; } else if (lastSizeSpawned == 1) { //Bloc long couvrant bloc court : pas possible x = Random.Range(0, AreaLimits.BlockColumnsCount() - 5); if (x >= lastColumnSpawned - 2) { x += 3; } } else { x = Random.Range(0, AreaLimits.BlockColumnsCount() - 2); } pos.x += 1f; chosenBlock = "BlockLong"; lastSizeSpawned = 3; } lastColumnSpawned = x; GameObject g; pos.x += ConvertColumnToPos(x); g = (GameObject)GameObject.Instantiate(Resources.Load(chosenBlock)); g.transform.position = pos; g.transform.SetParent(transform); } else { isLastEmpty = true; } } spawnTimer -= deltaTime; }
float ConvertColumnToPos(int x) { return(AreaLimits.CenterX() - AreaLimits.BlockColumnsCount() / 2f + x); }