Exemplo n.º 1
0
    private void SpawnNewHugeEnemy()
    {
        Assert.IsTrue(!_hugeEnemyExists);         //we only want one huge enemy at once on the screen
        EventLogger.PrintToLog("New Huge Enemy Spawn");
        ResetVerticalSpawnLimits();

        float randomIntervalCoef = Random.Range(MinHugeEnemySpawnIntervalCoef, MaxHugeEnemySpawnIntervalCoef);

        _hugeEnemySpawnInterval = randomIntervalCoef / _difficultyManagerScript.GetDifficultyMultiplier(DifficultyParameter.DpHugeEnemySpawnRateIncrease);

        //randomly select a prefab among available options
        int        hugeEnemyIndex  = Random.Range(0, HugeEnemyPrefabArray.Length);
        GameObject hugeEnemyPrefab = HugeEnemyPrefabArray[hugeEnemyIndex];
        HugeEnemy  hugeEnemyScript = hugeEnemyPrefab.GetComponent <HugeEnemy>();

        float diffOfPosition = hugeEnemyScript.VerticalSpawnLimits[1] - hugeEnemyScript.VerticalSpawnLimits[0];

        int hugeEnemyIntrusionSize = _difficultyManagerScript.DifficultyCoefs[DifficultyParameter.DpHugeEnemyIntrusionSize];

        float curDiffCoef = (float)(hugeEnemyIntrusionSize - 1) / (GameConstants.MaxDifficulty - GameConstants.MinDifficulty);     // 4/4, 3/4, 2/4, 1/4, 0/4

        float verticalSpawnCoord = hugeEnemyScript.VerticalSpawnLimits[0] + diffOfPosition * curDiffCoef;

        Vector3 hugeEnemyPos = new Vector2(hugeEnemyScript.HorizontalSpawnCoord, verticalSpawnCoord);

        SpawnHugeEnemyOnPosition(hugeEnemyPrefab, hugeEnemyScript, hugeEnemyPos);
    }
Exemplo n.º 2
0
    private void SpawnTutorialHugeEnemy()
    {
        GameObject hugeEnemyPrefab = HugeEnemyPrefabArray[0];
        HugeEnemy  hugeEnemyScript = hugeEnemyPrefab.GetComponent <HugeEnemy>();
        Vector3    hugeEnemyPos    = new Vector2(hugeEnemyScript.HorizontalSpawnCoord,
                                                 (hugeEnemyScript.VerticalSpawnLimits[0] + hugeEnemyScript.VerticalSpawnLimits[1]) * 0.5f);

        SpawnHugeEnemyOnPosition(hugeEnemyPrefab, hugeEnemyScript, hugeEnemyPos);
    }
Exemplo n.º 3
0
    private void SpawnHugeEnemyOnPosition(GameObject hugeEnemyPrefab, HugeEnemy hugeEnemyScript, Vector2 spawnPos)
    {
        GameObject hugeEnemy = Instantiate(hugeEnemyPrefab, spawnPos, Quaternion.identity);

        //TODO LATER we want to pull move dir of huge enemy from the corresponding basicmove script
        hugeEnemy.GetComponent <HugeEnemy>().Initialize(_playerScript, _difficultyManagerScript, hugeEnemy.GetComponent <BasicMove>(), Vector2.left);

        float colliderBoundary = hugeEnemyScript.VerticalColliderBoundary;

        if (Mathf.Approximately(Mathf.Sign(colliderBoundary), 1.0f))
        {
            //positive collider boundary means we're dealing with a huge enemy below, hence we should limit vMin
            _vertMinShipSpawnCoord = spawnPos.y + colliderBoundary + ShipColliderVertSize + 0.01f;
        }
        else
        {
            //negative collider boundary = huge enemy above = vMax
            _vertMaxShipSpawnCoord = spawnPos.y + colliderBoundary - ShipColliderVertSize - 0.01f;
        }

        SetHugeEnemyExists(true);
    }