Example #1
0
        /// <summary>
        /// Creates and registers a colony and all associated structures. Links colony to planet appropriately.
        /// </summary>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="owner"></param>
        /// <param name="area"></param>
        /// <param name="ls"></param>
        /// <returns></returns>
        public static Colony CreateColony(float xPos, float yPos, Player owner, Planet planet, LocatorService ls)
        {
            Colony c = new Colony(_localIDManager.PopFreeID(), owner, planet, ls);

            c.Name = "Colony " + planet.AreaName;
            c.AddStructure(StructureFactory.CreateCommandCenter(xPos, yPos, owner, planet.Id));
            Biodome b = StructureFactory.CreateBiodome(-9999999, -9999999, owner, planet.Id);

            c.AddStructure(b);
            b.Stats      = new SmallBiodomeStats();
            b.Population = 10;


            _galaxyRegistrationManager.RegisterObject(c);

            planet.SetColony(c);
            planet.GetOwner().ColonizedPlanetIDs.Add(planet.Id);
            planet.IsColonized = true;
            planet.AddStructure(c.CommandCenter);
            planet.AddStructure(b);



            return(c);
        }
        /// <summary>
        /// Creates a structure
        /// </summary>
        /// <param name="type"></param>
        /// <param name="health"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="owner"></param>
        /// <param name="commandCenter"></param>
        /// <returns></returns>
        public static IStructure CreateStructure(StructureTypes type, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl)
        {
            IStructure s;

            switch (type)
            {
            case (StructureTypes.LaserTurret):
                s = new Turret(_localIDManager.PopFreeID(), xPos, yPos, owner, commandCenter, currentAreaID, pl);
                break;

            case (StructureTypes.Biodome):
                s = new Biodome(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID);
                break;

            case (StructureTypes.PowerPlant):
                s = new PowerPlant(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID);
                break;

            case (StructureTypes.Silo):
                s = new Silo(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID);
                break;


            default:
                throw new Exception("CreateStructure not implemented for structure type " + type.ToString());
            }
            _galaxyRegistrationManager.RegisterObject(s);

            return(s);
        }
        public static Biodome CreateBiodome(float xPos, float yPos, Player owner, int currentAreaID)
        {
            Biodome b = new Biodome(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID);

            _galaxyRegistrationManager.RegisterObject(b);
            return(b);
        }
Example #4
0
        // Need to find a better place for this...
        public static IStructure InstantiateStructure(IStructureModel sm, IPlayerLocator pl, IGalaxyRegistrationManager gm)
        {
            IStructure s;

            switch (sm.StructureType)
            {
            case (StructureTypes.LaserTurret):
                s = new Turret((TurretModel)sm, pl);
                break;

            case (StructureTypes.Biodome):
                s = new Biodome((BiodomeModel)sm);
                break;

            case (StructureTypes.PowerPlant):
                s = new PowerPlant((PowerPlantModel)sm);
                break;

            case (StructureTypes.Silo):
                s = new Silo((SiloModel)sm);
                break;

            case (StructureTypes.CommandCenter):
                return(new CommandCenter((CommandCenterModel)sm));

            case (StructureTypes.Factory):
                s = new Factory((FactoryModel)sm);
                break;

            case StructureTypes.Refinery:
                s = new Refinery((RefineryModel)sm);
                break;

            case StructureTypes.Mine:
                s = new MineStructure((MineModel)sm);
                break;

            case StructureTypes.DefensiveMine:
                s = new DefensiveMine((DefensiveMineModel)sm, pl);
                break;

            case StructureTypes.ConstructionBuilding:
                s = new ConstructionBuilding((ConstructionBuildingModel)sm);
                break;

            default:
                throw new Exception("CreateStructure not implemented for structure type " + sm.StructureType.ToString());
            }
            gm.RegisterObject(s);


            return(s);
        }