Ejemplo n.º 1
0
 /// <summary>
 /// Called when drawing the scene
 /// </summary>
 /// <param name="imageIndex"></param>
 /// <param name="start"></param>
 /// <param name="finished"></param>
 public override void OnDraw(Semaphore start, int imageIndex, out Semaphore finished)
 {
     ClearEffect.Draw(start, Graphics.SwapchainAttachmentImages[imageIndex]);
     BulletHandler.Draw(ClearEffect.FinishedSemaphore, imageIndex, out var bulletsFinished);
     EnemyHandler.Draw(bulletsFinished, imageIndex, out var enemyFinished);
     finished = enemyFinished;
 }
Ejemplo n.º 2
0
    // Actions
    private void Die()
    {
        Vector3 deathPos = transform.position;

        // Move to spawn, stop controls and become invincible
        SFXHandler.PlaySound("playerdeath");
        StartCoroutine(DeathVisualEffect(1f, .6f, 80f, deathPos));
        StartCoroutine(Invincibility(3f));
        StartCoroutine(Paralyze(.3f));
        transform.position = startPos;

        // Lose 35% of power and drop 30%
        // Drops power above death position
        DropPower(deathPos, power * 0.30f);
        ChangePower(power * 0.65f);

        // Kill bullets
        BulletHandler.BulletsToScore();

        if (lives > 0)
        {
            lives--;
            Score.UpdatePlayer(lives);
        }
        else
        {
            // Pause and disable resuming on game over
            PauseMenu.TogglePause(PauseMode.GameOver);
            Debug.Log("Game Over");
        }
    }
Ejemplo n.º 3
0
    // Shoot
    private void HandleShot(BulletData data, float power)
    {
        switch (Mathf.FloorToInt(power))
        {
        case 0:
        case 1:
            BulletHandler.ShootSplit(data, 3f, 2);
            break;

        case 2:
        case 3:
            BulletHandler.ShootSplit(data, 3f, 3);
            break;

        case 4:
            BulletHandler.ShootSplit(data, 4f, 3);
            break;

        default:
            BulletHandler.ShootSplit(data, 4f, 4);
            break;
        }

        foreach (Transform orb in transform.Find("Orbs"))
        {
            if (orb.gameObject.activeSelf)
            {
                orb.GetComponent <Orb>().Shoot();
            }
        }
    }
Ejemplo n.º 4
0
    public void Shoot()
    {
        BulletData data = bulletData;

        data.pos = transform.position;

        BulletHandler.ShootBullet(data);
    }
Ejemplo n.º 5
0
    private void ShootABullet()
    {
        GameObject    bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
        BulletHandler bh     = bullet.GetComponent <BulletHandler>();

        bh.Shoot(transform.forward);
        Destroy(bullet, 3f);
    }
Ejemplo n.º 6
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.tag == "projectile")
     {
         BulletHandler bullet = collision.collider.gameObject.GetComponent <BulletHandler>();
         Globals.PlayerHealth();
     }
 }
Ejemplo n.º 7
0
    static public GameObject Create(GameObject created_obj, GameObject parent_obj, Vector3 path)
    {
        GameObject    temp   = GameObject.Instantiate(created_obj, parent_obj.transform.position, parent_obj.transform.rotation);
        BulletHandler script = temp.GetComponent <BulletHandler>();

        Physics2D.IgnoreCollision(temp.GetComponent <Collider2D>(), parent_obj.GetComponent <Collider2D>());
        return(temp);
    }
Ejemplo n.º 8
0
 /// <summary>
 /// Called when updating the scene
 /// </summary>
 public override void OnUpdate()
 {
     TimerHandler.Update();
     //System.GC.Collect(System.GC.MaxGeneration, System.GCCollectionMode.Optimized);
     //PlayerHandler.Update();
     BulletHandler.Update();
     EnemyHandler.Update();
 }
Ejemplo n.º 9
0
    // After delay seconds: Kill all enemies and convert all enemy bullets to score pickups, then collect them
    private IEnumerator BombEffect(float delay)
    {
        yield return(new WaitForSeconds(delay));

        StageHandler.KillAllEnemies();
        BulletHandler.BulletsToScore();
        StageHandler.CollectAllPickups(useConstantScore: true);
    }
    // Spawns two enemies from side and shoots circle spray
    // Negative centerDistance spreads enemies equally
    public IEnumerator TaskBurst3(int id, BulletData bulletData, int count = 40, float waitTimeMs = 500f, float shootTimeMs = 500f, float moveTimeMs = 5000f, float enterDistance = 3f, float centerDistance = -1f)
    {
        GameObject[] enemies = new GameObject[2];

        float spread;

        if (centerDistance < 0)
        {
            spread = StageSpread(2) / 2;
        }
        else
        {
            spread = centerDistance;
        }

        for (int i = 0; i < 2; i++)
        {
            int sign;
            if (i == 0)
            {
                sign = -1;
            }
            else
            {
                sign = 1;
            }

            // Spawn enemies
            enemies[i] = StageHandler.SpawnEnemy(id, new Vector3(
                                                     StageHandler.center.x + sign * (StageHandler.size.x / 2 + 1),
                                                     StageHandler.topRight.y - enterDistance
                                                     ), false);

            // Position where the enemy stops
            Vector3 endPos = new Vector3(
                StageHandler.center.x + sign * centerDistance,
                enemies[i].transform.position.y
                );

            // Change position and rotation of shot
            BulletData newBulletData = bulletData;
            newBulletData.pos = endPos;
            newBulletData.rot = BulletHandler.AngleToPlayer(enemies[i].transform.position);

            // Actions
            List <IEnumerator> actions = new List <IEnumerator>()
            {
                StageHandler.MoveObjectSmooth(moveTimeMs, enemies[i], endPos),
                BulletHandler.ShootSpiral(newBulletData, count, shootTimeMs / 1000),
                WaitMs(waitTimeMs),
                ToggleEnemyAI(enemies[i], true)
            };

            StageHandler.StartSequentialCoroutine(actions, enemies[i]);
        }

        yield return(null);
    }
Ejemplo n.º 11
0
    public override void Shoot()
    {
        SFXHandler.PlaySound("enemyshot");

        bulletData.pos = transform.position;
        bulletData.rot = BulletHandler.AngleToPlayer(transform.position);

        BulletHandler.ShootBullet(bulletData);
    }
Ejemplo n.º 12
0
 /// <summary>
 /// Called when ending the scene
 /// </summary>
 public override void OnEnd()
 {
     Current = null;
     TriangleRenderPass.Dispose();
     ClearEffect.End();
     TimerHandler.End();
     //PlayerHandler.End();
     BulletHandler.End();
     EnemyHandler.End();
 }
Ejemplo n.º 13
0
    void Start()
    {
        bulletHandlerScript = bulletHandler.GetComponent <BulletHandler>();
        var player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        if (player.Type != PlayerType.Soldier)
        {
            enabled = false;
        }
    }
Ejemplo n.º 14
0
    void SweepDestructedBullets()
    {
        //Copied to prevent issues when removing elements from List
        BulletHandler[] CopyOfBulletsAsArray = new BulletHandler[BulletsInternal.Count];
        BulletsInternal.CopyTo(CopyOfBulletsAsArray);

        foreach(BulletHandler Bullet in CopyOfBulletsAsArray){
            if(Bullet.IsQueuedForDestruct){
                DestroyBullet(Bullet);
            }
        }
    }
Ejemplo n.º 15
0
    // Invoca la bala y dispara
    void Shoot()
    {
        // Crear el objeto de la bala
        GameObject cloneBullet = Instantiate(bullet, transform.position, transform.rotation);

        // Obtener la referencia al script que se encarga de mover la bala
        BulletHandler myScript = cloneBullet.GetComponent <BulletHandler>();

        // Dispara en el sentido al que apunta la camara
        myScript.Shoot(transform.forward * impulse);

        Destroy(cloneBullet, 3f);
    }
    public override void Shoot()
    {
        SFXHandler.PlaySound("burstshot");

        bulletData.pos = transform.position;
        bulletData.rot = BulletHandler.AngleToPlayer(transform.position);

        StartCoroutine(BulletHandler.ShootBurst(
                           bulletData,
                           burstSpread,
                           burstCount,
                           burstTime
                           ));
    }
Ejemplo n.º 17
0
    void SweepDestructedBullets()
    {
        //Copied to prevent issues when removing elements from List
        BulletHandler[] CopyOfBulletsAsArray = new BulletHandler[BulletsInternal.Count];
        BulletsInternal.CopyTo(CopyOfBulletsAsArray);

        foreach (BulletHandler Bullet in CopyOfBulletsAsArray)
        {
            if (Bullet.IsQueuedForDestruct)
            {
                DestroyBullet(Bullet);
            }
        }
    }
Ejemplo n.º 18
0
        /// <summary>
        /// Called when starting the scene
        /// </summary>
        public override void OnStart()
        {
            Current            = this;
            TriangleRenderPass = new BasicRenderPass(Graphics);
            ClearEffect        = new ClearEffect(Graphics, TriangleRenderPass);
            ClearEffect.Start();
            ClearEffect.ClearColor = new ClearColorValue(0.5f, 0.7f, 0.9f);
            TimerHandler           = new TimerHandler(this);
            PlayerHandler          = new PlayerInterfaceHandler(1);
            BulletHandler          = new BulletHandler(this, 200000, ClearEffect);
            BulletHandler.Start();
            EnemyHandler = new EnemyHandler(this, 10000, BulletHandler.SpriteEffect);
            EnemyHandler.Start();

            ScriptHandler.ExecuteFile("demo.nut");
            ScriptHandler.CallGlobal("main");
        }
Ejemplo n.º 19
0
    IEnumerator SpreadBulletsLogic()
    {
        Difficulty difficulty = difficulties[currentLevel];

        // Make each spread bullets wave
        animator.SetTrigger("LaunchSpreadAttack");
        for (int i = 0; i != difficulty.spreadWavesRotations.Length; ++i)
        {
            // Calculate the angle of each spread
            float initialAngle = difficulty.spreadWavesRotations[i];
            float angleOffset  = 360f / (float)difficulty.spreadBullets;

            for (int j = 0; j != difficulty.spreadBullets; ++j)
            {
                BulletHandler bullet = spreadBulletPrefab.Spawn(transform.position, Quaternion.identity);
                bullet.transform.right = Quaternion.Euler(0, 0, initialAngle + (float)j * angleOffset) * transform.right;
                bullet.maxSpeed        = difficulty.spreadSpeed;
                bullet.SetDirection(new BulletInfo(bullet.transform.right, 50f));

                if (toggleBulletAS)
                {
                    sfxAudio2.clip          = spreadBulletSFX;
                    sfxAudio2.volume        = 1;
                    sfxAudio2.loop          = false;
                    klausAudio.spatialBlend = 1;
                    sfxAudio2.Play();
                }
                else
                {
                    sfxAudio3.clip          = spreadBulletSFX;
                    sfxAudio3.volume        = 1;
                    sfxAudio3.loop          = false;
                    klausAudio.spatialBlend = 1;
                    sfxAudio3.Play();
                }
                toggleBulletAS = !toggleBulletAS;
            }

            // Wait for some time
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(difficulty.timeBetweenSpreadWaves)));
        }

        ToNextAttack();
    }
Ejemplo n.º 20
0
    private void Fire()
    {
        if (!canFire)
        {
            return;
        }
        Quaternion quaternionAngle = Quaternion.Euler(new Vector3(0, 0, zAngle));
        float      angle           = quaternionAngle.eulerAngles.z;

        angle *= Mathf.Deg2Rad;
        float         cos          = Mathf.Cos(angle);
        float         sin          = Mathf.Sin(angle);
        GameObject    bulletClone  = Instantiate(aimRobotBullet, transform.position, quaternionAngle);
        Rigidbody2D   cloneRb      = bulletClone.GetComponent <Rigidbody2D>();
        BulletHandler cloneHandler = bulletClone.GetComponent <BulletHandler>();

        cloneRb.velocity          = new Vector2(cos * bulletSpeed, sin * bulletSpeed);
        cloneHandler.parentObject = this.transform.parent.gameObject;
        cloneHandler.destroyTime  = cloneDestroyTime;
        StartCoroutine(FireDelay());
    }
Ejemplo n.º 21
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == "player")
        {
            Globals.PlayerHealth();
            Globals.GameOver();
            Destroy(this.gameObject);
        }

        if (collision.collider.tag == "projectile")
        {
            BulletHandler bullet = collision.collider.gameObject.GetComponent <BulletHandler>();
            int           damage = bullet.Damage;
            health -= damage;
            Destroy(collision.collider.gameObject);
        }

        if (collision.collider.tag == "barrier")
        {
            Physics2D.IgnoreCollision(collision.collider, GetComponent <Collider2D>());
        }
    }
Ejemplo n.º 22
0
    public void Fire(Vector3 target)
    {
        Vector3 origin    = flash.transform.position;
        Vector3 direction = (target - origin).normalized;

        StartCoroutine(DoFlash());
        sfx.PlayBang();

        RaycastHit hit;

        Debug.DrawRay(origin, direction * bulletDistance, Color.red, 1f);
        if (Physics.Raycast(origin, direction, out hit, bulletDistance, ~0, QueryTriggerInteraction.Ignore))
        {
            BulletHandler bHandler = hit.transform.gameObject.GetComponent <BulletHandler>();

            if (!bHandler)
            {
                return;
            }

            bHandler.HitHandler(hit.point, damage);
        }
    }
Ejemplo n.º 23
0
    IEnumerator ElectricBoltsLogic()
    {
        Difficulty difficulty = difficulties[currentLevel];

        klausAudio.clip         = klausJA[UnityEngine.Random.Range(0, klausJA.Length)];
        klausAudio.spatialBlend = 0;
        klausAudio.Play();
        // Throw each bolts wave
        for (int i = 0; i != difficulty.boltsThrown; ++i)
        {
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(0.5f)));

            // Throw bolt
            sfxAudio.clip   = electricBoltSFX;
            sfxAudio.volume = 1;
            sfxAudio.Play();
            BulletHandler bullet = electricBoltPrefab.Spawn <BulletHandler>(electricBoltPoint, Vector3.zero, Quaternion.identity);
            bullet.maxSpeed = difficulty.boltsSpeed;
            bullet.SetDirection(new BulletInfo(bullet.transform.right, 60f));
        }

        ToNextAttack();
    }
Ejemplo n.º 24
0
    public IEnumerator Shoot(BulletManager BulletEngine, float RateModifier = 1f)
    {
        if (!CurrentBulletPrefab)
        {
            yield break;
        }
        CanFireInternal = false;
        GameObject BulletObject = MonoBehaviour.Instantiate(
            CurrentBulletPrefab,
            PortTransform.position,
            Quaternion.LookRotation(PortTransform.forward)
            )
                                  as GameObject;
        BulletHandler Bullet = BulletObject.GetComponent <BulletHandler>();

        //Make it Live, so it will have the correct flag to Move
        Bullet.IsLive = true;
        //Add to Bullet Manager, which will move it
        BulletEngine.Bullets.Add(Bullet);
        //Begin the Port's cooldown procedure
        yield return(new WaitForSeconds(Cooldown / RateModifier));

        CanFireInternal = true;
    }
Ejemplo n.º 25
0
    IEnumerator LaserLogic()
    {
        Difficulty difficulty         = difficulties[currentLevel];
        float      transitionWaitTime = 0.55f;
        float      totalTime          = difficulty.laserLockTime - transitionWaitTime;

        // Start creating energy bullets
        BulletHandler[] bullets = new BulletHandler[shootPositions.Length];
        for (int i = 0; i != shootPositions.Length; ++i)
        {
            bullets[i] = bigBulletPrefab.Spawn <BulletHandler>(shootPositions[i], Vector3.zero, Quaternion.identity);
        }

        // Turn off the background light
        StartCoroutine(TweenColor(new Color(0, 0, 0, 0.5f), totalTime * 0.9f));
        CameraShake.Instance.StartShake();

        // Turn on the light shield, the lights-in-ground effect, and the electric ground effect
        foreach (GameObject effect in loadEffects)
        {
            effect.SetActive(true);
        }

        // First 5%: Turn on some lightning animations
        float chunkTime = (totalTime * 0.1f) / ((float)onActivationEffects.Length);

        foreach (GameObject effect in onActivationEffects)
        {
            effect.SetActive(true);
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(chunkTime)));
        }

        // Wait a little
        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(totalTime * 0.6f)));

        // Just before release, turn on some light effects
        chunkTime = (totalTime * 0.2f) / ((float)beforeReleaseEffects.Length);
        foreach (GameObject effect in beforeReleaseEffects)
        {
            effect.SetActive(true);
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(chunkTime)));
        }

        // Wait a little more
        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(totalTime * 0.1f)));

        // Turn on the transition effect and turn on the background light
        transitionEffect.SetActive(true);
        StartCoroutine(TweenColor(new Color(0, 0, 0, 0), 0.1f));
        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(transitionWaitTime)));

        // LAUNCH ATTACK!
        CameraShake.Instance.StopShake();

        // Disable the light shield, the lights-in-ground effect, and the electric ground effect
        foreach (GameObject effect in loadEffects)
        {
            effect.SetActive(false);
        }

        // Turn off the light effects
        foreach (GameObject effect in beforeReleaseEffects)
        {
            effect.SetActive(false);
        }

        // Play the animation
        animator.SetTrigger("LaunchLaser");

        // Launch bullets!
        for (int i = 0; i != shootPositions.Length; ++i)
        {
            bullets[i].maxSpeed = difficulty.bigBulletSpeed;
            bullets[i].GetComponent <Animator>().SetTrigger("Launch");
            bullets[i].SetDirection(new BulletInfo(bullets[i].transform.right, 60f));
        }

        // Blur and shake for a moment
        StartCoroutine("BlurForTime", difficulty.blurTime);

        // Enable the electricity bolts
        foreach (GameObject effect in onReleaseEffects)
        {
            effect.SetActive(true);
        }

        // Stop animation
        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(0.75f)));

        animator.SetBool("Laser", false);
        Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("ObjectCharacter"), LayerMask.NameToLayer("Boss"), false);

        // Turn off the remaining effects
        transitionEffect.SetActive(false);
        foreach (GameObject effect in onReleaseEffects)
        {
            effect.SetActive(false);
        }

        foreach (GameObject effect in onActivationEffects)
        {
            effect.SetActive(false);
        }

        // Make vulnerable
        ChangeState(States.Vulnerable);
    }
 void Awake()
 {
     instance = this;
 }
Ejemplo n.º 27
0
 public void DestroyBullet(BulletHandler Bullet)
 {
     BulletsInternal.Remove(Bullet);
     Destroy(Bullet.gameObject);
 }
 public void Start()
 {
     _nextShootTime = Time.time;
     _bulletHandler = GetComponent<BulletHandler>();
 }
Ejemplo n.º 29
0
    IEnumerator VerticalBulletsLogic()
    {
        Difficulty difficulty = difficulties[currentLevel];
        float      chunkSize  = (maxPoint.x - minPoint.x) / ((float)difficulty.verticalBullets);

        klausAudio.clip         = klausJA[UnityEngine.Random.Range(0, klausJA.Length)];
        klausAudio.spatialBlend = 0;
        klausAudio.Play();
        // Going left
        for (int i = 0; i != difficulty.verticalBullets; ++i)
        {
            // Go to shooting position
            Vector2 position = cachedRigidbody.position;
            position.x -= chunkSize;
            yield return(StartCoroutine(MoveTowards(position, difficulties[currentLevel].movementSpeed)));

            // Shoot and make shoot pause
            sfxAudio.clip   = electricBoltSFX;
            sfxAudio.volume = 1;
            sfxAudio.Play();
            animator.SetTrigger("LaunchVerticalAttack");
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(0.15f)));

            BulletHandler bullet = verticalBulletPrefab.Spawn <BulletHandler>(verticalBulletPoint, Vector3.zero, Quaternion.identity);
            bullet.maxSpeed = difficulty.verticalBulletsSpeed;
            bullet.SetDirection(new BulletInfo(bullet.transform.right, 60f));

            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(difficulty.shootPauseTime)));
        }

        // Wait between the wave
        yield return(StartCoroutine(MoveTowards(new Vector2(minPoint.x, cachedRigidbody.position.y), difficulties[currentLevel].movementSpeed)));

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(difficulty.timeBetweenWaves)));

        klausAudio.clip         = klausJA[UnityEngine.Random.Range(0, klausJA.Length)];
        klausAudio.spatialBlend = 0;
        klausAudio.Play();
        // Going right
        for (int i = 0; i != difficulty.verticalBullets; ++i)
        {
            // Go to shooting position
            Vector2 position = cachedRigidbody.position;
            position.x += chunkSize;
            yield return(StartCoroutine(MoveTowards(position, difficulties[currentLevel].movementSpeed)));

            // Shoot and make shoot pause
            sfxAudio.clip   = electricBoltSFX;
            sfxAudio.volume = 1;
            sfxAudio.Play();
            animator.SetTrigger("LaunchVerticalAttack");
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(0.15f)));

            BulletHandler bullet = verticalBulletPrefab.Spawn <BulletHandler>(verticalBulletPoint, Vector3.zero, Quaternion.identity);
            bullet.SetDirection(new BulletInfo(bullet.transform.right, 60f));

            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(difficulty.shootPauseTime)));
        }

        yield return(StartCoroutine(MoveTowards(new Vector2(maxPoint.x, cachedRigidbody.position.y), difficulties[currentLevel].movementSpeed)));

        ToNextAttack();
    }
Ejemplo n.º 30
0
 public void DestroyBullet(BulletHandler Bullet)
 {
     BulletsInternal.Remove(Bullet);
     Destroy(Bullet.gameObject);
 }
Ejemplo n.º 31
0
    // Update is called once per frame
    void Update()
    {
        if (HexGM.isBattleRound())
        {
            /*
             * Check whether to display health bars
             */
            if (unit != null && !barsActive)
            {
                activateBars(true);
            }

            if (barsActive && unit == null)
            {
                activateBars(false);
            }
            else if (barsActive && unit != null)
            {
                setHealthColor(unit.isAlly);
                healthBar.value = (float)unit.currentHealth / unit.health;
                manaBar.value   = (float)unit.currentMana / unit.mana;
            }

            /*
             * Combat logic here
             */
            if (unit != null && unit.readyToAttack())
            {
                // figure out which tile to attack
                List <BaseTileHandler> bthl = battlefield.getClosestEnemy(coordinate, unit.isAlly);
                if (bthl != null)
                {
                    BaseTileHandler bth      = bthl[0];
                    int             distance = Battlefield.getDistance(this.coordinate, bth.getCoordinate());
                    if (!(distance <= unit.range))
                    {
                        // it's out of range, move instead, we already got the shortest path so try to move along the path
                        // the first unit is the target, so we want to start with the furthest possible range from the target
                        for (int i = unit.range; i > 0; i--)
                        {
                            if (bthl[i].getCurrentUnit() == null)
                            {
                                if (bthl[i].setUnit(this.unit))
                                {
                                    this.resetDefault();
                                    return;
                                }
                            }
                        }
                        for (int i = unit.range; i < bthl.Count; i++)
                        {
                            if (bthl[i].getCurrentUnit() == null)
                            {
                                if (bthl[i].setUnit(this.unit))
                                {
                                    this.resetDefault();
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        // Create the bullet, it'll be responsible for it's own destruction
                        var newBullet = Instantiate(AllyBullet, this.transform.position, Quaternion.identity);
                        newBullet.transform.SetParent(this.transform.parent.parent);
                        if (!unit.isAlly)
                        {
                            newBullet.GetComponent <Image>().color = Color.red;
                        }
                        BulletHandler b = newBullet.gameObject.GetComponent <BulletHandler>();
                        b.setDestination(this.transform.position, bth, unit);
                    }
                }
            }
        }
        else if (barsActive)
        {
            activateBars(false);
        }
    }
Ejemplo n.º 32
0
    IEnumerator Cutscene_Enter()
    {
        audioEnding.PlayDelayed(0.01f);
        DeadState state = target.GetComponentInChildren <DeadState>();

        state.blockRespawn = true;
        state.UnSuscribeOnStart(OnPlayerDead);
        CharacterManager.Instance.FreezeAll();

        // Flip if needed
        if (target.position.x < cachedRigidbody.position.x)
        {
            target.GetComponentInChildren <FlipSprite>().FlipIfCanFlip(Vector3.right);
        }
        else
        {
            target.GetComponentInChildren <FlipSprite>().FlipIfCanFlip(-Vector3.right);
        }

        // Show K1 dialogues


        Animator       K1Animator = K1.GetComponent(typeof(Animator)) as Animator;
        SpriteRenderer K1Sprite   = K1.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

        K1Animator.enabled = false;
        K1Sprite.sprite    = K1SpriteAngry.sprite;


        for (int i = 0; i != K1Dialogues.Length; ++i)
        {
            K1Dialogues[i].InitText();
            if (i == 0)
            {
                CameraShake.Instance.StartShake();
            }
            //VolDownMusik
            if (AS_W4BossMusik.Instance != null)
            {
                AS_W4BossMusik.Instance.MusikMuere();
            }
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(K1TimeBewteenDialogues[i])));

            if (i == 0)
            {
                CameraShake.Instance.StopShake();
            }
        }

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(timeForKlausAttack)));

        K1Animator.enabled = true;

        // Klaus GETS UP AND ATTACKS!!
        animator.SetBool("FinalAttack", true);
        animator.SetBool("Vulnerable", false);

        Blink overlayBlink = overlay.GetComponent <Blink>();

        overlayBlink.Play(5f, new Color(0, 0, 0, 0), new Color(0, 0, 0, 0.5f));

        foreach (GameObject effect in beforeReleaseEffects)
        {
            effect.SetActive(true);
        }

        foreach (GameObject effect in onReleaseEffects)
        {
            effect.SetActive(true);
        }

        //MusikClonesUp
        messageMix.SendMessage("NormalMix");
        if (AS_W4BossMusik.Instance != null)
        {
            AS_W4BossMusik.Instance.MusikRevive();
        }
        BulletHandler bullet = finalBulletPrefab.Spawn <BulletHandler>(cachedRigidbody.position, Quaternion.identity);

        bullet.transform.right = Vector3.Normalize(target.position - transform.position);
        bullet.SetDirection(new BulletInfo(bullet.transform.right, 60f));

        // Hide dialogues
        for (int i = 0; i != K1Dialogues.Length; ++i)
        {
            K1Dialogues[i].HideText();
            yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(0.1f)));
        }

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(0.5f)));

        // Now Klaus waits until it exits its trance
        overlayBlink.Stop();
        overlayBlink.SetColor(new Color(0, 0, 0, 0));

        foreach (GameObject effect in onReleaseEffects)
        {
            effect.SetActive(false);
        }

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(timeAfterKlausAttack * 0.1f)));

        foreach (GameObject effect in beforeReleaseEffects)
        {
            effect.SetActive(false);
        }

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(timeAfterKlausAttack * 0.9f)));

        // He gets up and sees K1
        animator.SetTrigger("WakeUp");
        KlausDialogues[0].HideText();

        Collider2D[] colliders = target.GetComponentsInChildren <Collider2D>();
        foreach (Collider2D collider in colliders)
        {
            collider.enabled = false;
        }

        target.GetComponentInChildren <Rigidbody2D>().isKinematic = true;

        DynamicCameraManager.Instance.RemoveEspecialTargetForK1();
        DynamicCameraManager.Instance.ChangueEspecialTargetForK1(transform, 0.5f, 7.5f, 0.5f);

        while (!inFrontOfCpu)
        {
            yield return(null);
        }

        // Run to the CPU
        animator.SetFloat("SpeedX", 5f);
        yield return(StartCoroutine(MoveTowards(cpuPosition, 5f, restrictY: true)));

        animator.SetFloat("SpeedX", 0f);
        ShowOutroDialogue(7);

        //lUIS COunter
        float timer = CounterTimerPlay.Instance.EndTime();

        SaveManager.Instance.AddPlayTime(timer);
        ManagerAnalytics.MissionCompleted(Application.loadedLevelName, false, timer, 0, true);

        // Hack the CPU
        LoadLevelManager.Instance.LoadLevel(SaveManager.Instance.isComingFromArcade ? "PrincipalMenu" : nextScene, true);
        animator.SetBool("TurnAround", true);
        animator.SetBool("isCoding", true);
        cpu.SetBool("Hacking", true);
        klausAudio.clip         = klausHacking;
        klausAudio.loop         = true;
        klausAudio.spatialBlend = 1;
        klausAudio.volume       = 0.6f;
        klausAudio.Play();

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(hackTime)));

        // CPU hacked
        klausAudio.Stop();
        klausAudio.loop       = false;
        sfxAudio.clip         = klausHaked;
        sfxAudio.spatialBlend = 1;
        sfxAudio.volume       = 0.6f;
        sfxAudio.Play();
        cpu.SetBool("HackingTrue", true);

        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(2f)));

        ShowOutroDialogue(8);

        // Load level
        yield return(StartCoroutine(new TimeCallBacks().WaitForSecondsPauseStop(2f)));

        LoadLevelManager.Instance.ActivateLoadedLevel();

        while (true)
        {
            yield return(null);
        }
    }