public override void Update() { base.Update(); if (!OnCamera) { var offX = Left > FP.Width || Right < 0; var offY = Top > FP.Height || Bottom < 0; if (offX && offY) { World.Remove(this); } } var l = new List <Entity>(); CollideInto(Player.Collision, X, Y, l); foreach (var p in l) { var player = p as Player; if (player != owner) { if (player.Rebounding) { World.BroadcastMessage(CameraManager.Message.Shake, 10.0f, 0.5f); Mixer.Hit1.Play(); var angle = FP.Angle(player.X, player.Y, owner.X, owner.Y); FP.AngleXY(ref direction.X, ref direction.Y, angle, 1); owner = player; } } if (player != owner) { if (!player.Invincible) { World.BroadcastMessage(CameraManager.Message.Shake, 10.0f, 0.5f); Mixer.Hit1.Play(); var force = ForceMultiplier * Fist.BASE_PUNCH_FORCE; var dir = direction.Normalized(); player.OnMessage(PhysicsBody.Message.Impulse, force * dir.X, force * dir.Y); } } } image.Angle = FP.Angle(0, 0, direction.X, direction.Y); direction.Normalize(FistSpeed); var rainbow = World.Add(new RainbowTrail(X, Y, direction, image.Scale, FistSpeed, Layer)); X += direction.X; Y += direction.Y; }
public override void Update() { if (this.commands == null) { World.Remove(this); return; } //make the wheel spin wheel.Angle -= 1; //keep track of mouse movement direction Point cMouse = new Point(Mouse.ScreenX, Mouse.ScreenY); int angle = (int)FP.Angle(cMouse.X, cMouse.Y, this.X, this.Y); if (commands != null && commands.Length > 0) { if (lastMouse != cMouse) { //check which command is being selected int deginc = 360 / commands.Length; //turn angle to '0' angle += deginc / 2 + 270; //find index of the command angle /= deginc; angle %= commands.Length; lastc = commands[angle]; //clear the last update scaling foreach (var img in commandImages.Values) { img.Scale = 1; } // Make it bigger to show its selected commandImages[lastc].Scale = 2; } } //Fire it if clicked if (Mouse.Left.Pressed) { if (lastc != null && lastc.Actions != null && lastc.Actions.Length > 0) { Action.runActions(lastc.Actions); World.Remove(this); } } else if (Mouse.Right.Pressed) { World.Remove(this); } //update last mouse lastMouse = cMouse; }
public override void Update() { base.Update(); cursor.Visible = Visible = Parent.World != null && !Parent.OnCamera; cursor.X = Parent.X - Parent.HalfWidth; cursor.Y = Parent.Y - Parent.HalfHeight; FP.ClampInRect(ref cursor.X, ref cursor.Y, FP.Camera.X - FP.HalfWidth, FP.Camera.Y - FP.HalfHeight, FP.Width, FP.Height, 25); image.Angle = FP.Angle(FP.Camera.X, FP.Camera.Y, cursor.X, cursor.Y); }
public override void Update() { base.Update(); var rand = FP.Random.InCircle(25); World.BroadcastMessage(GlobalEmitter.Message.BulletTrail, "spark", X + rand.X, Y + rand.Y); image.Angle = FP.Angle(0, 0, dir.X, dir.Y); MoveBy(dir.X * BULLET_SPEED, dir.Y * BULLET_SPEED, colliders, true); }
public RainbowTrail(float x, float y, Point direction, float scale, float FIST_SPEED, int layer) { X = x; Y = y; Layer = layer + 1; sineticks = 0; rainbow = new Image(Library.GetTexture("rainbow.png")); rainbow.CenterOO(); rainbow.Alpha = 0.5f; rainbow.Scale = scale; rainbow.Angle = FP.Angle(0, 0, direction.X, direction.Y); rainbow.ScaleX = rainbow.ScaledWidth / (FIST_SPEED / 2); rainbow.ScaleY = 0.75f; AddComponent(rainbow); var duration = 0.75f; Tweener.Tween(rainbow, new { Alpha = 0, ScaleY = 0 }, duration) .OnComplete(() => World.Remove(this)); }
public override void Update() { base.Update(); var currentAnimaion = this.CheckAnimation(); if (Keyboard.Space.Pressed) { switch (InteractiveObjectRef.Attributes["AvatarSpriteState"]) { case 0: InteractiveObjectRef.Attributes["AvatarSpriteState"] = 1; break; case 1: InteractiveObjectRef.Attributes["AvatarSpriteState"] = 2; break; case 2: InteractiveObjectRef.Attributes["AvatarSpriteState"] = 3; break; case 3: InteractiveObjectRef.Attributes["AvatarSpriteState"] = 0; break; default: break; } } if (InventoryObject) { if (currentAnimaion != "Idle" + InteractiveObjectRef.Attributes["AvatarSpriteState"]) { PlayAnimation("Idle" + InteractiveObjectRef.Attributes["AvatarSpriteState"]); } return; } if (IsMoving) { this.MoveToward(walkToX, walkToY, FP.Elapsed * this.MoveSpeedX, FP.Elapsed * this.MoveSpeedY); //Trigger event if needed var worldMetadata = ((DynamicSceneWorld)World).metaData; if (worldMetadata.Regions != null) { foreach (var r in worldMetadata.Regions) { if (r.Area.Contains(X, Y)) { if (!wasInRegion[r]) { //just entered, execute shit Action.runActions(r.OnEnter); wasInRegion[r] = true; } } else { if (wasInRegion[r]) { //just left region, execute other shit Action.runActions(r.OnExit); wasInRegion[r] = false; } } } } //Animation stuff List <int> footFallFrameNumbers; footFallFrames.TryGetValue(currentAnimaion, out footFallFrameNumbers); if (footFallFrameNumbers != null && footFallFrameNumbers.Contains(sprite.Frame) && lastFootFrame != sprite.Frame) { lastFootFrame = sprite.Frame; SoundManager.PlaySoundVariations("footstepL", .8f, .9f); } if (pathNodes != null) { if ((int)X == (int)walkToX && (int)Y == (int)walkToY) { if (pathNodes.MoveNext()) { walkToX = pathNodes.Current.X; walkToY = pathNodes.Current.Y; } else { PlayAnimation("Idle" + InteractiveObjectRef.Attributes["AvatarSpriteState"]); pathNodes = null; IsMoving = false; return; } } var walkAngle = FP.Angle(this.X, this.Y, walkToX, walkToY); bool flip = walkAngle >= 90 && walkAngle <= 270; if (Flipped != flip) { Flipped = flip; } if (currentAnimaion != ("WalkDown" + InteractiveObjectRef.Attributes["AvatarSpriteState"]) && (walkAngle >= 0 && walkAngle <= 180)) { PlayAnimation("WalkDown" + InteractiveObjectRef.Attributes["AvatarSpriteState"]); } else if (currentAnimaion != ("WalkUp" + +InteractiveObjectRef.Attributes["AvatarSpriteState"]) && walkAngle > 180 && walkAngle < 360) { PlayAnimation("WalkUp" + InteractiveObjectRef.Attributes["AvatarSpriteState"]); } } } }
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))); }