コード例 #1
0
    //Atacas a alguien a melee
    public UnitGridCombat lookForEnemies(UnitGridCombat thisUnit) // lookForEnemies a una casilla
    {
        enemiesCount = gridCombatSystem.GetComponent <GridCombatSystem>().alliesTeamList.Count;
        Vector3 myPosition = thisUnit.GetPosition();
        float   distance;

        for (int i = 0; i <= enemiesCount; i++) // para comparar mi posición con la posición de todos los personajes del equipo del jugador
        {
            //El primer Player a rango, lo atacas
            distance = Vector3.Distance(myPosition, gridCombatSystem.GetComponent <GridCombatSystem>().alliesTeamList[i].GetPosition());
            if (distance <= 11 && (thisUnit.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.MELEE || thisUnit.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.TANK))
            {
                return(gridCombatSystem.GetComponent <GridCombatSystem>().alliesTeamList[i]);
            }
            else if (distance <= 31 && (thisUnit.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.MAGE || thisUnit.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.HEALER))
            {
                return(gridCombatSystem.GetComponent <GridCombatSystem>().alliesTeamList[i]);
            }
            else if (distance <= 41 && (thisUnit.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.RANGED))
            {
                return(gridCombatSystem.GetComponent <GridCombatSystem>().alliesTeamList[i]);
            }
        }
        return(null);
    }
コード例 #2
0
 public void UpdateSprite(UnitGridCombat unitGridCombat)
 {
     if (unitGridCombat.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.MELEE)
     {
         knightSprite.SetActive(true);
         archerSprite.SetActive(false);
         healerSprite.SetActive(false);
         tankSprite.SetActive(false);
         mageSprite.SetActive(false);
         tipoText.SetText("Knight");
         atkText.SetText("Atk: 25");
         SetLevelText();
     }
     else if (unitGridCombat.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.RANGED)
     {
         knightSprite.SetActive(false);
         archerSprite.SetActive(true);
         healerSprite.SetActive(false);
         tankSprite.SetActive(false);
         mageSprite.SetActive(false);
         tipoText.SetText("Archer");
         atkText.SetText("Atk: 20");
         SetLevelText();
     }
     else if (unitGridCombat.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.HEALER)
     {
         knightSprite.SetActive(false);
         archerSprite.SetActive(false);
         healerSprite.SetActive(true);
         tankSprite.SetActive(false);
         mageSprite.SetActive(false);
         tipoText.SetText("Priest");
         atkText.SetText("Atk: 10");
         SetLevelText();
     }
     else if (unitGridCombat.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.TANK)
     {
         knightSprite.SetActive(false);
         archerSprite.SetActive(false);
         healerSprite.SetActive(false);
         tankSprite.SetActive(true);
         mageSprite.SetActive(false);
         tipoText.SetText("Paladin");
         atkText.SetText("Atk: 15");
         SetLevelText();
     }
     else if (unitGridCombat.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.MAGE)
     {
         knightSprite.SetActive(false);
         archerSprite.SetActive(false);
         healerSprite.SetActive(false);
         tankSprite.SetActive(false);
         mageSprite.SetActive(true);
         tipoText.SetText("Wizard");
         atkText.SetText("Atk: 25");
         SetLevelText();
     }
 }
コード例 #3
0
 private void SetLevelText()
 {
     if (unitGridCombat.GetComponent <CHARACTER_PREFS>().level == CHARACTER_PREFS.Level.NIVEL1)
     {
         levelText.SetText("Lvl. 1");
     }
     else if (unitGridCombat.GetComponent <CHARACTER_PREFS>().level == CHARACTER_PREFS.Level.NIVEL2)
     {
         levelText.SetText("Lvl. 2");
     }
     else if (unitGridCombat.GetComponent <CHARACTER_PREFS>().level == CHARACTER_PREFS.Level.NIVEL3)
     {
         levelText.SetText("Lvl. 3");
     }
 }
コード例 #4
0
    //Me muevo a la posicion dentro del rango de movimiento
    private void WalkToEnemyInRange(UnitGridCombat thisUnit)
    {
        Grid <GridCombatSystem.GridObject> grid = GameHandler_GridCombatSystem.Instance.GetGrid();
        GridPathfinding gridPathfinding         = GameHandler_GridCombatSystem.Instance.gridPathfinding;

        if (CheckCollisionsTargetIntermedio() && gridObject.GetUnitGridCombat() == null)
        {
            if (thisUnit.GetComponent <CHARACTER_PREFS>().tipo != CHARACTER_PREFS.Tipo.DUMMY)
            {
                grid.GetGridObject(thisUnit.GetPosition()).ClearUnitGridCombat();
                thisUnit.MoveTo(target, () =>
                {
                    gridObject.SetUnitGridCombat(thisUnit);
                    if (gridCombatSystem.GetComponent <GridCombatSystem>().SeekEnemiesIA(thisUnit) == true)
                    {
                        thisUnit.AttackUnit(lookForEnemies(thisUnit));
                    }
                });
            }
        }
        else
        {
            Debug.Log("Aqui no deberia entrar nunca");
        }
    }
コード例 #5
0
    public void Damage(UnitGridCombat Attacker)
    {
        if (Attacker.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.MELEE)
        {
            attackID = 1;

            attackedByMelee  = true;
            attackedByArcher = false;
            attackedByHealer = false;
            attackedByTank   = false;
            attackedByMage   = false;

            if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL1)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 25.0f + ((25.0f / 100.0f) * 55.0f);
                }
                else
                {
                    damageAmount = 25.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL2)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 30.0f + ((30.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 30.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL3)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 35.0f + ((35.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 35.0f;
                }
            }
        }
        else if (Attacker.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.RANGED)
        {
            attackID = 2;

            attackedByMelee  = false;
            attackedByArcher = true;
            attackedByHealer = false;
            attackedByTank   = false;
            attackedByMage   = false;
            if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL1)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 20.0f + ((20.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 20.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL2)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 25.0f + ((25.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 25.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL3)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 30.0f + ((30.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 30.0f;
                }
            }
        }
        else if (Attacker.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.HEALER)
        {
            attackedByMelee  = false;
            attackedByArcher = false;
            attackedByHealer = true;
            attackedByTank   = false;
            attackedByMage   = false;
            if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL1)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 10.0f + ((10.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 10.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL2)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 15.0f + ((15.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 15.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL3)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 20.0f + ((20.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 20.0f;
                }
            }
        }
        else if (Attacker.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.TANK)
        {
            attackedByMelee  = false;
            attackedByArcher = false;
            attackedByHealer = false;
            attackedByTank   = true;
            attackedByMage   = false;
            if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL1)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 15.0f + ((15.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 15.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL2)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 20.0f + ((20.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 20.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL3)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 25.0f + ((25.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 25.0f;
                }
            }
        }
        else if (Attacker.GetComponent <CHARACTER_PREFS>().tipo == CHARACTER_PREFS.Tipo.MAGE)
        {
            attackID = 3;

            attackedByMelee  = false;
            attackedByArcher = false;
            attackedByHealer = false;
            attackedByTank   = false;
            attackedByMage   = true;
            if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL1)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 25.0f + ((25.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 25.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL2)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 30.0f + ((30.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 30.0f;
                }
            }
            else if (Attacker.GetComponent <CHARACTER_PREFS>().Getlevel() == CHARACTER_PREFS.Level.NIVEL3)
            {
                if (sceneCombatSystem.inspiredAttack)
                {
                    damageAmount = 35.0f + ((35.0f / 100.0f) * 20.0f);
                }
                else
                {
                    damageAmount = 35.0f;
                }
            }
        }
        float dmg;

        dmg = RandomDamage(damageAmount);
        sceneCombatSystem.DamagePopUp(this.GetPosition(), (int)dmg);
        healthSystem.Damage((int)dmg);

        if (healthSystem.IsDead())
        {
            if (Attacker.GetTeam() == Team.Blue)
            {
                if (characterPrefs.Getlevel() == CHARACTER_PREFS.Level.NIVEL1)
                {
                    if (attackedByMelee)
                    {
                        characterManager.meleeExp += 5;
                    }
                    if (attackedByArcher)
                    {
                        characterManager.archerExp += 5;
                    }
                    if (attackedByHealer)
                    {
                        characterManager.healerExp += 5;
                    }
                    if (attackedByTank)
                    {
                        characterManager.tankExp += 5;
                    }
                    if (attackedByMage)
                    {
                        characterManager.mageExp += 5;
                    }
                }
                if (characterPrefs.Getlevel() == CHARACTER_PREFS.Level.NIVEL3)
                {
                    if (attackedByMelee)
                    {
                        characterManager.meleeExp += 25;
                    }
                    if (attackedByArcher)
                    {
                        characterManager.archerExp += 25;
                    }
                    if (attackedByHealer)
                    {
                        characterManager.healerExp += 25;
                    }
                    if (attackedByTank)
                    {
                        characterManager.tankExp += 25;
                    }
                    if (attackedByMage)
                    {
                        characterManager.mageExp += 25;
                    }
                }

                imDead = true;
                sceneCombatSystem.CheckIfDead();
                for (int i = 0; i < sceneCombatSystem.enemiesTeamList.Count; i++)
                {
                    if (!sceneCombatSystem.enemiesTeamList[i].imDead)
                    {
                        sceneCombatSystem.newEnemiesTeamList.Add(sceneCombatSystem.enemiesTeamList[i]);
                    }
                }
                CleanListIA();
            }
            else if (Attacker.GetTeam() == Team.Red)
            {
                imDead = true;
                sceneCombatSystem.CheckIfDead();
                sceneCombatSystem.allydeads += 1;

                if (characterPrefs.getType() == CHARACTER_PREFS.Tipo.MELEE)
                {
                    sceneCombatSystem.numberOfMeleeLeft--;
                }
                if (characterPrefs.getType() == CHARACTER_PREFS.Tipo.RANGED)
                {
                    sceneCombatSystem.numberOfRangedLeft--;
                }
                if (characterPrefs.getType() == CHARACTER_PREFS.Tipo.HEALER)
                {
                    sceneCombatSystem.numberOfHealerLeft--;
                }
                if (characterPrefs.getType() == CHARACTER_PREFS.Tipo.TANK)
                {
                    sceneCombatSystem.numberOfTankLeft--;
                }
                if (characterPrefs.getType() == CHARACTER_PREFS.Tipo.MAGE)
                {
                    sceneCombatSystem.numberOfMageLeft--;
                }

                for (int i = 0; i < sceneCombatSystem.alliesTeamList.Count; i++)
                {
                    if (!sceneCombatSystem.alliesTeamList[i].imDead)
                    {
                        sceneCombatSystem.newAlliesTeamList.Add(sceneCombatSystem.alliesTeamList[i]);
                    }
                }
                CleanListAlly();
            }
        }
        StartCoroutine(FeedbackAttack(Attacker));
    }
コード例 #6
0
    //Moverse hacia un enemigo al target intermedio (Movimiento fuera del Rango de Movimiento)
    private void WalkToEnemyOutOfRange(UnitGridCombat thisUnit)
    {
        Grid <GridCombatSystem.GridObject> grid = GameHandler_GridCombatSystem.Instance.GetGrid();
        GridPathfinding gridPathfinding         = GameHandler_GridCombatSystem.Instance.gridPathfinding;

        SelectNewMovePosition(thisUnit.GetPosition()); //Se calcula el targetIntermedio
        gridObject = grid.GetGridObject(targetIntermedio);
        if (CheckCollisionsTargetIntermedio() && gridObject.GetUnitGridCombat() == null)
        {
            if (thisUnit.GetComponent <CHARACTER_PREFS>().tipo != CHARACTER_PREFS.Tipo.DUMMY)
            {
                grid.GetGridObject(thisUnit.GetPosition()).ClearUnitGridCombat();
                thisUnit.MoveTo(targetIntermedio, () =>
                {
                    gridObject.SetUnitGridCombat(thisUnit);
                    if (gridCombatSystem.GetComponent <GridCombatSystem>().SeekEnemiesIA(thisUnit) == true)
                    {
                        thisUnit.AttackUnit(lookForEnemies(thisUnit));
                    }
                });
            }
        }
        //Buscar nuevo target Intermedio y me muevo
        else
        {
            enemyOutOfRange  = false; //El target intermedio se calcula para que siempre este a rango de movimiento, por lo tanto esto va a ser siempre false en esta parte del codigo
            targetIntermedio = CheckTargetRange(targetIntermedio, thisUnit);
            gridObject       = grid.GetGridObject(targetIntermedio);
            if (CheckCollisionsTargetIntermedio() && gridObject.GetUnitGridCombat() == null && CheckMoveRange(targetIntermedio, thisUnit.GetPosition()))
            {
                if (thisUnit.GetComponent <CHARACTER_PREFS>().tipo != CHARACTER_PREFS.Tipo.DUMMY)
                {
                    grid.GetGridObject(thisUnit.GetPosition()).ClearUnitGridCombat();
                    thisUnit.MoveTo(targetIntermedio, () =>
                    {
                        gridObject.SetUnitGridCombat(thisUnit);
                        if (gridCombatSystem.GetComponent <GridCombatSystem>().SeekEnemiesIA(thisUnit) == true)
                        {
                            thisUnit.AttackUnit(lookForEnemies(thisUnit));
                        }
                    });
                }
            }
            else //Busca un segundo target intermedio y sus adyacentes para moverse a una posicion
            {
                targetIntermedio = CheckTargetRange(targetIntermedio, thisUnit);
                gridObject       = grid.GetGridObject(targetIntermedio);
                if (CheckCollisionsTargetIntermedio() && gridObject.GetUnitGridCombat() == null && CheckMoveRange(targetIntermedio, thisUnit.GetPosition()))
                {
                    if (thisUnit.GetComponent <CHARACTER_PREFS>().tipo != CHARACTER_PREFS.Tipo.DUMMY)
                    {
                        grid.GetGridObject(thisUnit.GetPosition()).ClearUnitGridCombat();
                        thisUnit.MoveTo(targetIntermedio, () =>
                        {
                            gridObject.SetUnitGridCombat(thisUnit);
                            if (gridCombatSystem.GetComponent <GridCombatSystem>().SeekEnemiesIA(thisUnit) == true)
                            {
                                thisUnit.AttackUnit(lookForEnemies(thisUnit));
                            }
                        });
                    }
                }
            }
        }
    }