コード例 #1
0
    void iceAttackVertical()
    {
        nextIceballTime = Time.time + iceballCoolDown;
        var position = attackPos.position;


        GameObject spellA1           = Instantiate(iceball, new Vector2(positionXIceVertical1 + Random.Range(-2.5f, 2.5f), positionYIceVertical1), Quaternion.identity);
        PlayerIce  spellA1Controller = spellA1.GetComponent <PlayerIce>();

        spellA1Controller.enemy = "Player";
        GameObject spellA2           = Instantiate(iceball, new Vector2(positionXIceVertical1 + Random.Range(-2.5f, 2.5f), positionYIceVertical1), Quaternion.identity);
        PlayerIce  spellA2Controller = spellA2.GetComponent <PlayerIce>();

        spellA2Controller.enemy = "Player";
        GameObject spellA3           = Instantiate(iceball, new Vector2(positionXIceVertical1 + Random.Range(-2.5f, 2.5f), positionYIceVertical1), Quaternion.identity);
        PlayerIce  spellA3Controller = spellA3.GetComponent <PlayerIce>();

        spellA3Controller.enemy = "Player";
        spellA1.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 270);
        spellA2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 270 + iceAngle);
        spellA3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 270 - iceAngle);



        GameObject spellB1           = Instantiate(iceball, new Vector2(positionXIceVertical2 + Random.Range(-2.5f, 2.5f), positionYIceVertical2), Quaternion.identity);
        PlayerIce  spellB1Controller = spellB1.GetComponent <PlayerIce>();

        spellB1Controller.enemy = "Player";
        GameObject spellB2           = Instantiate(iceball, new Vector2(positionXIceVertical2 + Random.Range(-2.5f, 2.5f), positionYIceVertical2), Quaternion.identity);
        PlayerIce  spellB2Controller = spellB2.GetComponent <PlayerIce>();

        spellB2Controller.enemy = "Player";
        GameObject spellB3           = Instantiate(iceball, new Vector2(positionXIceVertical2 + Random.Range(-2.5f, 2.5f), positionYIceVertical2), Quaternion.identity);
        PlayerIce  spellB3Controller = spellB3.GetComponent <PlayerIce>();

        spellB3Controller.enemy = "Player";
        spellB1.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 270);
        spellB2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 270 + iceAngle);
        spellB3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 270 - iceAngle);
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time >= nextIceballTime)
        {
            sfx.PlayEnemyAttack(gameObject.transform.position);
            nextIceballTime = Time.time + iceballCoolDown;
            var position = attackPos.position;
            //position.x = position.x * -1;

            GameObject spell            = Instantiate(iceball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
            PlayerIce  spell1Controller = spell.GetComponent <PlayerIce>();
            spell1Controller.enemy  = "Player";
            spell1Controller.damage = iceDamege;
            GameObject spell2           = Instantiate(iceball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
            PlayerIce  spell2Controller = spell2.GetComponent <PlayerIce>();
            spell2Controller.enemy  = "Player";
            spell2Controller.damage = iceDamege;
            GameObject spell3           = Instantiate(iceball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
            PlayerIce  spell3Controller = spell3.GetComponent <PlayerIce>();
            spell3Controller.enemy  = "Player";
            spell3Controller.damage = iceDamege;

            if (Mathf.Sign(transform.localScale.x) > 0)
            {
                spell.GetComponent <Transform>().rotation  = Quaternion.Euler(0, 0, 180);
                spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180 + iceAngle);
                spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180 - iceAngle);
            }
            else
            {
                spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, iceAngle);
                spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 360 - iceAngle);
            }

            Vector3 spellScale = spell.transform.localScale;
            spell.transform.localScale = new Vector3(spellScale.x * Mathf.Sign(gameObject.transform.localScale.x), spellScale.y, spellScale.z);
        }
    }
コード例 #3
0
    void iceAttackHorizaontal()
    {
        nextIceballTime = Time.time + iceballCoolDown;
        var position = attackPos.position;

        GameObject spell            = Instantiate(iceball, new Vector2(position.x, position.y), Quaternion.identity);
        PlayerIce  spell1Controller = spell.GetComponent <PlayerIce>();

        spell1Controller.enemy = "Player";
        GameObject spell2           = Instantiate(iceball, new Vector2(position.x, position.y), Quaternion.identity);
        PlayerIce  spell2Controller = spell2.GetComponent <PlayerIce>();

        spell2Controller.enemy = "Player";
        GameObject spell3           = Instantiate(iceball, new Vector2(position.x, position.y), Quaternion.identity);
        PlayerIce  spell3Controller = spell3.GetComponent <PlayerIce>();

        spell3Controller.enemy = "Player";

        float angle = angleAabbeellToChawa(GameObject.Find("Chawa").transform.position, position);

        spell.GetComponent <Transform>().rotation  = Quaternion.Euler(0, 0, angle);
        spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, angle + iceAngle);
        spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, angle - iceAngle);
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (!PauseMenu.IsPaused)
        {
            if (Input.GetButton("Fire1") && Time.time >= nextBasicAttackTime && player.GetComponent <PlayerController>().enableMoving)
            {
                nextBasicAttackTime = Time.time + basicAttackCoolDown;

                animator.SetTrigger(Attack);
                sfx.PlayChawaAttack(transform.position);
            }

            if (Input.GetButton("Fire2") && player.GetComponent <PlayerController>().enableMoving)
            {
                if (equipedSpell == spells.Fire && Time.time >= nextFireballTime)
                {
                    //Starts cooldown animation in HUD
                    _spellCooldownController.triggerSpell("fire");
                    nextFireballTime = Time.time + fireballCoolDown;
                    var        position = attackPos.position;
                    GameObject spell    = Instantiate(fireball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
                    sfx.PlayFireBallSFX(position);
                    PlayerFireBall spellController = spell.GetComponent <PlayerFireBall>();
                    spellController.enemy = "Enemy";
                    Vector3 spellScale = spell.transform.localScale;
                    spell.transform.localScale = new Vector3(spellScale.x * Mathf.Sign(gameObject.transform.localScale.x), spellScale.y, spellScale.z);
                    //Instantiate(fireball, attackPos.transform);
                }

                if (equipedSpell == spells.Ice && Time.time >= nextIceTime)
                {
                    //Starts cooldown animation in HUD
                    _spellCooldownController.triggerSpell("ice");
                    nextIceTime = Time.time + iceCoolDown;
                    var        position         = transform.position;
                    GameObject spell            = Instantiate(ice, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
                    PlayerIce  spell1Controller = spell.GetComponent <PlayerIce>();
                    spell1Controller.enemy = "Enemy";
                    GameObject spell2           = Instantiate(ice, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
                    PlayerIce  spell2Controller = spell2.GetComponent <PlayerIce>();
                    spell2Controller.enemy = "Enemy";
                    GameObject spell3           = Instantiate(ice, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity);
                    PlayerIce  spell3Controller = spell3.GetComponent <PlayerIce>();
                    spell3Controller.enemy = "Enemy";

                    sfx.PlayIceSFX(position);
                    if (Mathf.Sign(transform.localScale.x) > 0)
                    {
                        spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, iceAngle);
                        spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 360 - iceAngle);
                    }
                    else
                    {
                        spell.GetComponent <Transform>().rotation  = Quaternion.Euler(0, 0, 180);
                        spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180 + iceAngle);
                        spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180 - iceAngle);
                    }

                    Vector3 spellScale = spell.transform.localScale;
                    spell.transform.localScale = new Vector3(spellScale.x * Mathf.Sign(gameObject.transform.localScale.x), spellScale.y, spellScale.z);
                }

                if (equipedSpell == spells.Air && Time.time >= nextDashTime)
                {
                    //Starts cooldown animation in HUD
                    _spellCooldownController.triggerSpell("air");
                    nextDashTime = Time.time + dashCoolDown;
                    animator.SetBool("isDashing", true);
                    sfx.PlayAirDashSFX(transform.position);
                }
            }

            if (Input.GetButton("ChangeRight") && Time.time > nextSpellChange)
            {
                if (unlockedSpellCount > 1)
                {
                    nextSpellChange = Time.time + spellChangeCoolDown;
                    int index = Array.IndexOf(unlockedSpells, equipedSpell);
                    index = (index + 1) % unlockedSpellCount;

                    equipedSpell = unlockedSpells[index];
                }
            }

            if (Input.GetButton("ChangeLeft") && Time.time > nextSpellChange)
            {
                if (unlockedSpellCount > 1)
                {
                    nextSpellChange = Time.time + spellChangeCoolDown;
                    int index = Array.IndexOf(unlockedSpells, equipedSpell);
                    index = (index - 1) % unlockedSpellCount;
                    if (index == -1)
                    {
                        index = unlockedSpellCount - 1;
                    }
                    equipedSpell = unlockedSpells[index];
                }
            }

            if (animator.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
            {
                Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemy);
                for (int i = 0; i < enemiesToDamage.Length; ++i)
                {
                    //enemiesToDamage[i].GetComponent<EnemyController>().takeDamage(damage);
                    if (enemiesToDamage[i].GetComponent <EnemyController>().enemyName.CompareTo("Aabbeell") == 0)
                    {
                        enemiesToDamage[i].GetComponent <EnemyController>().takeDamage(damage, damage /*Basic*/);
                    }
                    else
                    {
                        enemiesToDamage[i].GetComponent <EnemyController>().takeDamage(damage);
                    }
                }
            }
        }
    }