Пример #1
0
        public void DrawRangeRings(Canvas canvas)
        {
            /* RANGE RING LOGIC */
            float xpos = (SpriteArea.X + (SpriteArea.Width / 2));
            float ypos = (SpriteArea.Y + (SpriteArea.Height / 2) - (Scale * 50));
            float zpos = 0.0F;

            if (CurrentlySelectedSensor != string.Empty && CurrentlySelectedSensorRange > 0)
            {
                if (!IsSensorRingSet())
                {
                    SetSensorRingValues(CurrentlySelectedSensorRange, Color.FromArgb(DDD_RangeRings.GetInstance().SensorRangeRings.OpaqueRingColor), canvas, UTM_Mapping.HorizonalMetersPerPixel, UTM_Mapping.VerticalMetersPerPixel);
                }
                DrawSensorRangeRing(xpos, ypos, zpos, canvas);
            }
            if (CurrentlySelectedCapability != string.Empty && CurrentlySelectedCapabilityRange > 0)
            {
                if (!IsCapabilityRingSet())
                {
                    SetCapabilityRingValues(CurrentlySelectedCapabilityRange, Color.FromArgb(DDD_RangeRings.GetInstance().CapabilityRangeRings.OpaqueRingColor), canvas, UTM_Mapping.HorizonalMetersPerPixel, UTM_Mapping.VerticalMetersPerPixel);
                }
                DrawCapabilityRangeRing(xpos, ypos, zpos, canvas);
            }

            if (CurrentlySelectedVulnerability != string.Empty && CurrentlySelectedVulnerabilityRange > 0)
            {
                if (!IsVulnerabilityRingSet())
                {
                    SetVulnerabilityRingValues(CurrentlySelectedVulnerabilityRange, Color.FromArgb(DDD_RangeRings.GetInstance().VulnerabilityRangeRings.OpaqueRingColor), canvas, UTM_Mapping.HorizonalMetersPerPixel, UTM_Mapping.VerticalMetersPerPixel);
                }
                DrawVulnerabilityRangeRing(xpos, ypos, zpos, canvas);
            }

            /*       END        */
        }
Пример #2
0
        public static DDD_RangeRings GetInstance()
        {
            if (_instance == null)
            {
                _instance = new DDD_RangeRings();
                _instance.Reinitialize();
            }

            return(_instance);
        }
Пример #3
0
        public void LoadTextures(object obj)
        {
            string path = string.Empty;

            try
            {
                path = string.Format("{0}\\{1}.dll", DDD_Global.Instance.DDDClientShareFolder, DDD_Global.Instance.ImageLibrary);
                if (!File.Exists(path))
                {
                    path = string.Format(@"{0}\DDDClient\{1}.dll", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), DDD_Global.Instance.ImageLibrary);
                }
                ImageLib = Assembly.LoadFile(path);
            }
            catch (Exception e)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message   = "Missing Image Libary";
                    MsgColor  = Color.Red;
                    Thread.Sleep(2000);

                    throw new Exception(Message + ":" + path + ":" + e.Message);
                }
                return;
            }


            GameFramework g = (GameFramework)obj;
            GameTexture   _texture;
            List <string> names = new List <string>();


            try
            {
                StreamReader s = new StreamReader(ImageLib.GetManifestResourceStream("ImageLibrary.mf"));

                while (!s.EndOfStream)
                {
                    names.Add(s.ReadLine());
                }
                for (int i = 0; i < names.Count; i++)
                {
                    string[] texture_name = names[i].Split(':');
                    _texture        = g.CreateTexture(ImageLib.GetManifestResourceStream(texture_name[0]));
                    _texture.rotate = bool.Parse(texture_name[1]);
                    g.StoreTexture(texture_name[0], _texture);
                    lock (this)
                    {
                        Message = string.Format("Texture {0} of {1}", i + 1, names.Count);
                    }
                }
                s.Close();
            }
            catch (Exception)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message   = "Error loading texture";
                    MsgColor  = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.BACKGROUND;
            }

            bool        continue_looping = true;
            GameTexture Map;

            while (continue_looping)
            {
                if (DDD_Global.Instance.MapLocation != string.Empty)
                {
                    try
                    {
                        if (File.Exists(DDD_Global.Instance.MapLocation))
                        {
                            Map = g.CreateTexture(DDD_Global.Instance.MapLocation);
                        }
                        else
                        {
                            Map = g.CreateTexture(string.Format("{0}\\MapLib\\{1}", DDD_Global.Instance.DDDClientShareFolder, DDD_Global.Instance.MapName));
                        }
                        Controller.UTM_Mapping.ImageHeight = Map.height;
                        Controller.UTM_Mapping.ImageWidth  = Map.width;
                        g.StoreTexture("MAP", Map);
                        continue_looping = false;
                    }
                    catch (Exception)
                    {
                        SceneMode        = MODE.SCENE_ERROR;
                        Message          = "Map file missing: " + DDD_Global.Instance.MapName;
                        MsgColor         = Color.Red;
                        continue_looping = false;
                        Thread.Sleep(2000);

                        throw new Exception(Message);
                    }
                }
                else
                {
                    Thread.Sleep(2000);
                }
            }


            lock (this)
            {
                Stage = LoadingStage.FINISHED;
                DDD_RangeRings.SetCanvasPtr(GameFramework.Instance().CANVAS);
            }
        }
Пример #4
0
        public static DDD_RangeRings GetInstance()
        {
            if (_instance == null)
            {
                _instance = new DDD_RangeRings();
                _instance.Reinitialize();
            }

            return _instance;
        }