Exemple #1
0
    void NeighborAttackedAction(ref AbstractPlanet planet)
    {
        foreach (AbstractPlanet neigh in planet.adjacentPlanet)
        {
            if (actionHappened)
            {
                continue;
            }

            if (neigh.isContested && planet.planetOwnership == AbstractPlanet.Ownership.Enemy)               //Is my neighbor planet being attacked
            {
                if (ValidPlanetForTraining(ref planet))
                {
                    planet.TrainSoldiers(true);
                }
                planet.isFeeding = true;
                float totalUnits = neigh.enemySoldiers + neigh.playerSoldiers;
                if (neigh.playerSoldiers / totalUnits > 0.50f)
                {
                    ship = planet.CreateShip(AbstractPlanet.Ownership.Enemy);
                    if (ship.soldiersOnBoard == ship.soldierCapacity ||
                        (!CanNewUnitsBeCreated() && ship.soldiersOnBoard > 0))
                    {
                        LaunchShip(planet, neigh, planet.adjacentPaths, ship);
                    }
                    else if (!ship.GetIsLoading())
                    {
                        ship.StartLoadingSoldiersToShip(planet);
                    }
                }
                action++;
                actionHappened = true;
            }
        }
    }
Exemple #2
0
 void NeighborNeedsSoldiersAction(ref AbstractPlanet planet)
 {
     foreach (AbstractPlanet neigh in planet.adjacentPlanet)
     {
         if (actionHappened)
         {
             continue;
         }
         AbstractPlanet target = null;
         if (neigh.planetOwnership == AbstractPlanet.Ownership.Enemy && neigh.isRequestingSoldiers)
         {
             if (ValidPlanetForTraining(ref planet))
             {
                 planet.TrainSoldiers(true);
             }
             planet.isFeeding        = true;
             planet.planetRequesting = neigh;
             target = neigh;
         }
         else if (neigh.planetOwnership == AbstractPlanet.Ownership.Enemy && neigh.isFeeding)
         {
             if (PlanetInPath(neigh, neigh.planetRequesting) && neigh != neigh.planetRequesting)
             {
                 if (ValidPlanetForTraining(ref planet))
                 {
                     planet.TrainSoldiers(true);
                 }
                 planet.isFeeding        = true;
                 planet.planetRequesting = neigh.planetRequesting;
                 target = neigh;
             }
         }
         if (target)
         {
             ship = planet.CreateShip(AbstractPlanet.Ownership.Enemy);
             if (ship.soldiersOnBoard >= ship.soldierCapacity * 0.1f ||
                 (!CanNewUnitsBeCreated() && ship.soldiersOnBoard > 0))
             {
                 LaunchShip(planet, target, planet.adjacentPaths, ship);
             }
             else if (!ship.GetIsLoading())
             {
                 ship.StartLoadingSoldiersToShip(planet);
             }
             action++;
             actionHappened = true;
         }
     }
 }
Exemple #3
0
    void ExpandAction(ref AbstractPlanet planet)
    {
        foreach (AbstractPlanet neigh in planet.adjacentPlanet)
        {
            if (actionHappened)
            {
                continue;
            }
            if (neigh.planetOwnership == AbstractPlanet.Ownership.Neutral && neigh.isContested == false)
            {
                if (planet.GetPlanetType() != AbstractPlanet.PlanetType.Hybrid && planet.GetPlanetType() != AbstractPlanet.PlanetType.Soldier && planet.enemySoldiers == 0)
                {
                    planet.isRequestingSoldiers = true;
                }
                else
                {
                    planet.isRequestingSoldiers = false;
                    planet.planetRequesting     = null;
                    if (ValidPlanetForTraining(ref planet))
                    {
                        planet.TrainSoldiers(true);
                    }
                }


                ship = planet.CreateShip(AbstractPlanet.Ownership.Enemy);
                if (ship.soldiersOnBoard >= 1 ||
                    (!CanNewUnitsBeCreated() && ship.soldiersOnBoard > 0))
                {
                    LaunchShip(planet, neigh, planet.adjacentPaths, ship);
                    planet.TrainSoldiers(false);
                }
                else if (!ship.GetIsLoading())
                {
                    ship.StartLoadingSoldiersToShip(planet);
                }
                action++;
                actionHappened = true;
            }
        }
    }
Exemple #4
0
    void PlayerNearAction(ref AbstractPlanet planet)
    {
        foreach (AbstractPlanet neigh in planet.adjacentPlanet)
        {
            if (actionHappened)
            {
                continue;
            }

            if (neigh.planetOwnership == AbstractPlanet.Ownership.Player)               //Is there an enemy next to me
            {
                if (ValidPlanetForTraining(ref planet))
                {
                    planet.TrainSoldiers(true);
                }
                planet.isRequestingSoldiers = true;
                //Am I stronger then the enemy, then attack
                int estimatedUnits = (int)Mathf.Max(neigh.rankingScript.currentRank * 50 - 25, 0);

                ship = planet.CreateShip(AbstractPlanet.Ownership.Enemy);
                if ((ship.soldiersOnBoard + planet.enemySoldiers) > (estimatedUnits))
                {
                    if (ship.soldiersOnBoard == ship.soldierCapacity || ship.soldiersOnBoard > estimatedUnits)
                    {
                        LaunchShip(planet, neigh, planet.adjacentPaths, ship);
                    }
                    else if (!ship.GetIsLoading())
                    {
                        ship.StartLoadingSoldiersToShip(planet);
                    }
                }
                else
                {
                    ship.StopLoadingSoldiersToShip();
                }
                action++;
                actionHappened = true;
            }
        }
    }