Inheritance: MonoBehaviour
Beispiel #1
0
        private static Points RotateY(Points points, double sinDeg, double cosDeg)
        {
            double _x = (points.x * cosDeg) + (points.z * sinDeg);
            double _z = (points.x * -sinDeg) + (points.z * cosDeg);

            return new Points(_x, points.y, _z);
        }
Beispiel #2
0
        private static Points RotateX(Points points, double sinDeg, double cosDeg)
        {
            double _y = (points.y * cosDeg) + (points.z * sinDeg);
            double _z = (points.y * -sinDeg) + (points.z * cosDeg);

            return new Points(points.x, _y, _z);
        }
Beispiel #3
0
        private static Points RotateZ(Points points, double sinDeg, double cosDeg)
        {
            double _x = (points.x * cosDeg) + (points.y * sinDeg);
            double _y = (points.x * -sinDeg) + (points.y * cosDeg);

            return new Points(_x, _y, points.z);
        }
Beispiel #4
0
 private static Vector2 FindPosition(Rectangle area, Points point)
 {
     switch (point)
     {
         case Points.Left:
             return new Vector2(area.Left, area.Top + (area.Height / 2));
         case Points.Right:
             return new Vector2(area.Right, area.Top + (area.Height / 2));
         case Points.Top:
             return new Vector2(area.Left + (area.Width / 2), area.Top);
         case Points.Bottom:
             return new Vector2(area.Left + (area.Width / 2), area.Bottom);
         case Points.Centre:
             return new Vector2(area.Center.X, area.Center.Y);
         case Points.TopLeft:
             return new Vector2(area.X, area.Y);
         case Points.TopRight:
             return new Vector2(area.X + area.Width, area.Y);
         case Points.BottomLeft:
             return new Vector2(area.X, area.Y + area.Height);
         case Points.BottomRight:
             return new Vector2(area.X + area.Width, area.Y + area.Height);
         default:
             return Vector2.Zero;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public HeatmapPlotValue()
 {
     data = new Points<HeatPoint>();
     points.Add(data);
     ColorPalette = ColorPalettes.Hot;
     XLabel = "Column";
     YLabel = "Row";
 }
Beispiel #6
0
 public void Init(Gamefield gamefield)
 {
     this.Gamefield = gamefield;
     PointSystem = Gamefield.PointSystem;
     Reset();
     OnDestroy();
     OnInit();
     InvokeTurnsChanged();
 }
Beispiel #7
0
 public static Points[,] RotateZ(Points[,] points, double deg)
 {
     double radDeg = (Math.PI * deg) / 180.0;
     double cosDeg = Math.Cos(radDeg);
     double sinDeg = Math.Sin(radDeg);
     for (int i = 0; i < points.GetLength(0); i++)
         for (int j = 0; j < points.GetLength(1); j++)
             points[i, j] = RotateZ(points[i, j], sinDeg, cosDeg);
     return points;
 }
Beispiel #8
0
        public void Apply(ref ControlArea area, Rectangle parentArea, Points anchoredPoints)
        {
            if (AnchorControl != null)
                parentArea = AnchorControl.Area;

            Vector2 pointOnSelf = FindPosition(area.ToRectangle(), Start);
            Vector2 pointOnParent = FindPosition(parentArea, End);

            TranslateArea(ref area, pointOnParent - pointOnSelf + Offset, anchoredPoints);
        }
Beispiel #9
0
 public static Points[,] Perspective(Points[,] points)
 {
     const double Zk = 200;
     const double Zpl = 10;
     for (int i = 0; i < points.GetLength(0); i++)
         for (int j = 0; j < points.GetLength(1); j++)
         {
             double perspective = (Zk - Zpl) / (Zk - points[i, j].z);
             points[i, j] = new Points(points[i, j].x * perspective, points[i, j].y * perspective, points[i, j].z - Zpl);
         }
     return points;
 }
Beispiel #10
0
    public void ShowPoints(Points points)
    {
        var hub = GameObject.Find("PrefabHub").GetComponent<PrefabHub>();
        _ten = hub.PointTextures[0];
        _twentyFive = hub.PointTextures[1];
        _fifty = hub.PointTextures[2];
        _mulTwo = hub.PointTextures[3];
        _mulFive = hub.PointTextures[4];
        _mulTen = hub.PointTextures[5];
        PowerUpPrefab = hub.PowerUpPrefab;

        var pu =
            (GameObject)
                GameObject.Instantiate(PowerUpPrefab,
                    PointGiverObject.transform.position +
                    new Vector3(Random.Range(-4.0f, 4.0f), Random.Range(-4.0f, 4.0f) + 2.0f, Random.Range(-4.0f, 4.0f)),
                    Quaternion.Euler(27.33f, 226.9f, 0.0f));
        float scale = 1.0f;
        switch (points)
        {
            case Points.Ten:
                scale = Random.Range (0.7f, 1.3f);
                pu.GetComponent<PowerUpSprite>().UiTexture = _ten;

                break;
            case Points.TwentyFive:
                pu.GetComponent<PowerUpSprite>().UiTexture = _twentyFive;
            scale = Random.Range (0.7f, 1.3f);
                break;
            case Points.Fifty:
                pu.GetComponent<PowerUpSprite>().UiTexture = _fifty;
            scale = Random.Range (0.7f, 1.3f);
                break;
            case Points.MulTwo:
                pu.GetComponent<PowerUpSprite>().UiTexture = _mulTwo;
            scale = Random.Range (1.7f, 2.3f);
                break;
            case Points.MulFive:
                pu.GetComponent<PowerUpSprite>().UiTexture = _mulFive;
            scale = Random.Range (1.7f, 2.3f);
                break;
            case Points.MulTen:
                pu.GetComponent<PowerUpSprite>().UiTexture = _mulTen;
            scale = Random.Range (1.7f, 2.3f);;
                break;
            default:
                pu.GetComponent<PowerUpSprite>().UiTexture = _ten;
                break;
        }
        pu.transform.localScale = new Vector3(scale, scale, scale);
    }
Beispiel #11
0
 /// <summary>
 /// Creates a new SurfacePlot.
 /// </summary>
 public SurfacePlotValue()
 {
     data = new Points<Vertex>();
     ColorPalette = ColorPalettes.Jet;
     XLabel = "X";
     YLabel = "Y";
     ZLabel = "Z";
     points.Add(data);
     IsMesh = false;
     IsSurf = true;
     MeshThickness = 1.0;
     Color = "#444444";
     ShowLegend = false;
 }
Beispiel #12
0
        public Points GetAlternativeWaySegments(Car car)
        {
            var result = new Points();
            var myCell = GetCell(car.X, car.Y);
            result.Add(new Point(car));
            Cell prevCell = null;

            var passedWayPoints = new List<Cell>();

            for (var e = 1; result.Count < 5; e++)
            {
                var nextWp = GetNextWayPoint(car, e);
                for (var curCell = myCell; !curCell.Equals(nextWp); )
                {
                    var nextCell = DijkstraNextCell(curCell, nextWp, prevCell == null ? new Cell[] { } : new[] { prevCell });
                    var nextCenter = GetCenter(nextCell);
                    for (var i = 0; i < result.Count; i++)
                    {
                        if (CheckVisibilityAndWp(car, result[i], nextCenter, passedWayPoints))
                        {
                            result.RemoveRange(i + 1, result.Count - i - 1);
                            break;
                        }
                    }
                    result.Add(nextCenter);
                    prevCell = curCell;
                    curCell = nextCell;
                }
                myCell = nextWp;
                passedWayPoints.Add(nextWp);
            }
            var extended = ExtendWaySegments(result, 100);
            result.Clear();

            passedWayPoints.Clear();
            foreach (var t in extended)
            {
                if (result.Count > 0 && result.Last().Equals(t))
                    continue;
                if (GetNextWayPoint(car).Equals(GetCell(t)))
                    passedWayPoints.Add(GetCell(t));

                while (result.Count > 1 && CheckVisibilityAndWp(car, result[result.Count - 2], t, passedWayPoints))
                    result.Pop();
                result.Add(t);
            }
            return result;
        }
Beispiel #13
0
	// Use this for initialization
	void Awake () {
        playerPoints = new ArrayList();
        fileWay = Application.persistentDataPath + "/points.dat";
        medicFileWay = Application.persistentDataPath + "/MedicData.txt";
        Debug.Log(medicFileWay);

        #region "Singleton method"
        if (stateGame == null)
        {
            stateGame = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
        #endregion
    }
Beispiel #14
0
        private void TranslateArea(ref ControlArea area, Vector2 translation, Points anchoredPoints)
        {
            // an anchor can move a side if it has direct control of that side
            // or it can move the opposite side is that one has no direct anchors
            // or it can move both of the other 2 sides if neither of those have direct anchors.

            var leftOrRightAnchored = EitherSelected(anchoredPoints, Points.Left, Points.Right);
            var topOrBottomAnchored = EitherSelected(anchoredPoints, Points.Top, Points.Bottom);

            // left and right
            if (Start.Selected(Points.Left) || (Start.Selected(Points.Right) && !anchoredPoints.Selected(Points.Left)) || !leftOrRightAnchored)
                area.Left += (int)translation.X;
            if (Start.Selected(Points.Right) || (Start.Selected(Points.Left) && !anchoredPoints.Selected(Points.Right)) || !leftOrRightAnchored)
                area.Right += (int)translation.X;

            // top and bottom
            if (Start.Selected(Points.Top) || (Start.Selected(Points.Bottom) && !anchoredPoints.Selected(Points.Top)) || !topOrBottomAnchored)
                area.Top += (int)translation.Y;
            if (Start.Selected(Points.Bottom) || (Start.Selected(Points.Top) && !anchoredPoints.Selected(Points.Bottom)) || !topOrBottomAnchored)
                area.Bottom += (int)translation.Y;
        }
		private float GetPoints(string teamToCheck, Points pointsToAdd, IEnumerable<GameDto> gameDtos)
		{
			var result = .0f;
			var streak = 0;
			var games = gameDtos.OrderByDescending(g => g.Date).Take(GameCount).ToArray();

			// Check if enough data exists
			if (games.Length < GameCount)
			{
				throw new LogicException("Not enough games for both teams");
			}

			foreach (var game in games)
			{
				var scoreToCheck = string.Equals(game.Team1, teamToCheck, StringComparison.CurrentCultureIgnoreCase)
					? game.Score1
					: game.Score2;
				var scoreToCheckAgainst = string.Equals(game.Team2, teamToCheck, StringComparison.CurrentCultureIgnoreCase)
					? game.Score1
					: game.Score2;

				// Team won a single game
				if (scoreToCheck > scoreToCheckAgainst)
				{
					// Add winning game
					result += pointsToAdd.Victory;
					streak += 1;
				}
				// Team lost a single game
				else
				{
					// Add winning streak
					result += streak*pointsToAdd.Streak;
					streak = 0;
				}
			}

			// Add remaining streaks
			return result + streak*pointsToAdd.Streak;
		}
Beispiel #16
0
        public unsafe void Read(Action <Points> callback)
        {
            using (MemoryStream FS = new MemoryStream(System.IO.File.ReadAllBytes(File)))
            //using (System.IO.FileStream FS = new System.IO.FileStream(File, System.IO.FileMode.Open, System.IO.FileAccess.Read,System.IO.FileShare.Read,8192,System.IO.FileOptions.SequentialScan))
            {
                int FooterPOS = (int)FS.Length - 32;
                FS.Position = FooterPOS;
                BinaryReader RD = new BinaryReader(FS);

                DateTime StartTime      = TimeTag.Convert(RD.ReadDouble());
                DateTime EndTime        = TimeTag.Convert(RD.ReadDouble());
                int      PointsReceived = RD.ReadInt32();
                int      PointsArchived = RD.ReadInt32();
                int      DataBlockSize  = RD.ReadInt32();
                int      DataBlockCount = RD.ReadInt32();

                int FATPos = FooterPOS - 10 - 12 * DataBlockCount;
                FS.Position = FATPos;

                List <Blocks> Blocks = new List <Blocks>(DataBlockCount);
                byte[]        Header = RD.ReadBytes(10);

                Blocks B = default(Blocks);
                for (int x = 1; x <= DataBlockCount; x++)
                {
                    B.BlockID = RD.ReadInt32();
                    B.Time    = TimeTag.Convert(RD.ReadDouble());
                    Blocks.Add(B);
                }

                FS.Position = 0;
                Points P       = default(Points);
                int    NextPos = DataBlockSize * 1024;

                byte[] Buffer = new byte[DataBlockSize * 1024];

                fixed(byte *lp = Buffer)
                {
                    foreach (Blocks BK in Blocks)
                    {
                        FS.Read(Buffer, 0, DataBlockSize * 1024);
                        int pos = 0;
                        while (pos < DataBlockSize * 1024 - 9)
                        {
                            int   I = *(int *)(lp + pos);
                            short S = *(short *)(lp + pos + 4);
                            float V = *(float *)(lp + pos + 6);
                            pos += 10;

                            long TimeDiff = I * 1000L + (S >> 5);
                            if (TimeDiff != 0)
                            {
                                P.Time    = TimeTag.Convert(TimeDiff);
                                P.Value   = V;
                                P.PointID = BK.BlockID;
                                callback(P);
                            }
                        }
                        //FS.Position = NextPos;
                        NextPos += DataBlockSize * 1024;
                    }
                    return;
                }
            }
        }
Beispiel #17
0
 public static void AssertDesiredSize(this IControl control, string name, Points width, Points height)
 {
     Assert.AreEqual(width, control.DesiredSize.Width.FirstAsync().ToTask().GetResultAndUnpackExceptions(), name.Capitalize() + " has wrong desired width");
     Assert.AreEqual(height, control.DesiredSize.Height.FirstAsync().ToTask().GetResultAndUnpackExceptions(), name.Capitalize() + " has wrong desired height");
 }
        public override string ToString()
        {
            var pts = string.Join(",", Points.Select(p => String.Format("({0},{1})", p.X, p.Y)).ToArray());

            return(String.Format("{0} - {1}", Type.ToString(), pts));
        }
Beispiel #19
0
        } = 240;                                   //Thời gian kết thúc, sau sẽ được truyện vào từ Terminate

        //Method sinh Cus
        public IEnumerator <Task> Generator(Process p, object data)
        {
            Console.WriteLine(this.Now + @" The barber shop is opening for business...");
            //Resource barbers = CreateBarbers();
            ABarbers = Resource.Create(new List <Barber>()
            {
                new Barber(this, "Minh"), new Barber(this, "Anh")
            });
            int i = 0;

            switch (TypeDistribuion)
            {
            case Distribution.NormalDis:
                TypeDis = new Normal(Interval, 1.0);
                break;

            case Distribution.ExponentialDis:
                TypeDis = new Exponential(Interval);
                break;

            default:
                Console.WriteLine("k tim thay");
                break;
            }

            do
            {
                long d;
                do
                {
                    d = (long)TypeDis.NextDouble();
                } while (d <= 0L);
                if (FirstTime != 0 && Now == 0)
                {
                    yield return(p.Delay(FirstTime));

                    i++;
                    //Console.WriteLine(@"xxx         so Cus trong hang doi = " + ABarbers.BlockCount + " " + Now);
                    Customer c = new Customer(this, i.ToString(), this.Now, QueueCapacity);
                    c.Activate(null, 0L, ABarbers);
                    Console.WriteLine(this.Now + " The customer " + c.Name + " come");
                }
                else
                {
                    yield return(p.Delay(d));

                    Console.WriteLine(@"xxx         BlockCount - " + ABarbers.BlockCount + "- OutOfService - " + ABarbers.OutOfService + "- Reserved - " + ABarbers.Reserved + "- Now - " + Now);
                    i++;
                    Customer c = new Customer(this, i.ToString(), this.Now, QueueCapacity);
                    c.Activate(null, 0L, ABarbers);
                    Console.WriteLine(this.Now + " The customer " + c.Name + " come");
                    Console.WriteLine(@"yyy         BlockCount - " + ABarbers.BlockCount + "- OutOfService - " + ABarbers.OutOfService + "- Reserved - " + ABarbers.Reserved + "- Now - " + Now);
                    //point = new Point(Now, ABarbers.BlockCount);
                    Points.Add(new Point(Now, ABarbers.BlockCount));
                }
            } while (Now < EndingTime && i < LengthOfFile);

            Console.WriteLine(@"======================================================");
            Console.WriteLine(@"The barber shop is closed for the day.");

            if (ABarbers.BlockCount > 0)
            {
                Console.WriteLine(@"The barbers have to work late today.");
            }

            yield break;
        }
Beispiel #20
0
        protected override async void Start()
        {
            base.Start();

            // 3D scene with Octree
            var scene = new Scene(Context);

            octree = scene.CreateComponent <Octree>();

            // Camera
            var cameraNode = scene.CreateChild();

            cameraNode.Position = new Vector3(0, size * 2, size);
            camera = cameraNode.CreateComponent <Camera>();
            cameraNode.LookAt(Vector3.Zero, Vector3.Up);

            // Light
            Node lightNode = cameraNode.CreateChild();
            var  light     = lightNode.CreateComponent <Light>();

            light.LightType  = LightType.Point;
            light.Range      = size * size;
            light.Brightness = 1.3f;

            // Viewport
            var viewport = new Viewport(Context, scene, camera);

            Renderer.SetViewport(0, viewport);

            plotNode = scene.CreateChild();

            if (!(Points is null))
            {
                int   quantity = Convert.ToInt32(Math.Sqrt(Points.Count));
                float step     = size / Convert.ToSingle(quantity);

                double max   = Points.Select(Mapping).Max();
                double min   = Points.Select(Mapping).Min();
                double range = (max - min) / 6;

                if (range > 0)
                {
                    double doubleRange = range * 2;
                    double tripleRange = range * 3;
                    double fiveRange   = range * 5;

                    foreach (threeDimensionalPointDTO point in Points)
                    {
                        Color color = Color.Black;

                        double value = Mapping.Invoke(point) - min;

                        switch (Math.Floor(value / range))
                        {
                        case -1:
                        case 0:
                            color = new Color(Convert.ToSingle(value / range), Convert.ToSingle(value / range), 1);
                            break;

                        case 1:
                            color = new Color(Convert.ToSingle((doubleRange - value) / range), 1, 1);
                            break;

                        case 2:
                            color = new Color(0, 1, Convert.ToSingle((tripleRange - value) / range));
                            break;

                        case 3:
                            color = new Color(Convert.ToSingle((value - tripleRange) / range), 1, 0);
                            break;

                        case 4:
                            color = new Color(1, Convert.ToSingle((fiveRange - value) / range), 0);
                            break;

                        default:
                            color = new Color(1, 0, Convert.ToSingle((value - fiveRange) / range));
                            break;
                        }
                        var boxNode = plotNode.CreateChild();
                        boxNode.Position = new Vector3(Convert.ToSingle(point.x * step), 0, Convert.ToSingle(-point.y * step));
                        var box = new Bar(step, color);
                        boxNode.AddComponent(box);
                        box.Value = Convert.ToSingle(value);
                    }
                }
            }

            await plotNode.RunActionsAsync(new EaseBackOut(new RotateBy(2f, 0, 360, 0)));
        }
Beispiel #21
0
 public override IEnumerable <Vertex> GetIndexedVertices()
 {
     return(Points.OfType <DisplacementPoint>().Select(x => x.CurrentPosition));
 }
Beispiel #22
0
 public static T Points <T>(this T polyLineSegment, Points value) where T : IPolyLineSegment
 {
     polyLineSegment.Points = value;
     return(polyLineSegment);
 }
Beispiel #23
0
        public static void DrawWay(Car self, Moves stack, Brush brush, double width)
        {
            if (stack == null)
                return;

            var pts = new Points();
            pts.AddRange(MyStrategy.GetCarPath(self, stack).Select(car => new Point(car)));

            SegmentsDrawQueue.Add(new object[]
            {
                brush,
                pts,
                width
            });
        }
Beispiel #24
0
        public static List <MWPoint2D> OrderInDistance(List <MWPoint2D> pts)
        {
            List <MWPoint2D> lpts = pts;
            MWPoint2D        pt   = lpts.First(p => p.X == lpts.Max(v => v.X));
            List <MWPoint2D> res  = new List <MWPoint2D> {
                pt
            };

            lpts.Remove(pt);
            while (lpts.Count > 0)
            {
                MWPoint2D p0 = lpts.Aggregate(lpts[0], (closest, next) =>
                                              Points.Distance(res[res.Count - 1], next) < Points.Distance(res[res.Count - 1], closest) ? next : closest);
                res.Add(p0);
                lpts.Remove(p0);
            }
            return(res);
        }
Beispiel #25
0
        protected override IEnumerator<Task> GetProcessSteps()
        {
            Resource barbers = (Resource)ActivationData;
            //NewResource barbers = (NewResource)ActivationData;
            Console.WriteLine("M         so Cus trong hang doi = " + barbers.BlockCount + " " + Now);
            //if (barbers.BlockCount < QueueCapacity)//max so Cus trong hang doi
            //{

            //    yield return barbers.Acquire(this);//?o?n n?y s? nh?y sang Barber ?? th?c hi?n, khi th?c hi?n xong s? nh?y v? 2//Sau doan nay Cus se luu vao hang doi
            //}
            //else
            //{
            //    yield break;
            //}

            if (barbers.BlockCount < Condition)//max so Cus trong hang doi
            {
                yield break;

            }
            else
            {               
                yield return barbers.Acquire(this);//?o?n n?y s? nh?y sang Barber ?? th?c hi?n, khi th?c hi?n xong s? nh?y v? 2//Sau doan nay Cus se luu vao hang doi
            }


            System.Diagnostics.Debug.Assert(barbers == Activator);
            System.Diagnostics.Debug.Assert(ActivationData != null);
            Barber barber = (Barber)ActivationData;
            Points.Add(new Point(Now, barber.BlockCount));
            Console.WriteLine("H  H      so Cus trong hang doi = " + barbers.BlockCount + " " + Now);

            TimeIn = this.Now;
            Console.WriteLine(this.Now + " ? " + barber.Name + " begins cutting hair of customer " + this.Name);

            WaitOnTask(barber);
            yield return Suspend();
            // HINT: The above two lines of code can be shortened to
            //          yield return barber;

            Console.WriteLine("NN  NN    so Cus trong hang doi = " + barbers.BlockCount + " " + Now);

            TimeOut = this.Now;
            Console.WriteLine(this.Now + " x Customer " + Name + " pays {0} for the haircut.",
                barber.Name);
            Console.WriteLine($"thoi gian trong hang doi {TimeIn - this.TimeCome}" +
                              $" --- thoi gian trong he thong {TimeOut - this.TimeCome}");

            yield return barbers.Release(this);//giai phong bo nho

            //Resource barbers = (Resource)ActivationData;
            //yield return barbers.Acquire(this);

            //System.Diagnostics.Debug.Assert(barbers == Activator);
            //System.Diagnostics.Debug.Assert(ActivationData != null);
            //Barber barber = (Barber)ActivationData;

            //WaitOnTask(barber);
            //yield return Suspend();
            //// HINT: The above two lines of code can be shortened to
            ////          yield return barber;

            //Console.WriteLine("Customer pays {0} for the haircut.",
            //    barber.Name);

            //yield return barbers.Release(this);
        }
Beispiel #26
0
 private void Start()
 {
     materialCubo = GetComponent <MeshRenderer>();
     playerPoints = GetComponentInParent <Points>();
     walls        = wallManager.GetComponent <WallsRemaining>();
 }
        // Level // Spielverlauf zeichnen
        // ------------------------------------------------------------------------------------------------------------------------------------
        void Draw_Level()
        {
            // Background // Hintergrundbild
            // **************************************************************************************************************
            spriteBatch.Draw(texBackground, new Vector2(0, Background_Position), Color.White);
            // **************************************************************************************************************



            // Hintergundanimationen durchlaufen und zeichnen
            // **************************************************************************************************************
            for (int i = 0; i < ListBackgroundAnimation.Count(); i++)
            {
                spriteBatch.Draw(texBackgroundAnimation, new Vector2(ListBackgroundAnimation[i].x, ListBackgroundAnimation[i].y), Color.White);
            }
            // **************************************************************************************************************



            // Powershot zeichnen // Unter Gegner
            // **************************************************************************************************************
            // Wenn eigenes Schiff aktiv und Powerschuss-Animtaion läuft
            bool PowerShot_drawed = false;

            if (MyShipIsActive == true & PowerShotAnimation == true)
            {
                if (PowerShotAnimationFrame < 15)
                {
                    // Wenn Powerschuss noch aufbaut
                    spriteBatch.Draw(texMyShotPowerShot, new Vector2(MyShip_X - (texMyShotPowerShot.Width / 2), MyShip_Y - 120), Color.White);
                }
                else
                {
                    if (PowerShotAnimationFrame % 2 == 0)
                    {
                        // Powerschuss Strahl
                        spriteBatch.Draw(texMyShotPowerShot, new Vector2(MyShip_X - (texMyShotPowerShot.Width / 2), MyShip_Y - 20 - texMyShotPowerShot.Height), null, Color.White, 0.0f, new Vector2(0, 0), 1.0f, SpriteEffects.None, 1);
                        PowerShot_drawed = true;
                    }
                }
            }
            // **************************************************************************************************************



            // PowerUps durchlaufen und zeichnen
            // **************************************************************************************************************
            for (int i = 0; i < ListPowerUps.Count(); i++)
            {
                // PowerUp zeichnen
                if (ListPowerUps[i].show == true)
                {
                    spriteBatch.Draw(ListPowerUps[i].Texture, new Vector2(ListPowerUps[i].x - (ListPowerUps[i].Texture.Width / 2), ListPowerUps[i].y - (ListPowerUps[i].Texture.Height / 2)), null, Color.White);
                }
                // DEBUG Hitbox anzeigen
                if (DEBUG == true)
                {
                    HitboxRectangle.Width  = ListPowerUps[i].Texture.Width;
                    HitboxRectangle.Height = ListPowerUps[i].Texture.Height;
                    HitboxRectangle.X      = ListPowerUps[i].x - (ListPowerUps[i].Texture.Width / 2);
                    HitboxRectangle.Y      = ListPowerUps[i].y - (ListPowerUps[i].Texture.Height / 2);
                    spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Bisque);
                }
            }
            // **************************************************************************************************************



            // ShipEnemys // Gegnerische Schiffe
            // **************************************************************************************************************
            for (int i = 0; i < ListShipEnemys.Count(); i++)
            {
                // Prüfvariable ob Standard geladen wird
                bool load_just = true;
                // Ausrichtung des Schiffes erstellen und ausgeben
                if (ListShipEnemys[i].sprite == "left")
                {
                    spriteBatch.Draw(ListEnemyTextures[ListShipEnemys[i].enemy_type].left, new Vector2(ListShipEnemys[i].position_x, ListShipEnemys[i].position_y), null, Color.White, ListShipEnemys[i].rotation, new Vector2(ListEnemyTextures[ListShipEnemys[i].enemy_type].left.Width / 2, ListEnemyTextures[ListShipEnemys[i].enemy_type].left.Height / 2), 1, SpriteEffects.None, 0);
                    load_just = false;
                }
                else if (ListShipEnemys[i].sprite == "right")
                {
                    spriteBatch.Draw(ListEnemyTextures[ListShipEnemys[i].enemy_type].right, new Vector2(ListShipEnemys[i].position_x, ListShipEnemys[i].position_y), null, Color.White, ListShipEnemys[i].rotation, new Vector2(ListEnemyTextures[ListShipEnemys[i].enemy_type].right.Width / 2, ListEnemyTextures[ListShipEnemys[i].enemy_type].right.Height / 2), 1, SpriteEffects.None, 0);
                    load_just = false;
                }

                if (load_just == true)
                {
                    spriteBatch.Draw(ListEnemyTextures[ListShipEnemys[i].enemy_type].just, new Vector2(ListShipEnemys[i].position_x, ListShipEnemys[i].position_y), null, Color.White, ListShipEnemys[i].rotation, new Vector2(ListEnemyTextures[ListShipEnemys[i].enemy_type].just.Width / 2, ListEnemyTextures[ListShipEnemys[i].enemy_type].just.Height / 2), 1, SpriteEffects.None, 0);
                }



                // DEBUG Hitbox anzeigen
                if (DEBUG == true)
                {
                    HitboxRectangle.Width  = ListShipEnemys[i].hitbox_width;
                    HitboxRectangle.Height = ListShipEnemys[i].hitbox_height;
                    HitboxRectangle.X      = ListShipEnemys[i].hitbox_x;
                    HitboxRectangle.Y      = ListShipEnemys[i].hitbox_y;
                    spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Orange);
                }
            }
            // **************************************************************************************************************



            // Endboss Szenario
            // **************************************************************************************************************
            // Endboss zeichnen
            if (BossSzenario == true & DrawBoss == true)
            {
                spriteBatch.Draw(texBoss, new Vector2(Boss_X - (texBoss.Width / 2), Boss_Y - (texBoss.Height / 2)), null, Color.White);

                // DEBUG Hitbox anzeigen
                if (DEBUG == true)
                {
                    HitboxRectangle.Width  = Boss_Hitbox_Width;
                    HitboxRectangle.Height = Boss_Hitbox_Height;
                    HitboxRectangle.X      = Boss_X - (Boss_Hitbox_Width / 2);
                    HitboxRectangle.Y      = Boss_Y - (Boss_Hitbox_Height / 2);
                    spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Cyan);
                }
            }
            // **************************************************************************************************************



            // ListMyShotRocket // Erweiterte Schüsse durchlaufen und zeichnen
            // **************************************************************************************************************
            for (int i = 0; i < ListMyShotRocket.Count(); i++)
            {
                // Position der Raketen ermitteln und zeichen
                spriteBatch.Draw(texMyShotRocket, new Vector2(ListMyShotRocket[i].x - (texMyShotRocket.Width / 2), ListMyShotRocket[i].y - (texMyShotRocket.Height / 2)), null, Color.White);
                // Rauch zeichnen
                if (ListMyShotRocket[i].smoke1_y != -1000)
                {
                    spriteBatch.Draw(texSmoke1, new Vector2(ListMyShotRocket[i].x - (texSmoke1.Width / 2), ListMyShotRocket[i].smoke1_y - (texSmoke1.Height / 2)), null, Color.White);
                }
                if (ListMyShotRocket[i].smoke2_y != -1000)
                {
                    spriteBatch.Draw(texSmoke2, new Vector2(ListMyShotRocket[i].x - (texSmoke2.Width / 2), ListMyShotRocket[i].smoke2_y - (texSmoke2.Height / 2)), null, Color.White);
                }
                if (ListMyShotRocket[i].smoke3_y != -1000)
                {
                    spriteBatch.Draw(texSmoke3, new Vector2(ListMyShotRocket[i].x - (texSmoke3.Width / 2), ListMyShotRocket[i].smoke3_y - (texSmoke3.Height / 2)), null, Color.White);
                }
                if (ListMyShotRocket[i].smoke4_y != -1000)
                {
                    spriteBatch.Draw(texSmoke4, new Vector2(ListMyShotRocket[i].x - (texSmoke4.Width / 2), ListMyShotRocket[i].smoke4_y - (texSmoke4.Height / 2)), null, Color.White);
                }
                if (ListMyShotRocket[i].smoke5_y != -1000)
                {
                    spriteBatch.Draw(texSmoke5, new Vector2(ListMyShotRocket[i].x - (texSmoke5.Width / 2), ListMyShotRocket[i].smoke5_y - (texSmoke5.Height / 2)), null, Color.White);
                }// DEBUG Hitbox anzeigen
                if (DEBUG == true)
                {
                    HitboxRectangle.Width  = texMyShotRocket.Width;
                    HitboxRectangle.Height = texMyShotRocket.Height;
                    HitboxRectangle.X      = ListMyShotRocket[i].x - (HitboxRectangle.Width / 2);
                    HitboxRectangle.Y      = ListMyShotRocket[i].y - (HitboxRectangle.Height / 2);
                    spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Cyan);
                }
            }
            // **************************************************************************************************************



            // MyShip // Eigenes Raumschiff
            // **************************************************************************************************************
            // Wenn eigenes Schiff aktiv
            if (MyShipIsActive == true)
            {
                if (Indestructible == 0 | (Indestructible % 2 == 0))
                {
                    // Raumschiff zeichnen
                    if (MyShipPosition == 0)
                    {
                        spriteBatch.Draw(texMyShip, new Vector2(MyShip_X - (texMyShip.Width / 2), MyShip_Y - (texMyShip.Height / 2)), Color.White);
                    }
                    if (MyShipPosition == 1)
                    {
                        spriteBatch.Draw(texMyShipRight, new Vector2(MyShip_X - (texMyShipRight.Width / 2), MyShip_Y - (texMyShipRight.Height / 2)), Color.White);
                    }
                    if (MyShipPosition == -1)
                    {
                        spriteBatch.Draw(texMyShipLeft, new Vector2(MyShip_X - (texMyShipLeft.Width / 2), MyShip_Y - (texMyShipLeft.Height / 2)), Color.White);
                    }
                    // DEBUG MODE // Hitbox des Powerschusses anzeigen + 1
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = MyShip_PowerShot_Hitbox_Width;
                        HitboxRectangle.Height = MyShip_PowerShot_Hitbox_Height;;
                        HitboxRectangle.X      = MyShip_PowerShot_Hitbox_X;
                        HitboxRectangle.Y      = MyShip_PowerShot_Hitbox_Y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Green);
                    }
                    // DEBUG MODE // Hitbox des Powerschusses anzeigen + 2
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = MyShip_PowerShot_Hitbox_Width_2;
                        HitboxRectangle.Height = MyShip_PowerShot_Hitbox_Height_2;;
                        HitboxRectangle.X      = MyShip_PowerShot_Hitbox_X_2;
                        HitboxRectangle.Y      = MyShip_PowerShot_Hitbox_Y_2;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Orange);
                    }
                    // DEBUG MODE // Hitbox anzeigen
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = MyShip_Hitbox_Width;
                        HitboxRectangle.Height = MyShip_Hitbox_Height;;
                        HitboxRectangle.X      = MyShip_Hitbox_X;
                        HitboxRectangle.Y      = MyShip_Hitbox_Y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Red);
                    }
                }
            }
            // **************************************************************************************************************



            // Powershot zeichnen // Über andere Gegner
            // **************************************************************************************************************
            // Wenn eigenes Schiff aktiv und Powerschuss-Animtaion läuft
            if (MyShipIsActive == true & PowerShotAnimation == true)
            {
                if (PowerShotAnimationFrame >= 15)
                {
                    if (PowerShot_drawed == false)
                    {
                        spriteBatch.Draw(texMyShotPowerShot, new Vector2(MyShip_X - (texMyShotPowerShot.Width / 2), MyShip_Y - 20 - texMyShotPowerShot.Height), null, Color.White, 0.0f, new Vector2(0, 0), 1.0f, SpriteEffects.FlipHorizontally, 1);
                    }
                }
                if (DEBUG == true)
                {
                    HitboxRectangle.Width  = PowerShotHitboxWidth;
                    HitboxRectangle.Height = PowerShotHitboxHeight;
                    HitboxRectangle.X      = PowerShotHitboxX;
                    HitboxRectangle.Y      = PowerShotHitboxY;
                    spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.BurlyWood);
                }
            }
            // **************************************************************************************************************



            // ListMyShots // Schüsse durchlaufen und zeichnen
            // **************************************************************************************************************
            for (int x = 0; x < ListMyShots.Count(); x++)
            {
                // Schuss Feuer
                if (ListMyShots[x].type == "Fire")
                {
                    // Schuss zeichnen
                    spriteBatch.Draw(texMyShotFire, new Vector2(ListMyShots[x].x + (texMyShotFire.Width / 2), ListMyShots[x].y - (texMyShotFire.Height / 2)), null, Color.White, ListMyShots[x].angle, new Vector2(texMyShotFire.Width, texMyShotFire.Width), 1.0f, SpriteEffects.None, 1);
                    // DEBUG MODE // Hitbox anzeigen
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = ListMyShots[x].hitbox_width;
                        HitboxRectangle.Height = ListMyShots[x].hitbox_height;
                        HitboxRectangle.X      = ListMyShots[x].hitbox_x;
                        HitboxRectangle.Y      = ListMyShots[x].hitbox_y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Red);
                    }
                }

                // Schuss Phaser
                if (ListMyShots[x].type == "Phaser")
                {
                    // Schuss zeichnen
                    spriteBatch.Draw(texMyShotPhaser, new Vector2(ListMyShots[x].x + (texMyShotPhaser.Width / 2), ListMyShots[x].y - (texMyShotPhaser.Height / 2)), null, Color.White, ListMyShots[x].angle, new Vector2(texMyShotPhaser.Width, texMyShotPhaser.Width), 1.0f, SpriteEffects.None, 1);
                    // DEBUG MODE // Hitbox anzeigen
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = ListMyShots[x].hitbox_width;
                        HitboxRectangle.Height = ListMyShots[x].hitbox_height;
                        HitboxRectangle.X      = ListMyShots[x].hitbox_x;
                        HitboxRectangle.Y      = ListMyShots[x].hitbox_y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Red);
                    }
                }

                // Schuss Laser
                if (ListMyShots[x].type == "Laser")
                {
                    // Bei Laser Level 1
                    if (ListMyShots[x].level == 1)
                    {
                        // Schuss zeichnen
                        spriteBatch.Draw(texMyShotLaser1, new Vector2(ListMyShots[x].x + (texMyShotLaser1.Width / 2), ListMyShots[x].y - (texMyShotLaser1.Height / 2)), null, Color.White, ListMyShots[x].angle, new Vector2(texMyShotLaser1.Width, texMyShotLaser1.Width), 1.0f, SpriteEffects.None, 1);
                    }
                    // Bei Laser Level 2
                    if (ListMyShots[x].level == 2)
                    {
                        // Schuss zeichnen
                        spriteBatch.Draw(texMyShotLaser2, new Vector2(ListMyShots[x].x + (texMyShotLaser2.Width / 2), ListMyShots[x].y - (texMyShotLaser2.Height / 2)), null, Color.White, ListMyShots[x].angle, new Vector2(texMyShotLaser2.Width, texMyShotLaser2.Width), 1.0f, SpriteEffects.None, 1);
                    }
                    // Bei Laser Level 3
                    if (ListMyShots[x].level == 3)
                    {
                        // Schuss zeichnen
                        spriteBatch.Draw(texMyShotLaser3, new Vector2(ListMyShots[x].x + (texMyShotLaser3.Width / 2), ListMyShots[x].y - (texMyShotLaser3.Height / 2)), null, Color.White, ListMyShots[x].angle, new Vector2(texMyShotLaser3.Width, texMyShotLaser3.Width), 1.0f, SpriteEffects.None, 1);
                    }

                    // DEBUG MODE // Hitbox anzeigen
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = ListMyShots[x].hitbox_width;
                        HitboxRectangle.Height = ListMyShots[x].hitbox_height;
                        HitboxRectangle.X      = ListMyShots[x].hitbox_x;
                        HitboxRectangle.Y      = ListMyShots[x].hitbox_y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.BlueViolet);
                    }
                }
            }
            // **************************************************************************************************************



            // Enemy Shots // Gegnerische Schüsse durchlaufen und zeichnen
            // **************************************************************************************************************
            // Schuss typ 1 --> Direkter Schuss --> <ClassEnemyShotDirect> Durchlaufen und zeichnen
            for (int i = 0; i < ListEnemyShotDirect.Count(); i++)
            {
                // Bei kleinem Schuß
                if (ListEnemyShotDirect[i].hitbox_height == 20)
                {
                    // Schuss auswählen und zeichnen
                    if (ListEnemyShotDirect[i].angel == 1)
                    {
                        spriteBatch.Draw(texEnemyShot1, new Vector2(Convert.ToInt32(ListEnemyShotDirect[i].x) + (texEnemyShot1.Width / 2), Convert.ToInt32(ListEnemyShotDirect[i].y + (texEnemyShot1.Height / 2))), null, Color.White, 0.0f, new Vector2(texEnemyShot1.Width, texEnemyShot1.Height), 1.0f, SpriteEffects.None, 1);
                    }
                    else if (ListEnemyShotDirect[i].angel == 2)
                    {
                        spriteBatch.Draw(texEnemyShot1, new Vector2(Convert.ToInt32(ListEnemyShotDirect[i].x) + (texEnemyShot1.Width / 2), Convert.ToInt32(ListEnemyShotDirect[i].y + (texEnemyShot1.Height / 2))), null, Color.White, 0.0f, new Vector2(texEnemyShot1.Width, texEnemyShot1.Height), 1.0f, SpriteEffects.FlipHorizontally, 1);
                    }
                    else if (ListEnemyShotDirect[i].angel == 3)
                    {
                        spriteBatch.Draw(texEnemyShot1, new Vector2(Convert.ToInt32(ListEnemyShotDirect[i].x) + (texEnemyShot1.Width / 2), Convert.ToInt32(ListEnemyShotDirect[i].y + (texEnemyShot1.Height / 2))), null, Color.White, 0.0f, new Vector2(texEnemyShot1.Width, texEnemyShot1.Height), 1.0f, SpriteEffects.FlipVertically, 1);
                    }
                    // DEBUG MODE // Hitbox anzeigen
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = ListEnemyShotDirect[i].hitbox_width;
                        HitboxRectangle.Height = ListEnemyShotDirect[i].hitbox_height;
                        HitboxRectangle.X      = ListEnemyShotDirect[i].hitbox_x;
                        HitboxRectangle.Y      = ListEnemyShotDirect[i].hitbox_y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Aquamarine);
                    }
                }

                // Bei großem Schuß
                else if (ListEnemyShotDirect[i].hitbox_height == 40)
                {
                    // Schuss auswählen und zeichnen
                    if (ListEnemyShotDirect[i].angel == 1)
                    {
                        spriteBatch.Draw(texEnemyShot1_2, new Vector2(Convert.ToInt32(ListEnemyShotDirect[i].x) + (texEnemyShot1_2.Width / 2), Convert.ToInt32(ListEnemyShotDirect[i].y + (texEnemyShot1_2.Height / 2))), null, Color.White, 0.0f, new Vector2(texEnemyShot1_2.Width, texEnemyShot1_2.Height), 1.0f, SpriteEffects.None, 1);
                    }
                    else if (ListEnemyShotDirect[i].angel == 2)
                    {
                        spriteBatch.Draw(texEnemyShot1_2, new Vector2(Convert.ToInt32(ListEnemyShotDirect[i].x) + (texEnemyShot1_2.Width / 2), Convert.ToInt32(ListEnemyShotDirect[i].y + (texEnemyShot1_2.Height / 2))), null, Color.White, 0.0f, new Vector2(texEnemyShot1_2.Width, texEnemyShot1_2.Height), 1.0f, SpriteEffects.FlipHorizontally, 1);
                    }
                    else if (ListEnemyShotDirect[i].angel == 3)
                    {
                        spriteBatch.Draw(texEnemyShot1_2, new Vector2(Convert.ToInt32(ListEnemyShotDirect[i].x) + (texEnemyShot1_2.Width / 2), Convert.ToInt32(ListEnemyShotDirect[i].y + (texEnemyShot1_2.Height / 2))), null, Color.White, 0.0f, new Vector2(texEnemyShot1_2.Width, texEnemyShot1_2.Height), 1.0f, SpriteEffects.FlipVertically, 1);
                    }
                    // DEBUG MODE // Hitbox anzeigen
                    if (DEBUG == true)
                    {
                        HitboxRectangle.Width  = ListEnemyShotDirect[i].hitbox_width;
                        HitboxRectangle.Height = ListEnemyShotDirect[i].hitbox_height;
                        HitboxRectangle.X      = ListEnemyShotDirect[i].hitbox_x;
                        HitboxRectangle.Y      = ListEnemyShotDirect[i].hitbox_y;
                        spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.Aquamarine);
                    }
                }
            }



            // Schuss typ 2 --> Laser Schuss --> <ClassEnemyShotLaser> Durchlaufen und zeichnen
            for (int i = 0; i < ListEnemyShotLaser.Count(); i++)
            {
                // Schuss auswählen und zeichnen
                spriteBatch.Draw(ListEnemyShotLaser[i].texture, new Vector2(Convert.ToInt32(ListEnemyShotLaser[i].x) - (ListEnemyShotLaser[i].texture.Width / 2), Convert.ToInt32(ListEnemyShotLaser[i].y)), Color.White);
                // DEBUG MODE // Hitbox anzeigen
                if (DEBUG == true)
                {
                    HitboxRectangle.Width  = ListEnemyShotLaser[i].texture.Width;
                    HitboxRectangle.Height = ListEnemyShotLaser[i].texture.Height;
                    HitboxRectangle.X      = Convert.ToInt32(ListEnemyShotLaser[i].x) - (ListEnemyShotLaser[i].texture.Width / 2);
                    HitboxRectangle.Y      = Convert.ToInt32(ListEnemyShotLaser[i].y);
                    spriteBatch.Draw(HitboxTexture, HitboxRectangle, Color.BlanchedAlmond);
                }
            }
            // **************************************************************************************************************



            // ListExplosions // Explosionen durchlaufen und zeichen
            // **************************************************************************************************************
            for (int x = 0; x < ListExplosions.Count(); x++)
            {
                // Explosionen zeichnen
                spriteBatch.Draw(ListExplosions[x].Texture, new Vector2(ListExplosions[x].x - (ListExplosions[x].Texture.Width / 2), ListExplosions[x].y - (ListExplosions[x].Texture.Height / 2)), Color.White);
            }
            // **************************************************************************************************************



            // Anzeige zeichnen
            // **************************************************************************************************************
            // Display
            spriteBatch.Draw(texDisplay, new Vector2(0, Display_Y), null, Color.White);
            // Waffe
            spriteBatch.Draw(texDisplay_Weapon, new Vector2(74, 2 + Display_Content_Y), null, Color.White);
            // Level Waffe
            spriteBatch.Draw(texDisplay_LevelShot, new Vector2(138, 3 + Display_Content_Y), null, Color.White);


            // Level Extension
            if (Display_Show_Extension == true)
            {
                spriteBatch.Draw(texDisplay_Extension, new Vector2(155, 3 + Display_Content_Y), null, Color.White);
                spriteBatch.Draw(texDisplay_LevelExtension, new Vector2(186, 3 + Display_Content_Y), null, Color.White);
            }

            // Powerschuss Bar ausgeben
            spriteBatch.Draw(texDisplay_PowerShotBar, new Rectangle((204 + MyShip_PowerShot_Width), 5 + Display_Content_Y, (224 - MyShip_PowerShot_Width), 26), Color.White);


            // Leben ausgeben
            spriteBatch.DrawString(fntDisplay, Lives.ToString(), new Vector2(29, 2 + Display_Content_Y), Color.Black);

            // Punkte Ausgeben
            spriteBatch.DrawString(fntDisplay, Points.ToString(), new Vector2(209, 2 + Display_Content_Y), Color.Black);

            // Anzahl Powerschüsse ausgeben
            spriteBatch.DrawString(fntDisplay, MyShip_PowerShots.ToString(), new Vector2(441, 2 + Display_Content_Y), Color.Black);

            // Warnung zeichnen
            if (ShowWarning == true)
            {
                spriteBatch.Draw(texWarning, new Vector2(0, 400), null, Color.White);
            }
            // **************************************************************************************************************



            // Endboss Zeit ausgeben
            // **************************************************************************************************************
            if (BossTimeString != "")
            {
                Color   BossTimeColor = new Color(0.8f, 0.8f, 0.8f, 0.8f);
                Vector2 FontOrigin    = fntBossTime.MeasureString(BossTimeString) / 2;
                spriteBatch.DrawString(fntBossTime, BossTimeString.ToString(), new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, 60 + Display_Content_Y), Color.LightGray, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
            }
            // **************************************************************************************************************
        }
 protected override Rect GetBoundingRectangleCore() {
     var bounds = new Rect(Points.xPosition(Column), 0, Points.GetWidth(Column), Points.ColumnHeaderHeight);
     return new Rect(Owner.ColumnHeader.PointToScreen(bounds.TopLeft), Owner.ColumnHeader.PointToScreen(bounds.BottomRight));
 }
Beispiel #29
0
        private void MouseDown(Viewport3D vp, ViewportEvent e)
        {
            if (!_currentTool.NoSelection())
            {
                var vtxs = _currentTool.GetVerticesAtPoint(e.X, vp.Height - e.Y, vp);

                if (vtxs.Any())
                {
                    // Use the topmost vertex as the control point
                    var vtx = vtxs.First();

                    // Mouse down on a point
                    if (vtx.IsSelected && KeyboardState.Ctrl && _currentTool.ShouldDeselect(vtxs))
                    {
                        // If the vertex is selected and ctrl is down, deselect the vertices
                        vtxs.ForEach(x => x.IsSelected = false);
                    }
                    else
                    {
                        if (!vtx.IsSelected && !KeyboardState.Ctrl && _currentTool.ShouldDeselect(vtxs))
                        {
                            // If we aren't clicking on a selected point and ctrl is not down, deselect the others
                            Points.ForEach(x => x.IsSelected = false);
                            // If this point is already selected, don't deselect others. This is the same behaviour as 2D selection.
                        }
                        vtxs.ForEach(x => x.IsSelected = true);
                    }
                    VertexSelectionChanged();

                    // Don't do other click operations
                    return;
                }

                // Nothing clicked
                if (!KeyboardState.Ctrl)
                {
                    // Deselect all the points if not ctrl-ing
                    Points.ForEach(x => x.IsSelected = false);
                }
            }
            if (!_currentTool.No3DSelection())
            {
                // Do selection
                var ray   = vp.CastRayFromScreen(e.X, e.Y);
                var hits  = Document.Map.WorldSpawn.GetAllNodesIntersectingWith(ray, true);
                var solid = hits
                            .OfType <Solid>()
                            .Select(x => new { Item = x, Intersection = GetIntersectionPoint(x, ray) })
                            .Where(x => x.Intersection != null)
                            .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude())
                            .Select(x => x.Item)
                            .FirstOrDefault();

                if (solid != null)
                {
                    if (solid.IsSelected && KeyboardState.Ctrl)
                    {
                        // deselect solid
                        var select   = new MapObject[0];
                        var deselect = new[] { solid };
                        Document.PerformAction("Deselect VM solid", new ChangeSelection(select, deselect));
                    }
                    else if (!solid.IsSelected)
                    {
                        // select solid
                        var select   = new[] { solid };
                        var deselect = !KeyboardState.Ctrl ? Document.Selection.GetSelectedObjects() : new MapObject[0];
                        Document.PerformAction("Select VM solid", new ChangeSelection(select, deselect));
                    }

                    // Don't do other click operations
                    return;
                }
            }

            base.MouseDown(vp, e);
        }
Beispiel #30
0
        public Points GetWaySegments(Car car)
        {
            var result = new Points();
            var isWayPoint = new List<bool>();
            var myCell = GetCell(car.X, car.Y);
            result.Add(new Point(car));
            isWayPoint.Add(false);
            Cell prevCell = null;

            for (var e = 1; result.Count < 5; e++)
            {
                var nextWp = GetNextWayPoint(car, e);
                for (var curCell = myCell; !curCell.Equals(nextWp);)
                {
                    var nextCell = DijkstraNextCell(curCell, nextWp, prevCell == null ? new Cell[] { } : new[] { prevCell });
                    var nextPoint = GetCenter(nextCell);
                    while (result.Count > 1 && !isWayPoint[isWayPoint.Count - 1] && CheckVisibility(car, result[result.Count - 2], nextPoint, car.Height / 2 + 10))
                    {
                        result.Pop();
                        isWayPoint.RemoveAt(isWayPoint.Count - 1);
                    }
                    result.Add(nextPoint);
                    isWayPoint.Add(nextCell.Equals(nextWp));
                    prevCell = curCell;
                    curCell = nextCell;
                }
                myCell = nextWp;
            }
            return result;
        }
Beispiel #31
0
 /// <summary>
 ///     Updates the polygon. Use this after changing something.
 /// </summary>
 public void UpdatePolygon()
 {
     Points.Clear();
     Points.Add(LineStart);
     Points.Add(LineEnd);
 }
 Quaternion GetOrientation(Points p)
 {
     var x = p.GetDirection ("X");
     var y = p.GetDirection ("Y");
     var z = p.GetDirection ("Z");
     Quaternion rot;
     if (y.IsZero ()) {
         if (z.IsZero () && x.IsZero ()) {
             x = Vector3d.Cross (p.Up (), Vector3d.up);
             x.Normalize ();
             z = Vector3d.Cross (x, p.Up ());
         } else if (z.IsZero ()) {
             z = Vector3d.Cross (x, p.Up ());
             z.Normalize ();
         } else if (x.IsZero ()) {
             x = Vector3d.Cross (p.Up (), z);
             x.Normalize ();
         }
         rot = p.ChooseRotation (x, z);
     } else if (x.IsZero ()) {
         // y is not zero
         if (z.IsZero ()) {
             z = Vector3d.Cross (p.Up (), y);
             z.Normalize ();
         }
         rot = p.ChooseRotation (z, y);
     } else if (z.IsZero ()) {
         // neither x nor y are zero
         rot = p.ChooseRotation (y, x);
     } else {
         // no direction is 0
         rot = p.ChooseRotation (x, z, y);
     }
     return rot;
 }
Beispiel #33
0
 private void DeselectAll(object sender)
 {
     Points.ForEach(x => x.IsSelected = false);
     VertexSelectionChanged();
 }
Beispiel #34
0
        static void Main(string[] arguments)
        {
            string command = string.Empty;
            char[,] field = CreateField();
            char[,] bombs = PlaceBombs();
            int counter = 0;
            bool crash = false;
            List<Points> winners = new List<Points>(6);
            int row = 0;
            int col = 0;
            bool flag = true;
            const int max = 35;
            bool flag2 = false;

            do
            {
                if (flag)
                {
                    Console.WriteLine("Lets play. You should find the fields without mines." +
                    " Command 'top' shows the ranking, 'restart' starts a new game, 'exit' finishes the game!");
                    Input(field);
                    flag = false;
                }

                Console.Write("Row and Col: ");
                command = Console.ReadLine().Trim();

                if (command.Length >= 3 &&
                    int.TryParse(command[0].ToString(), out row) &&
                    int.TryParse(command[2].ToString(), out col) &&
                    row <= field.GetLength(0) && col <= field.GetLength(1))
                {
                        command = "turn";
                }

                switch (command)
                {
                    case "top":
                        Ranking(winners);
                        break;
                    case "restart":
                        field = CreateField();
                        bombs = PlaceBombs();
                        Input(field);
                        crash = false;
                        flag = false;
                        break;
                    case "exit":
                        Console.WriteLine("Bye!");
                        break;
                    case "turn":
                        if (bombs[row, col] != '*')
                        {
                            if (bombs[row, col] == '-')
                            {
                                OnTurn(field, bombs, row, col);
                                counter++;
                            }
                            if (max == counter)
                            {
                                flag2 = true;
                            }
                            else
                            {
                                Input(field);
                            }
                        }
                        else
                        {
                            crash = true;
                        }
                        break;
                    default:
                        Console.WriteLine("\nError! Wrong command!\n");
                        break;
                }

                if (crash)
                {
                    Input(bombs);
                    Console.Write("\nExit game with {0} points. " + "Nickname: ", counter);
                    string nickname = Console.ReadLine();
                    Points player = new Points(nickname, counter);

                    if (winners.Count < 5)
                    {
                        winners.Add(player);
                    }
                    else
                    {
                        for (int i = 0; i < winners.Count; i++)
                        {
                            if (winners[i].PointsIn < player.PointsIn)
                            {
                                winners.Insert(i, player);
                                winners.RemoveAt(winners.Count - 1);
                                break;
                            }
                        }
                    }

                    winners.Sort((Points player1, Points player2) => player2.Name.CompareTo(player1.Name));
                    winners.Sort((Points player1, Points player2) => player2.PointsIn.CompareTo(player1.PointsIn));
                    Ranking(winners);

                    field = CreateField();
                    bombs = PlaceBombs();
                    counter = 0;
                    crash = false;
                    flag = true;
                }
                if (flag2)
                {
                    Console.WriteLine("\nCongrats!");
                    Input(bombs);

                    Console.WriteLine("Name: ");
                    string name = Console.ReadLine();

                    Points points = new Points(name, counter);

                    winners.Add(points);
                    Ranking(winners);

                    field = CreateField();
                    bombs = PlaceBombs();

                    counter = 0;
                    flag2 = false;
                    flag = true;
                }
            }
            while (command != "exit");

            Console.Read();
        }
Beispiel #35
0
 public List <Point> PointsWithTotalDistanceLowerThan(int distance)
 {
     return(Points.Where(p => p.TotalDistance < distance).ToList());
 }
Beispiel #36
0
        /// <summary>
        /// Clears all anchor points.
        /// </summary>
        public void ClearAllPoints()
        {
            foreach (var anchor in anchors)
            {
                Frame parent = anchor.Value.AnchorControl ?? Parent;
                if (parent != null)
                    parent.anchorChildren.Remove(this);
            }

            anchoredPoints = 0;
            UpdateAnchors();
        }
 public string ToString(bool includeTransponder)
 {
     return("<competitor no=\"" + Number + "\" class=\"" + ClassName + "\" firstname=\"" + FirstName + "\" lastname=\"" + LastName +
            "\" registration=\"" + CarRegistration + "\" driverregistration=\"" + DriverRegistration + "\" points=\"" + Points.ToString() +
            "\" startpos=\"" + StartPosition.ToString() + "\" hidden=\"" + (Hidden ? "yes" : "no") + "\"" +
            (includeTransponder ? " transponders=\"" + Transponder + "\"/>" : "/>"));
 }
Beispiel #38
0
 /// <summary>
 /// Sets the the specified point on this frame to be at the same position
 /// as the corresponding point on the parent frame.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="offset">The offset.</param>
 public void SetPoint(Points point, Int2D offset)
 {
     SetPoint(point, offset.X, offset.Y);
 }
Beispiel #39
0
        private void UpdateFunc(List <DPoint> linePts1, List <DPoint> linePts2, Func <double, double> f1, Func <double, double> f2, double lowerLim, double upperLim, double logStep)
        {
            lineSeries1 = linePts1;
            lineSeries2 = linePts2;
            func1       = f1;
            func2       = f2;
            lowLim      = lowerLim;
            upLim       = upperLim;
            step        = logStep;

            Points.Clear();

            int    lpIndex1     = 0;
            double lpIntercept1 = 0d;
            double lpSlope1     = 0d;
            int    lpIndex2     = 0;
            double lpIntercept2 = 0d;
            double lpSlope2     = 0d;

            for (double x = lowerLim; x < upLim * logStep; x *= logStep)
            {
                if (x > upLim)
                {
                    x = upLim;
                }

                double lineValue1 = 0;

                if (lineSeries1[lpIndex1].X <= x)
                {
                    while (lpIndex1 < lineSeries1.Count && lineSeries1[lpIndex1].X <= x)
                    {
                        lpIndex1++;
                    }
                    if (lpIndex1 < lineSeries1.Count)
                    {
                        var cp = lineSeries1[lpIndex1 - 1];
                        var np = lineSeries1[lpIndex1];
                        lpSlope1     = (np.Y - cp.Y) / Math.Log10(np.X / cp.X);
                        lpIntercept1 = cp.Y - lpSlope1 * Math.Log10(cp.X);
                    }
                }

                if (lpIndex1 == 0 && lineSeries1[0].X >= x)
                {
                    lineValue1 = lineSeries1[0].Y;
                }
                else if (lpIndex1 < lineSeries1.Count)
                {
                    lineValue1 = lpIntercept1 + lpSlope1 * (Math.Log10(x));
                }
                else
                {
                    lineValue1 = lineSeries1.Last().Y;
                }

                double lineValue2 = 0;

                if (lineSeries2[lpIndex2].X <= x)
                {
                    while (lpIndex2 < lineSeries2.Count && lineSeries2[lpIndex2].X <= x)
                    {
                        lpIndex2++;
                    }
                    if (lpIndex2 < lineSeries2.Count)
                    {
                        var cp = lineSeries2[lpIndex2 - 1];
                        var np = lineSeries2[lpIndex2];
                        lpSlope2     = (np.Y - cp.Y) / Math.Log10(np.X / cp.X);
                        lpIntercept2 = cp.Y - lpSlope2 * Math.Log10(cp.X);
                    }
                }

                if (lpIndex2 == 0 && lineSeries2[0].X >= x)
                {
                    lineValue2 = lineSeries2[0].Y;
                }
                else if (lpIndex2 < lineSeries2.Count)
                {
                    lineValue2 = lpIntercept2 + lpSlope2 * (Math.Log10(x));
                }
                else
                {
                    lineValue2 = lineSeries2.Last().Y;
                }

                var val1  = Math.Pow(10d, (func1(x) + lineValue1) / 10d);
                var val2  = Math.Pow(10d, (func2(x) + lineValue2) / 10d);
                var total = 10d * Math.Log10(val1 + val2);

                Points.Add(new DataPoint(x, total));
            }
        }
Beispiel #40
0
        /// <summary>
        /// Sets the the specified point on this frame to be at the same position
        /// as the corresponding point on the parent frame.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="x">The x offset.</param>
        /// <param name="y">The y offset.</param>
        /// <param name="anchorFrame">The frame this frame is anchored to.</param>
        /// <param name="anchoredTo">The point on the anchorFrame to anchor to.</param>
        public void SetPoint(Points point, int x, int y, Frame anchorFrame, Points anchoredTo)
        {
            foreach (var side in anchors)
            {
                if (point.Selected(side.Key))
                {
                    Anchor anchor = side.Value;
                    anchor.Start = side.Key;
                    anchor.End = anchoredTo;
                    anchor.AnchorControl = anchorFrame;
                    anchor.Offset = new Vector2(x, y);
                }
            }

            anchoredPoints |= point;

            Frame parent = anchorFrame ?? this.Parent;
            if (parent != null && !parent.anchorChildren.Contains(this))
                parent.anchorChildren.Add(this);

            UpdateAnchors();
        }
Beispiel #41
0
 public void AssertAvailableSize(Points width, Points height)
 {
     Assert.IsTrue(_available.HasValue, _name.Capitalize() + " have not receieved an available size");
     Assert.AreEqual(width, _available.Value.Width, _name.Capitalize() + " got wrong available width");
     Assert.AreEqual(height, _available.Value.Height, _name.Capitalize() + " got wrong available height");
 }
Beispiel #42
0
        public override void MouseDown(ViewportBase vp, ViewportEvent e)
        {
            _clickSelectionDone = false;
            if (_currentTool != null)
            {
                // If the current tool handles the event, we're done
                _currentTool.MouseDown(vp, e);
                if (e.Handled)
                {
                    return;
                }
            }
            if (!(vp is Viewport2D))
            {
                MouseDown((Viewport3D)vp, e);
                return;
            }

            if (_currentTool == null)
            {
                return;
            }

            if (_currentTool.NoSelection())
            {
                return;
            }

            var viewport = (Viewport2D)vp;

            // Otherwise we try a selection
            // Find the clicked vertices
            var vtxs = _currentTool.GetVerticesAtPoint(e.X, viewport.Height - e.Y, viewport);

            if (!vtxs.Any())
            {
                // Nothing clicked
                if (!KeyboardState.Ctrl)
                {
                    // Deselect all the points if not ctrl-ing
                    Points.ForEach(x => x.IsSelected = false);
                }

                // Try to select in 2D

                // Create a box to represent the click, with a tolerance level
                var unused    = viewport.GetUnusedCoordinate(new Coordinate(100000, 100000, 100000));
                var tolerance = 4 / viewport.Zoom; // Selection tolerance of four pixels
                var used      = viewport.Expand(new Coordinate(tolerance, tolerance, 0));
                var add       = used + unused;
                var click     = viewport.Expand(viewport.ScreenToWorld(e.X, viewport.Height - e.Y));
                var box       = new Box(click - add, click + add);

                var centerHandles = Select.DrawCenterHandles;
                var centerOnly    = Select.ClickSelectByCenterHandlesOnly;
                // Get the first element that intersects with the box
                var solid = Document.Map.WorldSpawn.GetAllNodesIntersecting2DLineTest(box, centerHandles, centerOnly).OfType <Solid>().FirstOrDefault();

                if (solid != null)
                {
                    // select solid
                    var select   = new[] { solid };
                    var deselect = !KeyboardState.Ctrl ? Document.Selection.GetSelectedObjects() : new MapObject[0];
                    Document.PerformAction("Select VM solid", new ChangeSelection(select, deselect));

                    // Don't do other click operations
                    return;
                }

                base.MouseDown(vp, e);
                return;
            }

            var vtx = vtxs.First();

            // When clicking, only select vertices in a single solid
            vtxs = vtxs.Where(x => x.Solid == vtx.Solid).ToList();

            // If any vertices are selected, don't change the selection yet
            if (!vtxs.Any(x => x.IsSelected))
            {
                _clickSelectionDone = true;
                DoSelection(vtxs, viewport);
            }

            // Only move selected vertices
            vtxs = vtxs.Where(x => x.IsSelected).ToList();
            if (!vtxs.Any())
            {
                return;
            }

            // Use the fist vertex as the control point
            _currentTool.DragStart(vtxs);
            MoveSelection    = vtxs;
            _snapPointOffset = SnapIfNeeded(viewport.Expand(viewport.ScreenToWorld(e.X, viewport.Height - e.Y))) - viewport.ZeroUnusedCoordinate(vtx.Coordinate);
            _movingPoint     = vtx;
        }
Beispiel #43
0
 /// <summary>
 /// Sets the the specified point on this frame to be at the same position
 /// as the corresponding point on the parent frame.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="x">The x offset.</param>
 /// <param name="y">The y offset.</param>
 public void SetPoint(Points point, int x, int y)
 {
     SetPoint(point, x, y, null, point);
 }
Beispiel #44
0
        private void AddVertex(string values)
        {
            var fields = Split(values);

            Points.Add(new Point3D(fields[0], fields[1], fields[2]));
        }
Beispiel #45
0
        public static Points ExtendWaySegments(Points pts, double delta)
        {
            var res = new Points();

            for (var idx = 1; idx < pts.Count; idx++)
            {
                EnumeratePointsBetween(pts[idx - 1], pts[idx], delta, point =>
                {
                    if (res.Count == 0 || !res[res.Count - 1].Equals(point))
                        res.Add(point);
                    return true;
                });
            }
            return res;
        }
Beispiel #46
0
 /// <summary>
 /// Sets the the specified point on this frame to be at the same position
 /// as the corresponding point on the parent frame.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="offset">The offset.</param>
 public void SetPoint(Points point, Int2D offset)
 {
     SetPoint(point, offset.X, offset.Y);
 }
        public Transform PlaceShip(ShipConstruct ship, ExBuildControl.Box vessel_bounds)
        {
            if (site == null) {
                return part.transform;
            }
            Transform xform;
            xform = part.FindModelTransform ("EL launch pos");

            var points = new Points (site);
            Transform t = part.transform;
            GameObject launchPos = new GameObject ("EL launch pos");
            launchPos.transform.parent = t;
            launchPos.transform.position = t.position;
            launchPos.transform.position += points.center - part.vessel.GetWorldPos3D ();
            launchPos.transform.rotation = GetOrientation (points);
            xform = launchPos.transform;
            Debug.Log (String.Format ("[EL] launchPos {0} {1}", xform.position, xform.rotation));

            float angle;
            Vector3 axis;
            xform.rotation.ToAngleAxis (out angle, out axis);

            Part rootPart = ship.parts[0].localRoot;
            Vector3 pos = rootPart.transform.position;
            Vector3 shift = points.ShiftBounds (xform, pos, vessel_bounds);
            shift += xform.position;
            rootPart.transform.Translate (shift, Space.World);
            rootPart.transform.RotateAround (xform.position,
                                                  axis, angle);
            return xform;
        }
Beispiel #48
0
 /// <summary>
 /// Sets the the specified point on this frame to be at the same position
 /// as the corresponding point on the parent frame.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="anchorFrame">The frame this frame is anchored to.</param>
 /// <param name="anchoredTo">The point on the anchorFrame to anchor to.</param>
 public void SetPoint(Points point, Int2D offset, Frame anchorFrame, Points anchoredTo)
 {
     SetPoint(point, offset.X, offset.Y, anchorFrame, anchoredTo);
 }
Beispiel #49
0
 public static bool Selected(this Points points, Points option)
 {
     return (points & option) == option;
 }
Beispiel #50
0
 // Use this for initialization
 void Start()
 {
     healthComponent = character.GetComponent <Health>();
     pointsComponent = character.GetComponent <Points>();
 }
Beispiel #51
0
        public Moves Do(ACar car, Points pts)
        {
            // Проверка что данный путь был выбран
            if (_selectThisTick + 1 != MyStrategy.world.Tick)
                _lastSuccessStack = null;

            Self = car.Clone();

            if (_lastCall == LastSuccess)
                LastSuccess = _lastCall;

            for (var t = 0; t < MyStrategy.world.Tick - _lastCall && _lastSuccessStack != null && _lastSuccessStack.Count > 0; t++)
            {
                _lastSuccessStack[0].Times--;
                _lastSuccessStack.Normalize();
            }
            if (_lastSuccessStack != null && (_lastSuccessStack.Count == 0 || _useDist2 && _lastSuccessStack.ComputeTime() < 30))
                _lastSuccessStack = null;

            _lastCall = MyStrategy.world.Tick;

            /*
             * Количество бонусов на расстоянии 0.5t
             * Если изменилось - пересчитывать сильно
             */
            var bonusesCount05 = MyStrategy.Bonuses
                .Count(bonus => Self.GetDistanceTo(bonus) < Const.TileSize / 2);

            /*
             * Количество бонусов на расстоянии 2t
             * Если изменилось - чуть нужно пересчитать
             */
            var bonusesCount2 = MyStrategy.Bonuses
                .Count(
                    bonus =>
                        Self.GetDistanceTo(bonus) < Const.TileSize*2 &&
                        MyStrategy.CellDistance(Self, bonus) <= 2);

            // Если был success на прошлом тике, то продолжаем. Или каждые _interval тиков.
            if (Const.Game.InitialFreezeDurationTicks < MyStrategy.world.Tick &&
                bonusesCount05 == _bonusesCount05 &&
                LastSuccess < MyStrategy.world.Tick - 1 &&
                (MyStrategy.world.Tick - (LastSuccess + 1))%_interval != 0)
            {
                _validateLastSuccessStack();
                return _lastSuccessStack;
            }

            /*
             * Смотрим на шины, которые на расстоянии не более 6 тайлов
             */
            var prevProj = _projCandidates;
            _projCandidates = MyStrategy.Tires
                .Where(
                    proj =>
                        Self.GetDistanceTo(proj[0]) <= Const.TileSize * 6 &&
                        MyStrategy.CellDistance(Self, proj[0]) <= 6)
                .ToArray();

            var extended = MyStrategy.ExtendWaySegments(pts, 50);
            _bruteWayPoints = extended.GetRange(0, Math.Min(_waypointsCount, extended.Count)).ToArray();
            if (LastStageMove.IsUseNitro && _turnsCount(_bruteWayPoints) > 1)
                return null;
            #if DEBUG
            var bruteWayPoints = new Points();
            bruteWayPoints.AddRange(_bruteWayPoints);
            Visualizer.SegmentsDrawQueue.Add(new object[]{ Brushes.Brown, bruteWayPoints, 0.0 });
            #endif
            _needDist = Const.TileSize*0.5 - 3;
            _needDist2 = Const.TileSize - 3;
            _turnTo = _bruteWayPoints[_bruteWayPoints.Length - 1];
            _turnTo2 = _bruteWayPoints[Math.Min(_bruteWayPoints.Length - 1, (int)(_bruteWayPoints.Length * 0.83))];
            #if DEBUG
            Visualizer.CircleFillQueue.Add(new Tuple<Brush, ACircularUnit>(Brushes.OrangeRed, new ACircularUnit { X = _turnTo.X, Y = _turnTo.Y, Radius = 20}));
            Visualizer.CircleFillQueue.Add(new Tuple<Brush, ACircularUnit>(Brushes.Orange, new ACircularUnit { X = _turnTo2.X, Y = _turnTo2.Y, Radius = 20 }));
            #endif

            _patterns = Patterns.Select(pt => new PathPattern
            {
                From = pt.From,
                To = pt.To,
                Step = pt.Step,
                Move = pt.Move.Clone()
            }).ToArray();
            foreach (var p in _patterns)
            {
                if (p.Move.WheelTurn is TurnPattern)
                {
                    var turnPattern = p.Move.WheelTurn as TurnPattern;
                    if (turnPattern.Pattern == TurnPatternType.ToNext)
                        p.Move.WheelTurn = Self.GetAngleTo(_turnTo) < 0 ? -1 : 1;
                    else if (turnPattern.Pattern == TurnPatternType.FromNext)
                        p.Move.WheelTurn = Self.GetAngleTo(_turnTo) < 0 ? 1 : -1;
                }
            }

            _movesStack = new Moves();
            _bestMovesStack = new Moves();
            _bestTime = MyStrategy.Infinity;
            _bestImportance = 0;

            /*
             * Смотрим на бонусы, которые на расстоянии не более 4t
             * TODO: уменьшить приоритет бонусов, которые может быть возьмет другой (в.т.ч тиммейт)
             */
            _bonusCandidates = MyStrategy.Bonuses
                .Where(
                    bonus =>
                        MyStrategy.world.Tick > 270 && // Не смотреть на бонусы при старте!!!
                        Self.GetDistanceTo(bonus) <= Const.TileSize * 4 &&
                        MyStrategy.CellDistance(Self, bonus) <= 4
                )
                .ToArray();

            /*
             * Смотрим на лужи, которые на расстоянии не более 5 тайлов
             */
            var prevSlicks = _slickCandidates;
            _slickCandidates = MyStrategy.OilSlicks
                .Where(
                    slick =>
                        Self.GetDistanceTo(slick) <= Const.TileSize*5 &&
                        MyStrategy.CellDistance(Self, slick) <= 5
                )
                .ToArray();

            /*
             * Пытаться объехать тех, которые
             * - Крашнулись
             * - Убиты
             * - Двигатель меньше чем на 0.5 мощности
             * - Двигаются по встречной
             *
             * - Если у меня нитро, или будет нитро
             *
             * - Своих
             */
            var prevCars = _carCandidates;
            _carCandidates = MyStrategy.Others
                .Where(opp => opp[0].GetDistanceTo(Self) < Const.TileSize*9)
                .Where(
                    opp =>
                        opp[0].Original.IsTeammate ||
                        MyStrategy.IsCrashed(opp[0].Original) ||
                        !DurabilityObserver.IsActive(opp[0].Original) ||
                        opp[0].EnginePower < 0.5 ||
                        Self.RemainingNitroTicks > 0 ||
                        Math.Abs(Geom.GetAngleBetween(Self.Speed, opp[0].Speed)) > Math.PI / 2
                )
                .Where(opp => MyStrategy.CellDistance(Self, opp[0]) <= 9) // 9 - потому что он может ехать по встречке
                .ToArray();

            if (_cache != null)
            {
                for (var k = 0; k < _patterns.Length; k++)
                {
                    var range = (prevSlicks == null || prevCars == null || prevProj == null
                        || _bonusesCount2 != bonusesCount2
                        || prevSlicks.Length != _slickCandidates.Length
                        || prevCars.Length != _carCandidates.Length
                        || prevProj.Length != _projCandidates.Length)
                        ? (k == 0 ? 6 : 4)
                        : (k == 0 ? 6 : 2);

                    if (_bonusesCount05 != bonusesCount05 || Special && k == 0)
                        range = 10;

                    _patterns[k].From = Math.Max(0, _cache[k].Times - range);
                    _patterns[k].To = Math.Min(_patterns[k].To * 9 / 7, _cache[k].Times + range);
                    _patterns[k].Step = 2;
                }
            }

            _bonusesCount05 = bonusesCount05;
            _bonusesCount2 = bonusesCount2;

            var wayPointRequired = false;
            for(var i = _bruteWayPoints.Length - 1; i >= 0; i--)
            {
                if (_bruteWayPoints[i].GetDistanceTo2(_turnTo) < _needDist*_needDist)
                {
                    for (var j = 0; j < i; j++)
                        wayPointRequired |=
                            MyStrategy.GetNextWayPoint(Self.Original).Equals(MyStrategy.GetCell(_bruteWayPoints[j]));
                    break;
                }
            }

            _doRecursive(Self, 0, new PassedInfo { WayPoint = !wayPointRequired });
            _cache = null;
            if (_bestTime == MyStrategy.Infinity)
                return _lastSuccessStack;

            if (_bestMovesStack.ComputeTime() != _bestTime)
                throw new Exception("ComputeTime != BestTime");

            LastSuccess = MyStrategy.world.Tick;
            _cache = _bestMovesStack.Clone();

            if (_maxTicksInfo == null)
                _maxTicksInfo = new int[_bestMovesStack.Count];
            for (var i = 0; i < _maxTicksInfo.Length; i++)
                _maxTicksInfo[i] = Math.Max(_maxTicksInfo[i], _bestMovesStack[i].Times);

            _bestMovesStack.Normalize();
            _lastSuccessStack = _bestMovesStack.Clone();
            return _bestMovesStack;
        }
Beispiel #52
0
        private void NewWorld()
        {
            var nwDialog = new NewWorldView();

            if ((bool)nwDialog.ShowDialog())
            {
                _loadTimer.Reset();
                _loadTimer.Start();
                _saveTimer.Stop();
                Task.Factory.StartNew(() =>
                {
                    World w       = nwDialog.NewWorld;
                    w.SpawnX      = w.TilesWide / 2;
                    w.SpawnY      = (int)Math.Max(0, w.GroundLevel - 10);
                    w.GroundLevel = (int)w.GroundLevel;
                    w.RockLevel   = (int)w.RockLevel;
                    w.BottomWorld = w.TilesHigh * 16;
                    w.RightWorld  = w.TilesWide * 16;
                    w.Tiles       = new Tile[w.TilesWide, w.TilesHigh];
                    var cloneTile = new Tile();
                    for (int y = 0; y < w.TilesHigh; y++)
                    {
                        OnProgressChanged(w, new ProgressChangedEventArgs(Calc.ProgressPercentage(y, w.TilesHigh), "生成世界中..."));

                        if (y == (int)w.GroundLevel - 10)
                        {
                            cloneTile = new Tile {
                                WireRed = false, IsActive = true, LiquidType = LiquidType.None, LiquidAmount = 0, Type = 2, U = -1, V = -1, Wall = 2
                            }
                        }
                        ;
                        if (y == (int)w.GroundLevel - 9)
                        {
                            cloneTile = new Tile {
                                WireRed = false, IsActive = true, LiquidType = LiquidType.None, LiquidAmount = 0, Type = 0, U = -1, V = -1, Wall = 2
                            }
                        }
                        ;
                        else if (y == (int)w.GroundLevel + 1)
                        {
                            cloneTile = new Tile {
                                WireRed = false, IsActive = true, LiquidType = LiquidType.None, LiquidAmount = 0, Type = 0, U = -1, V = -1, Wall = 0
                            }
                        }
                        ;
                        else if (y == (int)w.RockLevel)
                        {
                            cloneTile = new Tile {
                                WireRed = false, IsActive = true, LiquidType = LiquidType.None, LiquidAmount = 0, Type = 1, U = -1, V = -1, Wall = 0
                            }
                        }
                        ;
                        else if (y == w.TilesHigh - 182)
                        {
                            cloneTile = new Tile();
                        }
                        for (int x = 0; x < w.TilesWide; x++)
                        {
                            w.Tiles[x, y] = (Tile)cloneTile.Clone();
                        }
                    }
                    return(w);
                })
                .ContinueWith(t => CurrentWorld = t.Result, TaskFactoryHelper.UiTaskScheduler)
                .ContinueWith(t => RenderEntireWorld())
                .ContinueWith(t =>
                {
                    CurrentFile = null;
                    PixelMap    = t.Result;
                    UpdateTitle();
                    Points.Clear();
                    Points.Add("出生点");     // PointTool.MouseDown 判定
                    Points.Add("地牢");
                    foreach (NPC npc in CurrentWorld.NPCs)
                    {
                        Points.Add(npc.Name);
                    }
                    MinimapImage = RenderMiniMap.Render(CurrentWorld);
                    _loadTimer.Stop();
                    OnProgressChanged(this, new ProgressChangedEventArgs(0, string.Format("加载世界耗时 {0} 秒.", _loadTimer.Elapsed.TotalSeconds)));
                    _saveTimer.Start();
                }, TaskFactoryHelper.UiTaskScheduler);
            }
        }
Beispiel #53
0
 /// <summary>
 /// Sets the the specified point on this frame to be at the same position
 /// as the corresponding point on the parent frame.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="x">The x offset.</param>
 /// <param name="y">The y offset.</param>
 public void SetPoint(Points point, int x, int y)
 {
     SetPoint(point, x, y, null, point);
 }
Beispiel #54
0
 /// <summary>
 /// returns the next point in the list
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 public Point GetNextPoint(Point point)
 {
     return(this.Points.ElementAt(Points.FindIndex(x => x == point) + 1));
 }
Beispiel #55
0
 /// <summary>
 /// Sets the the specified point on this frame to be at the same position
 /// as the corresponding point on the parent frame.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="anchorFrame">The frame this frame is anchored to.</param>
 /// <param name="anchoredTo">The point on the anchorFrame to anchor to.</param>
 public void SetPoint(Points point, Int2D offset, Frame anchorFrame, Points anchoredTo)
 {
     SetPoint(point, offset.X, offset.Y, anchorFrame, anchoredTo);
 }
Beispiel #56
0
 /// <summary>
 /// checkls if the first point of the list has a car on it.
 /// </summary>
 /// <returns></returns>
 public bool IsFirstPointEmpty()
 {
     return(Cars.Exists(x => x.CurPoint == Points.First()));
 }
Beispiel #57
0
 public static void DrawWireRegionFromTerrain(Points points, float penWidth, Color color)
 {
     Binding.FCE_Draw_WireRegionFromTerrain(points.Pointer, penWidth, (float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f);
 }
Beispiel #58
0
 public static T Points <T>(this T polygon, Points value) where T : IPolygon
 {
     polygon.Points = value;
     return(polygon);
 }
        private static void Main()
        {
            string command;
            char[,] board = CreateBoard();
            char[,] mines = PlaceMines();
            int counter = 0;
            bool isMine = false;
            List<Points> highScores = new List<Points>(6);
            int row = 0;
            int column = 0;
            bool inGame = true;
            const int MaxScore = 35;
            bool maxResultAchieved = false;

            do
            {
                if (inGame)
                {
                    Console.WriteLine("Lets play MineSweeper. Try to find the free from mines fields." +
                        "The 'top' command shows the current standings, 'restart' starts a new game, 'exit'" +
                        "quits the game.");
                    PrintBoard(board);
                    inGame = false;
                }

                Console.Write("Enter row and column: ");
                command = Console.ReadLine().Trim();

                if (command != null && command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out row) &&
                        int.TryParse(command[2].ToString(), out column) &&
                        row <= board.GetLength(0) && column <= board.GetLength(1))
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                    case "top":
                        PrintHighscores(highScores);
                        break;

                    case "restart":
                        board = CreateBoard();
                        mines = PlaceMines();
                        PrintBoard(board);
                        break;

                    case "exit":
                        Console.WriteLine("Bye, bye!");
                        break;

                    case "turn":
                        if (mines[row, column] != '*')
                        {
                            if (mines[row, column] == '-')
                            {
                                PlayerTurn(board, mines, row, column);
                                counter++;
                            }

                            if (MaxScore == counter)
                            {
                                maxResultAchieved = true;
                            }
                            else
                            {
                                PrintBoard(board);
                            }
                        }
                        else
                        {
                            isMine = true;
                        }

                        break;
                    default:
                        Console.WriteLine("\nError! Invalid command!\n");
                        break;
                }

                if (isMine)
                {
                    PrintBoard(mines);
                    Console.Write("\nBOOM! You died heroically with {0} points. Enter your nickname: ", counter);
                    string nickname = Console.ReadLine();
                    Points result = new Points(nickname, counter);

                    if (highScores.Count < 5)
                    {
                        highScores.Add(result);
                    }
                    else
                    {
                        for (int i = 0; i < highScores.Count; i++)
                        {
                            if (highScores[i].UserPoints < result.UserPoints)
                            {
                                highScores.Insert(i, result);
                                highScores.RemoveAt(highScores.Count - 1);
                                break;
                            }
                        }
                    }

                    highScores.Sort((result1, result2) => string.Compare(
                        result2.UserName,
                        result1.UserName,
                        StringComparison.Ordinal));
                    highScores.Sort((result1, result2) => result2.UserPoints.CompareTo(result1.UserPoints));
                    PrintHighscores(highScores);

                    board = CreateBoard();
                    mines = PlaceMines();
                    counter = 0;
                    isMine = false;
                    inGame = true;
                }

                if (maxResultAchieved)
                {
                    Console.WriteLine("\nCongratulations! You opened 35 cells!");
                    PrintBoard(mines);
                    Console.WriteLine("Enter your name: ");
                    string name = Console.ReadLine();
                    Points result = new Points(name, counter);
                    highScores.Add(result);
                    PrintHighscores(highScores);
                    board = CreateBoard();
                    mines = PlaceMines();
                    counter = 0;
                    maxResultAchieved = false;
                    inGame = true;
                }
            }
            while (command != "exit");
            Console.WriteLine("Made in Bulgaria");
            Console.Read();
        }
Beispiel #60
0
 private List <AreaPoints> GenerateAreaPointsList(int countOfClasses)
 => Points.GenerateCenters(countOfClasses).Select(x => new AreaPoints(x)).ToList();