예제 #1
0
        /// <summary>
        /// Method for create a path between two objects that have X and Y coordinates
        /// </summary>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        private void CreateMissilePath(IScaleable begin, IScaleable end)
        {
            double distance = Math.Sqrt((Math.Pow(begin.PosX - end.PosX, 2) + Math.Pow(begin.PosY - end.PosY, 2)));

            int offset = (int)(Scaling.GetInstance().FactorX * 12); //Offset is depending on scaling!

            _hittedTarget = GetHittedRandomTarget(end.PosX, end.PosY, offset);

            offset *= (int)(distance * 0.01);       //Offset is now depending on distance and scaling!
            int last    = _path.Length - 1;
            int start   = last / 2;                 //Start with index of midpoint between start and goal
            int current = start;

            _path[0]    = new Point(begin.PosX, begin.PosY); //Set the starting point (index 0) in array
            _path[last] = _hittedTarget;                     //Set the target point (last index) in array

            while (start != 0)                               //Loop sets the rest of the points in array
            {
                //Make the current point to a midpoint between the closest defined points
                _path[current] = GetRandMidpoint(_path[current - start], _path[current + start], offset);

                current = current + 2 * start;      //Increase current index two times the start value

                if (current >= last)                //If the end of array is reached
                {
                    start   = start / 2;            //Set a new starting index
                    current = start;
                    offset  = offset / 4;
                }
            }
        }
예제 #2
0
 public static Scaling GetInstance()
 {
     if (instance == null)
     {
         instance = new Scaling();
     }
     return(instance);
 }
예제 #3
0
        public Ocean(string name, int x, int y)
        {
            _name = name;
            PosX  = x;
            PosY  = y;

            Scaling.GetInstance().Add(this);        //Adds every new object to scaling control
        }
예제 #4
0
        private void UpdateAllMapLabels()
        {
            Scaling.GetInstance().ApplyUserScaling(_orgFormSize.Width, Size.Width, _orgFormSize.Height, Size.Height);

            foreach (var item in Scaling.GetInstance().AllScalebleObjects())
            {
                UpdateMapLabel(item);
            }
        }
예제 #5
0
        public Nation(string name, int endurance, int x, int y)
        {
            _name = name;
            _endurance = endurance;
            _shots = 0;
            _kills = 0;
            PosX = x;
            PosY = y;

            Scaling.GetInstance().Add(this);        //Adds every new object to scaling control
        }
예제 #6
0
        private void DrawHittedTarget()
        {
            int      offset = (int)(Scaling.GetInstance().FactorX * 12);
            Pen      myPen;
            Graphics fg = CreateGraphics();

            fg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //Added for extra quality!
            myPen            = new Pen(Color.OrangeRed, 2);
            fg.DrawEllipse(myPen, _hittedTarget.X - offset / 4, _hittedTarget.Y - offset / 8, offset / 2, offset / 4);
            myPen = new Pen(Color.Yellow, 1);
            fg.DrawEllipse(myPen, _hittedTarget.X - offset / 2, _hittedTarget.Y - offset / 4, offset, offset / 2);
            fg.Dispose();
        }
예제 #7
0
        private void playButton_Click(object sender, EventArgs e)
        {
            startGroupBox.Visible      = false;
            startAndStopButton.Enabled = true;
            FormResizeAllowed(true);

            _ww3 = new War(_startEndurance);
            UpDateStatsList(_ww3.GetSortedList());

            foreach (var item in Scaling.GetInstance().AllScalebleObjects())
            {
                CreateMapLabel(item);
            }

            UpdateAllMapLabels();
        }