Esempio n. 1
0
        public override void Start()
        {
            if (!m_StartCalled)
            {
                m_StartCalled   = true;
                mShip           = RequireComponent <PlayerShip>();
                mTarget         = RequireComponent <PlayerTarget>();
                mCharacter      = RequireComponent <PlayerCharacterObject>();
                mAI             = RequireComponent <AIState>();
                mRace           = RequireComponent <RaceableObject>();
                mMessage        = RequireComponent <MmoMessageComponent>();
                mDamagable      = RequireComponent <ShipBasedDamagableObject>();
                mWeapon         = RequireComponent <ShipWeapon>();
                mSkills         = RequireComponent <PlayerSkills>();
                mBonuses        = RequireComponent <PlayerBonuses>();
                mPassiveBonuses = GetComponent <PassiveBonusesComponent>();

                mCharacter.SetCharacterId((string)nebulaObject.Tag((byte)PlayerTags.CharacterId));
                mCharacter.SetCharacterName((string)nebulaObject.Tag((byte)PlayerTags.Name));
                printPropertiesTimer = printPropertiesInterval;

                if (application.serverActors.ContainsKey(nebulaObject.Id))
                {
                    MmoActor old;
                    if (application.serverActors.TryRemove(nebulaObject.Id, out old))
                    {
                        log.Info("successfully remove actor before replacing with new [red]");
                    }
                }
                if (application.serverActors.TryAdd(nebulaObject.Id, this))
                {
                    log.Info("successfully added actor to server actors [red]");
                }

                //create chest on killing when player die
                mDamagable.SetCreateChestOnKilling(true);
                mDamagable.SetIgnoreDamageInterval(30);
                mDamagable.SetIgnoreDamageAtStart(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Update a planet and determine population for tick.
        /// </summary>
        /// <param name="planet">The planet to update.</param>
        /// <param name="settings">Settings for the current Galaxy.</param>
        /// <param name="bonuses">Bonuses for the player based on their race.</param>
        /// <returns>The calculated values from the planet.</returns>
        public static PlanetValue Update(this Planet planet, GalaxySettings settings, PlayerBonuses bonuses)
        {
            var output = new PlanetValue();

            output.EntityCount = planet.TotalBuildings;

            // Set the base population
            if (Math.Abs(planet.Population - 0) < settings.BasePopulation)
            {
                planet.Population = settings.BasePopulation;
            }

            // multiply by 0.01 to convert to percentage
            var min1 = planet.Population * (1 + (settings.PopulationGrowth * bonuses.WelfareBonus * 0.01));

            var min2 = settings.BasePopulation + (settings.MaxPopulationPerBuildings * planet.BuildingCapacity)
                       + (planet.LivingQuartersCount * settings.PeoplePerLivingQuarter * bonuses.WelfareBonus);

            // cap the population
            output.Population = Math.Min(min1, min2);

            planet.PopulationGrowth = output.Population - planet.Population;
            planet.Population       = output.Population;

            // cash calculations
            var cashBonus = bonuses.EconomyBonus * planet.CashBonus;

            // so the user always makes cash
            var positiveIncome = settings.PositiveIncomeCash * cashBonus;
            var buildingCount  = Math.Max(output.EntityCount, 1);

            output.CashFactoryCash = planet.CashFactoryCount * settings.CashOutput * cashBonus;
            output.PopulationCash  = planet.Population / settings.PopulationCashDivider * cashBonus;
            output.TaxOfficeCash   = (double)planet.TaxOfficeCount / buildingCount
                                     * (positiveIncome + output.CashFactoryCash + output.PopulationCash);

            output.Cash = positiveIncome + output.CashFactoryCash + output.PopulationCash + output.TaxOfficeCash;

            output.Energy = planet.EnergyLabCount * planet.EnergyBonus;
            output.Food   = settings.FoodOutput * planet.FarmCount * planet.FoodBonus;
            output.Iron   = planet.MineCount * planet.IronBonus;
            output.Mana   = planet.ManaCount * planet.ManaBonus;

            output.Research = settings.ResearchOutput * planet.ResearchLabCount * planet.ResearchBonus * bonuses.ResearchBonus;

            return(output);
        }