private void Start() { if (stage != 5) { player = Instantiate(playerModel, playerStartPos, Quaternion.identity); enemy = Instantiate(enemyModel, enemyStartPos, Quaternion.identity); enemy.GetComponent <EnemyAI>().enabled = false; crown = Instantiate(crownModel); crownFollow = crown.GetComponent <CrownFollow>(); crown.SetActive(false); sphere = simplePool.PoolObject(); sphere.transform.position = sphereStartPos; sphereBounce = sphere.GetComponent <SphereBounce>(); sphere.SetActive(true); scoreHolderManager.InitializeBoard(maxScore); } else { player = Instantiate(playerModel, playerStartPos, Quaternion.identity); enemy = null; sphere = simplePool.PoolObject(); sphere.transform.position = sphereStartPos; sphereBounce = sphere.GetComponent <SphereBounce>(); sphere.SetActive(true); scoreHolderManager.InitializeGemBoard(); } PlayerFollow.player = player.transform; }
//private Animator anim; void Awake() { playerInput = GetComponent <PlayerInput>(); playerMove = GetComponent <PlayerMove>(); playerJump = GetComponent <PlayerJump>(); playerGroundDetection = GetComponent <PlayerGroundDetection>(); playerRhythmSwitch = GetComponent <PlayerRhythmSwitch>(); cubeWallJump = GetComponent <CubeWallJump>(); cubeDash = GetComponent <CubeDash>(); cubeDashLaunch = GetComponent <CubeDashLaunch>(); sphereGlide = GetComponent <SphereGlide>(); sphereSlam = GetComponent <SphereSlam>(); sphereBounce = GetComponent <SphereBounce>(); rb = GetComponent <Rigidbody>(); }
private void RespawnBall() { GameObject nextSphere = simplePool.PoolObject(); sphereBounce.KillSequence(); sphere.SetActive(false); Vector3 playerPos = player.transform.position; Vector3 enemyPos = Vector3.zero; if (enemy != null) { enemyPos = enemy.transform.position; } while (true) { Vector3 ballPosition = new Vector3(Random.Range(leftTopSpawnCorner.x, rightBottomSpawnCorner.x), Random.Range(rightBottomSpawnCorner.y, leftTopSpawnCorner.y)); //Проверка на нахождение случайной позиции в квадрате с стороной в 2*noSpawnrange и центром в позиции игрока if (!(playerPos.x > ballPosition.x - noSpawnRange && playerPos.x < ballPosition.x + noSpawnRange && playerPos.y > ballPosition.y - noSpawnRange && playerPos.y < ballPosition.y + noSpawnRange)) { //Аналогичная проверка с центром квадрата в позиции противника if (!(enemy != null && enemyPos.x > ballPosition.x - noSpawnRange && enemyPos.x < ballPosition.x + noSpawnRange && enemyPos.y > ballPosition.y - noSpawnRange && enemyPos.y < ballPosition.y + noSpawnRange)) { sphere = nextSphere; sphere.transform.position = ballPosition; sphereBounce = sphere.GetComponent <SphereBounce>(); sphere.SetActive(true); break; } } } }