Exemplo n.º 1
0
    void HandleMovement()
    {
        // Keyboard.

        Vector2 vel = Vector2.zero;

        if (Input.GetKey(KeyCode.W))
        {
            vel += new Vector2(0f, 1.0f);
        }
        if (Input.GetKey(KeyCode.S))
        {
            vel += new Vector2(0f, -1.0f);
        }
        if (Input.GetKey(KeyCode.D))
        {
            vel += new Vector2(1.0f, 0f);
        }
        if (Input.GetKey(KeyCode.A))
        {
            vel += new Vector2(-1.0f, 0f);
        }

        rigidBody.velocity = ((Vector3)(speed * vel.normalized));

        // Mouse.

        float angle = MathSET.AngleBetween(Camera.main.ScreenToWorldPoint(Input.mousePosition), transform.position);

        transform.eulerAngles = new Vector3(0f, 0f, angle);
    }
Exemplo n.º 2
0
    void CalcIndex()
    {
        float perc = MathSET.Map(currentHp, 0, maxHp, 0, 1);

        if (perc > 0.75f)
        {
            rageIndex = 0;
        }
        else if (perc > 0.5f)
        {
            rageIndex = 1;
        }
        else if (perc > 0.25f)
        {
            rageIndex = 2;
        }
        else if (perc > 0.05f)
        {
            rageIndex = 3;
        }
        else
        {
            rageIndex = 4;
        }
    }
Exemplo n.º 3
0
    void CalcStars()
    {
        angleOffset = (angleOffset + STAR_OMEGAS[rageIndex] * Time.deltaTime) % 360f;

        for (int i = 0; i < stars.Count; ++i)
        {
            float angle = ((MathSET.Map(i, 0, stars.Count, 0f, 360f) + angleOffset) % 360f) * Mathf.Deg2Rad;
            stars[i].position = new Vector3(transform.position.x + STAR_DISTANCE * Mathf.Cos(angle), transform.position.y + STAR_DISTANCE * Mathf.Sin(angle), transform.position.z);
        }
    }
Exemplo n.º 4
0
    void Shoot()
    {
        for (float i = 0; i < BULLET_COUNT[rageIndex]; ++i)
        {
            SoundManager.Play(audioSrc, SoundManager.Clip.BOSS_SHOOT);
            float angle = ((MathSET.Map(i, 0, BULLET_COUNT[rageIndex], 0f, 360f) + angleOffset) % 360f) * Mathf.Deg2Rad;

            Vector3 vel = new Vector3(BULLET_SPEEDS[rageIndex] * Mathf.Cos(angle), BULLET_SPEEDS[rageIndex] * Mathf.Sin(angle), 0f);

            ProjectileScript proj = Instantiate(bulletPrefab, transform.position, Quaternion.Euler(0f, 0f, angle * Mathf.Rad2Deg)).GetComponent <ProjectileScript>();
            proj.Construct(vel, BULLET_DAMAGE, "Bullet_pi", 255);
        }
    }
Exemplo n.º 5
0
Arquivo: Alive.cs Projeto: deprimus/D1
    protected virtual void RenderHp()
    {
        float scale = GetHpScale();

        hpEmptyTransform.localScale   = new Vector3(scale, scale, 1f);
        hpOverlayTransform.localScale = new Vector3(MathSET.Map(currentHp, 0f, maxHp, 0f, scale), scale, 1f);

        Vector3 pos   = GetTransform().position + (-GetTransform().up *HP_BAR_DISTANCE);
        Vector3 angle = GetTransform().eulerAngles;

        hpEmptyTransform.position   = pos;
        hpOverlayTransform.position = pos;

        hpEmptyTransform.eulerAngles   = angle;
        hpOverlayTransform.eulerAngles = angle;
    }
Exemplo n.º 6
0
    protected override void Die()
    {
        if (!dead)
        {
            dead = true;

            RenderHp();

            if (isAtBoss)
            {
                if (MathSET.Map(boss.currentHp, 0f, boss.maxHp, 0f, 1f) > 0.05f)
                {
                    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
                }
                else
                {
                    dialogManager.ShowDialog(() =>
                    {
                        SoundManager.PlayWith(audioSrc, SoundManager.Clip.SIGSEGV, () =>
                        {
                            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
                        });
                    },
                                             new Tuple <string, string>("Pi", "Phew, that was close."),
                                             new Tuple <string, string>("David", "..."),
                                             new Tuple <string, string>("David", "I'm doomed."),
                                             new Tuple <string, string>("Pi", "You see, I'm actually immortal."),
                                             new Tuple <string, string>("Pi", "Even if you wanted to, you couldn't kill me."),
                                             new Tuple <string, string>("Pi", "Anyway, looks like you're kind of dead."),
                                             new Tuple <string, string>("Pi", "I'll take my leave. Goodbye."));
                }
            }
            else
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
        }
    }
Exemplo n.º 7
0
    void HandleDirection()
    {
        float angle = MathSET.AngleBetween(playerTransform.position, transform.position);

        transform.eulerAngles = new Vector3(0, 0, angle);
    }