コード例 #1
0
 public override void Update()
 {
     base.Update();
     rotation += speed;
     FP.AnchorTo(ref theRazor.X, ref theRazor.Y, X, Y, razorArm.ScaledWidth);
     FP.RotateAround(ref theRazor.X, ref theRazor.Y, X, Y, rotation, false);
     razorArm.Angle = rotation;
 }
コード例 #2
0
ファイル: EmptyPart.cs プロジェクト: Tankooni/shoe-polish
        public override void Update()
        {
            base.Update();


            CenterOrigin();

            FP.AnchorTo(ref X, ref Y, myShip.X, myShip.Y, Distance, Distance);
            FP.RotateAround(ref X, ref Y, myShip.X, myShip.Y, myShip.ShipCenter.Angle + angle, false);
        }
コード例 #3
0
ファイル: Part.cs プロジェクト: Tankooni/shoe-polish
        public override void Update()
        {
            base.Update();

            if (health <= 0)
            {
                if (myShip != null)
                {
                    if (myShip as Ship == null)
                    {
                        List <PartBase> temp = myShip.shipParts;
                        World.Remove(myShip);
                        for (int i = 0; i < temp.Count; i++)
                        {
                            if (temp[i].MyType != 0)
                            {
                                Part replacementPart = new Part(temp[i].MyType);
                                replacementPart.X = temp[i].X;
                                replacementPart.Y = temp[i].Y;
                                World.Add(replacementPart);
                            }

                            World.Remove(temp[i]);
                        }
                        World.Remove(myShip);
                    }
                    else
                    {
                        World.Add(new EmptyPart(myShip, curCol, curRow, curCol, curRow));
                        World.Remove(this);
                        if (myShip.shipParts.Count <= 0)
                        {
                            var Title = new Text("Game Over! Press R to Restart The Game.", 100, FP.HalfHeight - 200, 0, 0);
                            Title.Size = 100;
                            AddGraphic(Title);
                        }
                    }
                }
                else
                {
                    World.Remove(this);
                }
            }

            if (Attached)
            {
                SetHitboxTo(aPart);
                aPart.CenterOO();
                CenterOrigin();

                FP.AnchorTo(ref X, ref Y, myShip.X, myShip.Y, Distance, Distance);
                FP.RotateAround(ref X, ref Y, myShip.X, myShip.Y, myShip.ShipCenter.Angle + angle, false);

                aPart.Angle = myShip.ShipCenter.Angle;

                if (PartNum == 3)
                {
                    //FP.Log(FP.Angle(X, Y, World.MouseX, World.MouseY));

                    if (myShip.ShipCenter.Angle + 2 > 360)
                    {
                        myShip.ShipCenter.Angle = (myShip.ShipCenter.Angle + 2) - 360;
                    }
                    if (myShip.ShipCenter.Angle - 2 <= 0)
                    {
                        myShip.ShipCenter.Angle = (myShip.ShipCenter.Angle - 2) + 360;
                    }


                    if ((myShip.ShipCenter.Angle + 45 > FP.Angle(X, Y, World.MouseX, World.MouseY)) && (myShip.ShipCenter.Angle - 45 < FP.Angle(X, Y, World.MouseX, World.MouseY)))
                    {
                        aPart.Angle = FP.Angle(X, Y, World.MouseX, World.MouseY);
                        if (Mouse.IsButtonPressed(Mouse.Button.Right))
                        {
                            TurretSfx.Volume = FP.Random * 20 + 20;
                            TurretSfx.Pitch  = FP.Random * .3f + .2f;
                            TurretSfx.Play();

                            World.Add(new Bullet(X, Y, new Vector2f((float)Math.Cos(aPart.Angle * FP.RAD) * 5, (float)Math.Sin(aPart.Angle * FP.RAD) * 5), myShip));
                        }
                        else
                        {
                            //TurretSfx.Pitch = .01f; //+ 0.5f;
                        }
                    }
                    else
                    {
                        //TurretSfx.Pitch = .01f; //+ 0.5f;
                        aPart.Angle = myShip.ShipCenter.Angle;
                    }
                }
                else
                {
                    aPart.Angle = myShip.ShipCenter.Angle + rotationOffSet;
                }
            }
            else
            {
                SetHitboxTo(aPart);
                aPart.CenterOO();
                CenterOrigin();
                EmptyPart temp = World.CollideRect("EmptyPart", X, Y, Width, Height) as EmptyPart;
                if (temp != null)
                {
                    float t   = (float)Math.Atan2(temp.curRow - temp.parentRow, temp.curCol - temp.parentCol);
                    Part  add = new Part(temp.myShip, MyType, temp.curCol, temp.curRow);
                    add.rotationOffSet = (t * FP.DEG) - 90;
                    add.rotationOffSet = (float)Math.Round(add.rotationOffSet);
                    if (add.rotationOffSet < 0.0002 && add.rotationOffSet > -0.0002)
                    {
                        add.rotationOffSet = 0;
                    }
                    World.Add(add);
                    World.Remove(temp);
                    World.Remove(this);
                }

                if (Input.Pressed(Mouse.Button.Left))
                {
                    if (World.CollidePoint("Part", World.MouseX, World.MouseY) == this)
                    {
                        Dragging = true;
                    }
                }
                else if (Input.Released(Mouse.Button.Left))
                {
                    Dragging = false;
                }

                if (Dragging)
                {
                    X      = World.MouseX;
                    Y      = World.MouseY;
                    Flying = false;
                }
                if (Flying)
                {
                    X += FP.Rand(2);
                    Y += FP.Rand(2);
                }
            }
            //aPart.Color = FP.Color(0x000000);
            aPart.Color = new SFML.Graphics.Color((byte)(byte)(FP.Clamp <int>((int)((health / totalHealth) * 255), 0, 255)), (byte)(byte)(FP.Clamp <int>((int)((health / totalHealth) * 255), 0, 255)), (byte)(byte)(FP.Clamp <int>((int)((health / totalHealth) * 255), 0, 255)));
        }