コード例 #1
0
        /// <summary>Must be called before show form</summary>
        public virtual void Prepare()
        {
            if (SurfaceImage == null)
            {
                SurfaceImage = Screenshot.CaptureFullscreen();
            }

            if (Config.UseDimming)
            {
                /*
                 * using (Image darkSurfaceImage = ColorMatrixManager.Contrast(0.9f).Apply(SurfaceImage))
                 * {
                 *  darkBackgroundBrush = new TextureBrush(darkSurfaceImage) { WrapMode = WrapMode.Clamp };
                 * }
                 *
                 * using (Image lightSurfaceImage = ColorMatrixManager.Contrast(1.1f).Apply(SurfaceImage))
                 * {
                 *  lightBackgroundBrush = new TextureBrush(lightSurfaceImage) { WrapMode = WrapMode.Clamp };
                 * }
                 */

                using (Bitmap darkBackground = (Bitmap)SurfaceImage.Clone())
                    using (Graphics g = Graphics.FromImage(darkBackground))
                    {
                        using (Brush brush = new SolidBrush(Color.FromArgb(50, Color.Black)))
                        {
                            g.FillRectangle(brush, 0, 0, darkBackground.Width, darkBackground.Height);
                        }

                        darkBackgroundBrush = new TextureBrush(darkBackground)
                        {
                            WrapMode = WrapMode.Clamp
                        };
                        lightBackgroundBrush = new TextureBrush(SurfaceImage)
                        {
                            WrapMode = WrapMode.Clamp
                        };
                    }
            }
            else
            {
                darkBackgroundBrush = new TextureBrush(SurfaceImage)
                {
                    WrapMode = WrapMode.Clamp
                };
            }
        }
コード例 #2
0
        /// <summary>
        /// Cleanup when layer is disabled
        /// </summary>
        public override void Dispose()
        {
            this.Inited = false;

            if (downloadThread != null)
            {
                if (downloadThread.IsAlive)
                {
                    downloadThread.Abort();
                }
                downloadThread = null;
            }

            if (m_SurfaceImage != null)
            {
                m_ParentWorld.WorldSurfaceRenderer.RemoveSurfaceImage(m_SurfaceImage.ImageFilePath);
                m_SurfaceImage = null;
            }
            if (this.texture != null)
            {
                this.texture.Dispose();
                this.texture = null;
            }

            if (legendControl != null)
            {
                legendControl.Dispose();
                legendControl = null;
            }

            if (refreshTimer != null &&
                refreshTimer.Enabled)
            {
                refreshTimer.Stop();
                refreshTimer = null;
            }
        }
コード例 #3
0
ファイル: ImageLayer.cs プロジェクト: jpespartero/WorldWind
		/// <summary>
		/// Cleanup when layer is disabled
		/// </summary>
		public override void Dispose()
		{
			this.isInitialized = false;

			if(downloadThread != null)
			{
				if(downloadThread.IsAlive)
				{
					downloadThread.Abort();
				}
				downloadThread = null;
			}

			if(m_SurfaceImage != null)
			{
				m_ParentWorld.WorldSurfaceRenderer.RemoveSurfaceImage(m_SurfaceImage.ImageFilePath);
				m_SurfaceImage = null;
			}
			if (this.texture!=null)
			{
				this.texture.Dispose();
				this.texture = null;
			}

			if(legendControl != null)
			{
				legendControl.Dispose();
				legendControl = null;
			}

			if(refreshTimer != null && refreshTimer.Enabled)
			{
				refreshTimer.Stop();
				refreshTimer = null;
			}
		}
コード例 #4
0
        //public SpaceGame.Game Socket;


        private Core(bool loadData = true, DataConnector connector = null)
        {
            if (connector == null)
            {
                dataConnection = new SpacegameServer.DataConnectors.SqlConnector();
            }
            else
            {
                dataConnection = connector;
            }

            writeToLog("Starting");

            InfluenceManager.InitInfluenceRings();

            identities.shipLock         = new IdentityNumbers();
            identities.templateLock     = new IdentityNumbers();
            identities.colonyId         = new IdentityNumbers();
            identities.colonyBuildingId = new IdentityNumbers();
            identities.planetSurfaceId  = new IdentityNumbers();
            identities.allianceId       = new IdentityNumbers();
            identities.commNode         = new IdentityNumbers();
            identities.commNodeMessage  = new IdentityNumbers();
            identities.message          = new IdentityNumbers();
            identities.combat           = new IdentityNumbers();
            identities.galacticEvents   = new IdentityNumbers();
            identities.trades           = new IdentityNumbers();
            identities.routes           = new IdentityNumbers();
            identities.chat             = new IdentityNumbers();

            //fill the regions array with (yet empty) regions
            //ToDo: this leads to a maximum siz of the world. Units should not leave the area...
            GeometryIndex.createIndex();



            //RULES
            //int ObjectDescriptionsSize = 20000;

            int GoodsSize         = 10000;
            int BuildingsSize     = 10000;
            int ModuleSize        = 5000;
            int SurfaceImagesSize = 50; //TODO
            int ShipHullsSize     = 230;
            //int ShipHullsImagesSize = 100;
            int QuestSize     = 1000;
            int ResearchsSize = 10000;

            //int SpecializationGroupSize = 10;

            int ResearchQuestPrerequisitesSize = 500;
            int SurfaceTilesSize = 30;

            int languageSize = 8;

            //MAP
            //int StarMapSize = 100000;
            //int SolarSystemInstanceSize = 1000000;
            //int PlanetSurfaceSize = 1000000;


            //USERS
            //int UserSize = 1000;
            //int ShipTemplateSize = UserSize * 1000;
            //int ShipSize = UserSize * 100;
            //int ColonySize = UserSize * 10;
            //int ColonyBuildingSize = ColonySize * 100;
            NodeQuadTree.BoundarySouthWest boundarySouthWest    = new NodeQuadTree.BoundarySouthWest(4096, 4096);
            NodeQuadTree.Bounding          NodeQuadTreeBounding = new NodeQuadTree.Bounding(boundarySouthWest, 2048);
            nodeQuadTree = new NodeQuadTree.NodeQuadTree(NodeQuadTreeBounding);

            //RULES
            ObjectDescriptions       = new Dictionary <int, ObjectDescription>(); //[ObjectDescriptionsSize];
            ObjectsOnMap             = new Dictionary <short, ObjectOnMap>();
            ObjectWeaponModificators = new Dictionary <short, Dictionary <short, ObjectWeaponModificator> >();

            Goods           = new Good[GoodsSize];
            Buildings       = new Building[BuildingsSize];
            PlanetTypes     = new List <PlanetType>(10);
            Modules         = new Module[ModuleSize];
            ShipHulls       = new ShipHull[ShipHullsSize];
            ShipHullsImages = new List <ShipHullsImage>();
            Quests          = new Quest[QuestSize];
            Researchs       = new Research[ResearchsSize];
            ResearchGains   = new List <ResearchGain>();

            SpecializationGroups = new List <SpecializationGroup>();

            ResearchQuestPrerequisites = new List <ResearchQuestPrerequisite>(ResearchQuestPrerequisitesSize);
            SurfaceImages      = new SurfaceImage[SurfaceImagesSize];
            SurfaceTiles       = new SurfaceTile[SurfaceTilesSize];
            BuildOptions       = new List <BuildOption>();
            objectRelations    = new List <ResearchQuestPrerequisite>(1000);
            surfaceDefaultMaps = new List <SurfaceDefaultMap>(3000);

            TurnEvaluations = new List <TurnEvaluation>(1000);

            languages = new Language[languageSize];
            //SurfaceImages = new SurfaceImages
            //MAP
            stars         = new Dictionary <int, SystemMap>();           // StarMap[StarMapSize];
            planets       = new Dictionary <int, SolarSystemInstance>(); //[SolarSystemInstanceSize];
            planetSurface = new Dictionary <long, PlanetSurface>();      // [PlanetSurfaceSize];

            //USERS
            users = new ConcurrentDictionary <int, User>();                     // [UserSize];

            shipTemplate    = new ConcurrentDictionary <int, ShipTemplate>();   // ShipTemplate[ShipTemplateSize];
            ships           = new ConcurrentDictionary <int, Ship>();           //Ship[ShipSize];
            colonies        = new ConcurrentDictionary <int, Colony>();         //Colony[ColonySize];
            colonyBuildings = new ConcurrentDictionary <int, ColonyBuilding>(); //ColonyBuilding[ColonyBuildingSize];

            alliances          = new ConcurrentDictionary <int, Alliance>();
            invitesPerAlliance = new ConcurrentDictionary <int, List <int> >();
            invitesPerUser     = new ConcurrentDictionary <int, List <int> >();

            tradeOffer = new ConcurrentDictionary <int, TradeOffer>();
            routes     = new ConcurrentDictionary <int, Route>();
            chatLog    = new ConcurrentDictionary <int, ChatLog>();

            userRelations = new UserRelations();

            labels     = new List <Label>();
            shipRefits = new List <shipRefit>();

            commNodes      = new ConcurrentDictionary <int, CommunicationNode>();
            messages       = new ConcurrentDictionary <int, MessageHead>();
            combats        = new ConcurrentDictionary <int, Combat>();
            galactivEvents = new ConcurrentDictionary <int, GalacticEvents>();

            //read all data
            if (loadData)
            {
                dataConnection.loadData(this);
            }

            /*
             * (new TurnSummary(this)).researchSpread(this); //Todo - remove, save to db after turn summary, restore from db when getAll(_core); is called
             * (new TurnSummary(this)).CalcGalaxyOwnership();
             *
             *
             * //update data in all ships
             * foreach (var ship in this.ships.Values)
             * {
             *  var clone = ship.clone();
             *  SpacegameServer.Core.StatisticsCalculator.calc(clone, this);
             *  ship.CombatMaxHitpoint = clone.hitpoints;
             *  ship.CombatStartHitpoint = ship.hitpoints;
             * }
             *
             *
             * //TODO
             * if (identities.shipLock.id == -1) identities.shipLock.id = 1000; //ToDo: F***ing ugly stupid and not even really functioning workaround, :ToDo : 1000 is a really bad workaround, because ships and colonies will sometimes (for example during trading) be stored in the same array as spaceobjects...
             *
             *
             * createTurnTimer();
             */
        }