Exemple #1
0
    public void FrecceGemelle(GameObject _enemy)
    {
        //costo e variabili
        int mp = costoAbilita[2];

        //calcola effetto
        int      danni = player.stats.attDistanza + Mathf.RoundToInt(player.stats.attDistanza / 2);
        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        GameObject effect = Instantiate(frecceGemelleSprite);

        effect.transform.position = _enemy.transform.position;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioFreccia);
        //scala il danno dal nemico e gli mp al player
        enemy.SubisciDannoMelee(danni, _enemy);
        player.stats.mp -= mp;
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
    }
Exemple #2
0
    public void AssorbiAnima(GameObject _enemy)
    {
        //calcola effetto
        int danni = player.stats.attDistanza;

        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        GameObject effect = Instantiate(assorbiAnimaEnemy);

        effect.transform.position = new Vector3(_enemy.transform.position.x, _enemy.transform.position.y + 0.5f, _enemy.transform.position.z);
        GameObject effect1 = Instantiate(assorbiAnimaPlayer);

        effect1.transform.position = player.transform.position;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioAssorbiAnima);
        //scala il danno dal nemico e gli mp al player
        SpriteRenderer sr = _enemy.GetComponent <SpriteRenderer>();

        sr.color = Color.white;
        int danniEffettivi = enemy.SubisciDannoRangedAndReturn(danni, _enemy);

        if (player.stats.mp + danniEffettivi > player.stats.mpMax)
        {
            player.stats.mp = player.stats.mpMax;
        }
        else
        {
            player.stats.mp += danniEffettivi;
        }
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.DamageText(player.gameObject, danniEffettivi, Color.blue);
        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
    public void Disarma(GameObject _enemy)
    {
        //costo e variabili
        int mp                = costoAbilita[3];
        int nturni            = 2;
        int percentualeDebuff = 35;
        int danni             = player.stats.attMelee;
        //calcola effetto
        GameObject effect = Instantiate(attaccoMeno);

        effect.transform.position = _enemy.transform.position;
        GameObject effect1 = Instantiate(attaccoFisico);

        effect1.transform.position = _enemy.transform.position;
        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        int debuffAttacco = Mathf.RoundToInt((enemy.att * percentualeDebuff) / 100);

        enemy.nturnoAttacco.Add(nturni);
        enemy.debuffAttacco.Add(debuffAttacco);
        enemy.att -= debuffAttacco;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(attMeno);
        //scala il danno dal nemico e gli mp al player
        SpriteRenderer sr = _enemy.GetComponent <SpriteRenderer>();

        sr.color = Color.white;
        enemy.SubisciDannoMelee(danni, _enemy);
        player.stats.mp -= mp;

        // Robe per UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
Exemple #4
0
    public void Cura(GameObject _player)
    {
        //costo e variabili
        int        mp           = costoAbilita[0];
        Player     playerTarget = _player.GetComponent <Player>();
        GameObject effect       = Instantiate(spriteCura);

        effect.transform.position = _player.transform.position;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioCura);
        //calcola effetto
        int cura = Mathf.RoundToInt(this.player.stats.attMagico * (Random.Range(1f, 1.25f)));

        if (playerTarget.stats.hp + cura > playerTarget.stats.hpMax)
        {
            playerTarget.stats.hp = playerTarget.stats.hpMax;
        }
        else
        {
            playerTarget.stats.hp += cura;
        }
        Animator anim = player.GetComponent <Animator>();

        if (playerTarget.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        //scala il danno dal nemico e gli mp al player
        SpriteRenderer sr = _player.GetComponent <SpriteRenderer>();

        sr.color              = Color.white;
        this.player.stats.mp -= mp;
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaVita(playerTarget.stats.hpMax, playerTarget.stats.hp, playerTarget.uiInfo);
        ui.DamageText(playerTarget.gameObject, cura, Color.green);
        ui.AggiornaMana(this.player.stats.mpMax, this.player.stats.mp, this.player.uiInfo);
        DestroyBuffBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
Exemple #5
0
    // ABILITA ESORTAZIONE    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void Esortazione()
    {
        //costo e variabili
        int mp                = costoAbilita[1];
        int nturni            = 3;
        int percentualeDebuff = 25;

        //Cerca gli alleati
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");

        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioEsortazione);

        foreach (var item in players)
        {
            if (item != null)
            {
                Player pl = item.GetComponent <Player>();

                GameObject effect = Instantiate(esortazioneSprite);
                effect.transform.position = item.transform.position;

                int buffMelee  = (pl.stats.attMelee * percentualeDebuff) / 100;
                int buffMagico = (pl.stats.attMagico * percentualeDebuff) / 100;
                int buffRanged = (pl.stats.attDistanza * percentualeDebuff) / 100;

                pl.nturnoBuffAttacco.Add(nturni);

                pl.buffAttaccoMelee.Add(buffMelee);
                pl.buffAttaccoMagico.Add(buffMagico);
                pl.buffAttaccoRanged.Add(buffRanged);

                pl.stats.attMelee    += buffMelee;
                pl.stats.attDistanza += buffRanged;
                pl.stats.attMagico   += buffMagico;
            }
        }
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.dpsAbilityPanel.SetActive(false);
        ui.AggiornaMana((float)player.stats.mpMax, (float)player.stats.mp, player.uiInfo);
        ui.CoAttivaPanel();
        player.stats.mp -= mp;
    }
Exemple #6
0
    public void Veleno(GameObject _enemy)
    {
        //costo e variabili
        int mp                = costoAbilita[3];
        int nturni            = 3;
        int percentualeVeleno = 5;
        int danni             = player.stats.attDistanza;
        //calcola effetto
        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        GameObject effect = Instantiate(dardoAvvelenato);

        effect.transform.position = _enemy.transform.position;
        GameObject effect1 = Instantiate(veleno);

        effect1.transform.SetParent(_enemy.transform);
        effect1.transform.position = _enemy.transform.position;
        enemy.turniVeleno         += nturni;
        enemy.percVeleno           = percentualeVeleno;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioVeleno);
        //scala il danno dal nemico e gli mp al player
        SpriteRenderer sr = _enemy.GetComponent <SpriteRenderer>();

        sr.color = Color.white;
        enemy.SubisciDannoRanged(danni, _enemy);
        player.stats.mp -= mp;

        // Robe per UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
    }
    public void SpaccaTeschi(GameObject _enemy)
    {
        //costo e variabili
        int mp = costoAbilita[4];

        //calcola effetto
        int        danni  = player.stats.attMelee + Mathf.RoundToInt(player.stats.attMelee / 2);
        GameObject effect = Instantiate(spaccaossi);

        effect.transform.position = new Vector3(player.transform.position.x, player.transform.position.y + 0.5f, 0);;
        GameObject effect1 = Instantiate(attaccoCasuale);

        effect1.transform.position = _enemy.transform.position;
        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        //scala il danno dal nemico e gli mp al player
        SpriteRenderer sr = _enemy.GetComponent <SpriteRenderer>();

        sr.color = Color.white;
        enemy.SubisciDannoMelee(danni, _enemy);
        player.stats.mp -= mp;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(spaccaOs);
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
Exemple #8
0
    public void Protezione(GameObject _player)
    {
        //costo e variabili
        int      mp           = costoAbilita[1];
        int      nTurniBuff   = 2;
        Player   playerTarget = _player.GetComponent <Player>();
        Animator anim         = player.GetComponent <Animator>();

        if (playerTarget.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        GameObject effect = Instantiate(protezione);

        effect.transform.position = new Vector3(_player.transform.position.x, _player.transform.position.y + 0.5f, _player.transform.position.z);
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioProtezione);

        //calcola effetto
        playerTarget.nTurnoProtezione += nTurniBuff;
        //scala il danno dal nemico e gli mp al player
        SpriteRenderer sr = _player.GetComponent <SpriteRenderer>();

        sr.color              = Color.white;
        this.player.stats.mp -= mp;
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(this.player.stats.mpMax, this.player.stats.mp, this.player.uiInfo);
        DestroyBuffBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
Exemple #9
0
    public void Fulmine(GameObject _enemy)
    {
        //costo e variabili
        int mp = costoAbilita[4];

        GameObject effect = Instantiate(fulmine);

        effect.transform.position = _enemy.transform.position;

        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioFulmine);

        //calcola effetto
        int      danni = Mathf.RoundToInt(((player.stats.attMagico) * 1.5f) * (Random.Range(1.0f, 1.25f)));
        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        //scala il danno dal nemico e gli mp al player
        enemy.SubisciDannoRanged(danni, _enemy);
        player.stats.mp -= mp;
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
Exemple #10
0
    public void Ragnatela(GameObject _enemy)
    {
        //costo e variabili
        int   mp     = costoAbilita[3];
        float random = Random.Range(0.0f, 100.0f);

        if (random >= 0)
        {
            List <int>       n  = new List <int>();
            CombatController cc = FindObjectOfType <CombatController>();
            int nturni          = 0;

            for (int j = cc.turno + 1; j < cc.player.Count; j++)
            {
                if (cc.player[j] == _enemy)
                {
                    n.Add(j);
                }

                nturni++;

                if (nturni == 2)
                {
                    break;
                }
            }
            n.Reverse();
            foreach (var item in n)
            {
                cc.player.RemoveAt(item);
            }
            cc.UpdateTurnPortrait();
        }

        GameObject effect = Instantiate(ragnatela);

        effect.transform.position = _enemy.transform.position;
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioRagnatela);

        //calcola effetto
        int      danni = Mathf.RoundToInt(((1) * 1.5f) * (Random.Range(1.0f, 1.25f)));
        Enemy    enemy = _enemy.GetComponent <Enemy>();
        Animator anim  = player.GetComponent <Animator>();

        if (enemy.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        //scala il danno dal nemico e gli mp al player
        enemy.SubisciDannoRanged(danni, _enemy);
        player.stats.mp -= mp;
        // Roba UI
        UiController ui = FindObjectOfType <UiController>();

        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        DestroyAttackBox();
        DestroyEnemyButton();
        ui.CoSvuotaPanel();
    }
Exemple #11
0
    public void PioggiaDiFrecce(GameObject _enemy)
    {
        BattleGrid   grid = FindObjectOfType <BattleGrid>();
        UiController ui   = FindObjectOfType <UiController>();
        // Suono
        AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();

        audio.PlayOneShot(audioFreccia);
        //costo e variabili
        int mp    = costoAbilita[4];
        int danni = Mathf.RoundToInt(((player.stats.attDistanza) * 63) / 100);
        List <GameObject> targets = new List <GameObject>();
        // cerca i target

        Enemy    ene  = _enemy.GetComponent <Enemy>();
        Animator anim = player.GetComponent <Animator>();

        if (ene.pos.x >= player.pos.x)
        {
            anim.SetTrigger("AttackRight");
        }
        else
        {
            anim.SetTrigger("AttackLeft");
        }
        int _x = (int)ene.pos.x;
        int _y = (int)ene.pos.y;



        for (int i = (_x - 3); i <= (_x + 3); i++)
        {
            for (int y = (_y - 3); y <= (_y + 3); y++)
            {
                if (i < 0)
                {
                    continue;
                }
                if (y < 0)
                {
                    continue;
                }
                if (i > grid.width - 1)
                {
                    continue;
                }
                if (y > grid.height - 1)
                {
                    continue;
                }

                if (Mathf.Abs(i - _x) + Mathf.Abs(y - _y) <= (3))
                {
                    if (grid.cells[i, y].occupier != null)
                    {
                        targets.Add(grid.cells[i, y].occupier);
                    }
                }
            }
        }

        foreach (GameObject item in targets)
        {
            GameObject effect = Instantiate(frecciaSprite);
            effect.transform.position = item.transform.position;

            if (item.GetComponent <Enemy>() != null)
            {
                Enemy enemy1 = item.GetComponent <Enemy>();
                enemy1.SubisciDannoRanged(danni, item);
            }
            else
            {
                Player player1 = item.GetComponent <Player>();
                player1.SubisciDanno(danni);
            }
        }

        Enemy enemy = _enemy.GetComponent <Enemy>();

        //scala il danno dal nemico e gli mp al player
        player.stats.mp -= mp;
        // Roba UI
        ui.AggiornaMana(player.stats.mpMax, player.stats.mp, player.uiInfo);
        GameObject[] targetss = GameObject.FindGameObjectsWithTag("Target");
        foreach (var item in targetss)
        {
            Destroy(item);
        }
        DestroyAttackBox();
        DestroyEnemyButton();
    }