Exemplo n.º 1
0
        /// <summary>
        /// Used only for tempShips
        /// </summary>
        //public Ship()
        //{
        //    ShipStats = new ShipStats();
        //    StatBonuses = new ShipBonusHandler();

        //    Debuffs = new DebuffHandler();
        //    Shields = new QuickRegenShieldHandler(ShipStats, StatBonuses, Debuffs);
        //}

        public Ship(int shipID,
                    int playerID,
                    string playerName,
                    ShipStats stats,
                    ParticleManager particleManager,
                    SpriteBatch spriteBatch,
                    HashSet <int> teams)
        {
            _particleManager = particleManager;
            _spriteBatch     = spriteBatch;
            _rand            = new Random(7747);

            _weapons = new List <Weapon>();

            BodyBehaviors = new List <IBodyBehavior>();

            this.Id         = shipID;
            this.playerID   = playerID;
            this.playerName = playerName;
            Teams           = teams;


            lastTimeStamp = 0;

            IsSelected = false;

            PotentialTargets = new Dictionary <int, ITargetable>();

            Cargo = new CargoHandler_ReadAddRemoveVM <CargoHandlerModel>();

            Modules = new Dictionary <int, Module>();

            StatBonuses = new ShipBonusHandler();

            Debuffs = new DebuffHandler();

            switch (stats.ShieldType)
            {
            case ShieldTypes.QuickRegen:
                Shields = new QuickRegenShieldHandler(stats, StatBonuses, Debuffs);
                break;

            case ShieldTypes.SlowRegen:
                Shields = new SlowRegenShieldHandler(stats, StatBonuses, Debuffs);
                break;

            case ShieldTypes.NoRegen:
                Shields = new NoRegenShieldHandler(stats, StatBonuses, Debuffs);
                break;
            }

            ShipStats = stats;

            RecalculateModuleBonuses();

            CreateDictionaries(ShipStats.Energy);
        }
Exemplo n.º 2
0
        protected override void SetViewModel(ISynchronousTransaction <ISyncerCargoHandler, CargoResult> transaction)
        {
            var port = transaction.CargoHolder as Port;
            ISyncerCargoHandler sch;

            if (port == null)
            {
                sch = new CargoHandler_ReadAddRemoveVM <CargoHandlerModel>(transaction.CargoHolder.GetCargo());
            }
            else
            {
                var ch = port.GetCargo();
                sch = new CargoHandlerPort_SyncerVM(new CargoHandlerPort_ROVM(ch), port.PriceGetter, port.PriceGetter);
            }

            transaction.SetSyncherVM(sch);
        }