Пример #1
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");
        }
    }
Пример #2
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));
                            }
                        });
                    }
                }
            }
        }
    }