void Start() { if (isHuman) { Time.timeScale = 1; Cursor.SetCursor(cursor, new Vector2(cursor.width / 2, cursor.height / 2), CursorMode.Auto); if (startingPowerUp.Equals(PowerUpType.SPLIT)) { powerUp = new PowerUp(startingPowerUp); launcher.projectileType = ProjectileType.getSpread(0.1f, startingPowerUpStacks); } else if (startingPowerUp.Equals(PowerUpType.TRACKING)) { powerUp = new PowerUp(startingPowerUp); launcher.projectileType = ProjectileType.getSpread(0.1f, startingPowerUpStacks); launcher.isSeeking = true; } else { launcher.projectileType = ProjectileType.getRegular(0.1f); } horizontalAxis = Vector3.Normalize(Vector3.right + (Vector3.forward * -1)); verticalAxis = Vector3.Normalize(Vector3.right + Vector3.forward); isRunning = false; rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); lineRenderer = GetComponent <LineRenderer>(); lineRenderer.positionCount = 2; currentMoveSpeed = walkSpeed; aimDirection = launcher.transform.forward; isAirborne = false; } else { if (startingPowerUp.Equals(PowerUpType.SPLIT)) { launcher.projectileType = ProjectileType.getSpread(0.1f, startingPowerUpStacks); } else if (startingPowerUp.Equals(PowerUpType.TRACKING)) { launcher.projectileType = ProjectileType.getSpread(0.1f, startingPowerUpStacks); launcher.isSeeking = true; } else { launcher.projectileType = ProjectileType.getRegular(0.1f); } navAgent = GetComponent <NavMeshAgent>(); isRunning = false; rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); isAirborne = false; playerInRange = false; } }
public void PowerUp(PowerUpType powerUpType) { if (powerUpType.Equals(PowerUpType.HEALTH)) { float newHealth = health + 20; if (newHealth > maxHealth) { health = maxHealth; } else { health = newHealth; } } else if (powerUp == null || !powerUp.getType().Equals(powerUpType)) { powerUp = new PowerUp(powerUpType); if (powerUpType.Equals(PowerUpType.SPLIT)) { launcher.isSeeking = false; launcher.projectileType = ProjectileType.getSpread(0.1f, 1); } if (powerUpType.Equals(PowerUpType.TRACKING)) { launcher.isSeeking = true; launcher.projectileType = ProjectileType.getSpread(0.1f, 0); } } else { if (powerUp.getStackCount() < 3) { if (powerUpType.Equals(PowerUpType.SPLIT)) { launcher.projectileType = ProjectileType.getSpread(0.1f, ++powerUp.stackCount); } else if (powerUpType.Equals(PowerUpType.TRACKING)) { launcher.projectileType = ProjectileType.getSpread(0.1f, ++powerUp.stackCount - 1); } } } }
public void ActivatePowerUp(PowerUpType type) { last_powerup = active_powerup; active_powerup = type; // check switch off conditions if (last_powerup == PowerUpType.Enlarge) { transform.localScale = default_localScale; } if (last_powerup == PowerUpType.Slow) { SwitchBallsSpeed(false); } // handle one shot behaviours switch (active_powerup) { case PowerUpType.Enlarge: { Vector3 localScale = new Vector3(transform.localScale.x, 1.2f, transform.localScale.z); transform.localScale = localScale; break; } case PowerUpType.Slow: { SwitchBallsSpeed(true); break; } case PowerUpType.Disruption: { // instantiate 2 new balls // find current ball position GameObject any_current_ball = GameObject.FindGameObjectWithTag("Ball"); if (any_current_ball) { for (int i = 0; i < 2; ++i) { // TODO: check why this doesnt work if we instantiate directly as ballbehaviour GameObject new_ball = Instantiate(Resources.Load("Ball"), any_current_ball.transform.position, Quaternion.identity) as GameObject; if (new_ball) { BallBehaviour ball = new_ball.GetComponent <BallBehaviour>(); if (ball) { ball.movement = new Vector3(Random.Range(-1.0f, 1.0f), 0.0f, Random.Range(-1.0f, 1.0f)); } } } } else { Debug.LogError("not found any ball ingame"); } break; } case PowerUpType.ExtraLife: { gameManager.AddLife(); break; } } // play generic pickup clip if (!type.Equals(PowerUpType.None)) { m_audio.PlayOneShot(generic_pickup_clip); } }