public void AddObject(GraphicObject g) { if (Objects == null) Objects = new List<GraphicObject>(); Objects.Add(g); }
public override void Intersection(Collision c, GraphicObject g) { base.Intersection(c, g); switch (g.OT) { case ObjectType.OT_BlockQuestion: { int a = 1; } break; case ObjectType.OT_Goomba: { DirX *= -1; OnWalk(null, null); ((MonsterGoomba)g).DirX *= -1; ((MonsterGoomba)g).OnWalk(null, null); } break; case ObjectType.OT_Mario: { Mario m = (Mario)g; if (c.Dir != CollisionDirection.CD_Down) { if (!m.Blinking) if (m.Type == Mario.MarioType.MT_Big || m.Type == Mario.MarioType.MT_Fire) { m.Type = Mario.MarioType.MT_Small; m.StartBlinking(); m.SetMarioProperties(); } } } break; } }
public override void Intersection(Collision c, GraphicObject g) { base.Intersection(c, g); switch (g.OT) { case ObjectType.OT_BlockQuestion: goto case ObjectType.OT_Grass; case ObjectType.OT_Grass: { if (c.Dir == CollisionDirection.CD_Up) { Fall = false; } } break; case ObjectType.OT_Brick: goto case ObjectType.OT_PipeUp; case ObjectType.OT_Pirana: goto case ObjectType.OT_PipeUp; case ObjectType.OT_SolidBlock: goto case ObjectType.OT_PipeUp; case ObjectType.OT_PipeUp: { if (c.Dir == CollisionDirection.CD_Left || c.Dir == CollisionDirection.CD_Right) { Fall = false; DirX *= -1; OnWalk(null, null); } } break; } }
public void AddObject(GraphicObject g) { if (g.Objects != null) for (int i = 0; i < g.Objects.Count; i++) AddObject(g.Objects[i]); Objects.Add(g); }
public override void Intersection(Collision c, GraphicObject g) { base.Intersection(c, g); switch (g.OT) { case ObjectType.OT_SolidBlock: goto case ObjectType.OT_PipeUp; case ObjectType.OT_BlockQuestion: goto case ObjectType.OT_Grass; case ObjectType.OT_Brick: goto case ObjectType.OT_Grass; case ObjectType.OT_Grass: { StartFireBall(); } break; case ObjectType.OT_PipeUp: { Started = false; Visible = false; } break; case ObjectType.OT_Goomba: { if (Type == FireBallType.FT_Mario) { ((MonsterGoomba)g).GoombaFallDie(); Started = false; Visible = false; } } break; case ObjectType.OT_Koopa: { if (Type == FireBallType.FT_Mario) { ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_Shield); Started = false; Visible = false; } } break; case ObjectType.OT_Pirana: { if (Type == FireBallType.FT_Mario) { ((MonsterPiranah)g).Visible = false; ((MonsterPiranah)g).Live = false; } } break; } }
public override void Intersection(Collision c, GraphicObject g) { base.Intersection(c, g); switch (g.OT) { case ObjectType.OT_Brick: { if (State == KoopaState.KS_ShieldMoving) { if (c.Dir == CollisionDirection.CD_Left || c.Dir == CollisionDirection.CD_Right) ((BlockBrick)g).BreakBrick(); } } break; case ObjectType.OT_Goomba: { if (State == KoopaState.KS_ShieldMoving) { ((MonsterGoomba)g).GoombaFallDie(); } if (State == KoopaState.KS_Walking) { ((MonsterGoomba)g).DirX *= -1; ((MonsterGoomba)g).newx += 5 * ((MonsterGoomba)g).DirX; ((MonsterGoomba)g).OnWalk(null, null); DirX *= -1; OnWalk(null, null); } if (State == KoopaState.KS_Shield) { ((MonsterGoomba)g).DirX *= -1; ((MonsterGoomba)g).newx += 5 * ((MonsterGoomba)g).DirX; ((MonsterGoomba)g).OnWalk(null, null); } } break; case ObjectType.OT_Mario: { if (State == KoopaState.KS_Shield && ReturningTime >= 3) { if (c.Dir == CollisionDirection.CD_Left) DirX = -1; if (c.Dir == CollisionDirection.CD_Right) DirX = 1; SetKoopaState(KoopaState.KS_ShieldMoving); } } break; } }
public override void Intersection(Collision c, GraphicObject g) { base.Intersection(c, g); switch (g.OT) { case ObjectType.OT_Goomba: { int a = 2; } break; case ObjectType.OT_Mario: { } break; } }
public void CreateHidden(ObjectType hidden) { switch (hidden) { case ObjectType.OT_Coin: HiddenObject = new CoinBlock(x, y, true); break; case ObjectType.OT_Mush: HiddenObject = new MushRed(x, y + 1); break; case ObjectType.OT_MushLife: HiddenObject = new MushLife(x, y + 1); break; case ObjectType.OT_Flower: HiddenObject = new Flower(x, y + 1); break; } AddObject(HiddenObject); }
public Collision Intersects(GraphicObject SrcObject, GraphicObject DestObject) { Rectangle Src = SrcObject.GetObjectRect(); Rectangle Dest = DestObject.GetObjectRect(); if (Src.X + Src.Width < Dest.X) return null; if (Src.Y + Src.Height < Dest.Y) return null; if (Src.X > Dest.X + Dest.Width) return null; if (Src.Y > Dest.Y + Dest.Height) return null; CollisionDirection Dir = CollisionDirection.CD_Down; int H, W; //Point ButtomRight = new Point(Src.X + Src.Width, Src.Y + Src.Height); //Point ButtomLeft = new Point(Src.X, Src.Y + Src.Height); //Point TopRight = new Point(Src.X + Src.Width, Src.Y); //Point TopLeft = new Point(Src.X, Src.Y); ButtomRight.X = Src.X + Src.Width; ButtomRight.Y = Src.Y + Src.Height; ButtomLeft.X = Src.X; ButtomLeft.Y = Src.Y + Src.Height; TopRight.X = Src.X + Src.Width; TopRight.Y = Src.Y; TopLeft.X = Src.X; TopLeft.Y = Src.Y; Boolean Found = false; if (Contains(ButtomRight, Dest)) //if (Dest.Contains(ButtomRight)) { Found = true; W = ButtomRight.X - Dest.X; H = ButtomRight.Y - Dest.Y; if (W > H) Dir = CollisionDirection.CD_Up; else if (H > W) Dir = CollisionDirection.CD_Left; else Dir = CollisionDirection.CD_TopLeft; } if (Contains(ButtomLeft, Dest)) // if (Dest.Contains(ButtomLeft)) { Found = true; W = Dest.X + Dest.Width - ButtomLeft.X; H = ButtomLeft.Y - Dest.Y; if (W > H) Dir = CollisionDirection.CD_Up; else if (H > W) Dir = CollisionDirection.CD_Right; else Dir = CollisionDirection.CD_TopRight; } if (Contains(TopRight, Dest)) // if (Dest.Contains(TopRight)) { Found = true; W = TopRight.X - Dest.X; H = Dest.Y + Dest.Height - TopRight.Y; if (W > H) Dir = CollisionDirection.CD_Down; else Dir = CollisionDirection.CD_Left; } if (Contains(TopLeft, Dest)) // if (Dest.Contains(TopLeft)) { Found = true; W = Dest.X + Dest.Width - TopLeft.X; H = Dest.Y + Dest.Height - TopLeft.Y;// -5; //Bug if (W > H) Dir = CollisionDirection.CD_Down; else Dir = CollisionDirection.CD_Right; } if (Found == false) return null; else { // For Better Performance..... MainColision.Src = Src; MainColision.Dest = Dest; MainColision.Dir = Dir; MainColision.Type = CollisionType.CT_Moveable; return MainColision; // Old One //return new Collision(Src, Dest, CollisionType.CT_Moveable, Dir); } }
public override void Intersection(Collision c, GraphicObject g) { base.Intersection(c, g); switch (g.OT) { case ObjectType.OT_Exit: { if (UpPressed) { UpPressed = false; System.Windows.Forms.MessageBox.Show("Very Good !"); } } break; case ObjectType.OT_Flower: { ((Flower)g).Visible = false; if (Type != MarioType.MT_Fire) { Type = MarioType.MT_Fire; SetMarioProperties(); Media.PlaySound(Media.SoundType.ST_Mush); } } break; case ObjectType.OT_Mush: { ((MushRed)g).Visible = false; ((MushRed)g).Animated = false; ((MushRed)g).Live = false; if (Type == MarioType.MT_Small) { Type = MarioType.MT_Big; SetMarioProperties(); Media.PlaySound(Media.SoundType.ST_Mush); } } break; case ObjectType.OT_Coin: { ((CoinBlock)g).Animated = false; ((CoinBlock)g).Visible = false; Media.PlaySound(Media.SoundType.ST_Coin); } break; case ObjectType.OT_Goomba: { if (c.Dir == CollisionDirection.CD_Up) { // Jump On Goomba with Control Presses if (((MonsterGoomba)g).FallDie == false) { if (ControlPressed) StartJump(true, 0); else StartJump(true, -20); ((MonsterGoomba)g).GoombaDie(); Media.PlaySound(Media.SoundType.ST_Stomp); } } } break; case ObjectType.OT_Koopa: { if (c.Dir == CollisionDirection.CD_Up) { // Jump On Koopa with Control Presses if (((MonsterKoopa)g).State == MonsterKoopa.KoopaState.KS_Walking) { if (ControlPressed) StartJump(true, 0); else StartJump(true, -20); ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_Shield); Media.PlaySound(Media.SoundType.ST_Stomp); } else if ((((MonsterKoopa)g).State == MonsterKoopa.KoopaState.KS_Shield) && (((MonsterKoopa)g).ReturningTime >= 3)) { ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_ShieldMoving); } else if (((MonsterKoopa)g).State == MonsterKoopa.KoopaState.KS_ShieldMoving) { if (ControlPressed) StartJump(true, 0); else StartJump(true, -20); ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_Shield); } } } break; case ObjectType.OT_MovingBlock: goto case ObjectType.OT_Grass; case ObjectType.OT_SolidBlock: goto case ObjectType.OT_Grass; case ObjectType.OT_PipeUp: goto case ObjectType.OT_Grass; case ObjectType.OT_BlockQuestion: goto case ObjectType.OT_Grass; case ObjectType.OT_BlockQuestionHidden: goto case ObjectType.OT_Grass; case ObjectType.OT_Brick: goto case ObjectType.OT_Grass; case ObjectType.OT_Grass: { SetDirections(); if (c.Dir == CollisionDirection.CD_TopLeft) { if (g.OT == ObjectType.OT_Brick) { //if (MoveState == MarioMoveState.J_Right) // x -= (int)XAdd; //if (MoveState == MarioMoveState.J_Left) // x += (int)XAdd; //Intersection_None(); } } if (c.Dir == CollisionDirection.CD_Up) { if (g.OT == ObjectType.OT_MovingBlock) { this.y = g.newy - this.height; ((BlockMoving)g).MarioOn = true; } else { if (State != MarioJumpState.J_None) this.y = g.newy - this.height; } if (State != MarioJumpState.J_None) State = MarioJumpState.J_None; SetDirections(); } if (c.Dir == CollisionDirection.CD_Left) { this.x = g.newx - width; //if (g.OT == ObjectType.OT_SolidBlock) // Intersection_None(); if (g.OT == ObjectType.OT_Brick) { //if (MoveState == MarioMoveState.J_Right) // x -= (int)XAdd; //if (MoveState == MarioMoveState.J_Left) // x += (int)XAdd; this.x = g.newx - width; } } if (c.Dir == CollisionDirection.CD_Down) { if (State == MarioJumpState.J_Up) { State = MarioJumpState.JDown; StartPosition = y; TimeCount = 0; StartVelocity = 0; if (g.OT == ObjectType.OT_BlockQuestion || g.OT == ObjectType.OT_BlockQuestionHidden) { ((BlockQuestion)g).isMonsterExist(); ((BlockQuestion)g).StartMove(); if (((BlockQuestion)g).HiddenObject.OT != ObjectType.OT_Coin) Media.PlaySound(Media.SoundType.ST_Block); } if (g.OT == ObjectType.OT_Brick) { if (Type == MarioType.MT_Big || Type == MarioType.MT_Fire) { ((BlockBrick)g).BreakBrick(); Media.PlaySound(Media.SoundType.ST_Brick); } else { Media.PlaySound(Media.SoundType.ST_Block); } } } } if (c.Dir == CollisionDirection.CD_Right) { this.x = g.newx + g.width; //if (g.OT == ObjectType.OT_SolidBlock) // Intersection_None(); //XAdd = 0; } } break; } }
public void AddObject(int x, int y, GraphicObject Object) { }
public IntersectionClass(Collision _C, GraphicObject _G, Intersects_Event _E) { C = _C; G = _G; E = _E; }
public override void Action(GraphicObject g) { base.Action(g); g.CheckObjectEnabled(); }
public virtual void Action(GraphicObject g) { }
public Collision Intersects(GraphicObject SrcObject, GraphicObject DestObject) { Rectangle Src = SrcObject.GetObjectRect(); Rectangle Dest = DestObject.GetObjectRect(); if (Src.X + Src.Width < Dest.X) { return(null); } if (Src.Y + Src.Height < Dest.Y) { return(null); } if (Src.X > Dest.X + Dest.Width) { return(null); } if (Src.Y > Dest.Y + Dest.Height) { return(null); } CollisionDirection Dir = CollisionDirection.CD_Down; int H, W; //Point ButtomRight = new Point(Src.X + Src.Width, Src.Y + Src.Height); //Point ButtomLeft = new Point(Src.X, Src.Y + Src.Height); //Point TopRight = new Point(Src.X + Src.Width, Src.Y); //Point TopLeft = new Point(Src.X, Src.Y); ButtomRight.X = Src.X + Src.Width; ButtomRight.Y = Src.Y + Src.Height; ButtomLeft.X = Src.X; ButtomLeft.Y = Src.Y + Src.Height; TopRight.X = Src.X + Src.Width; TopRight.Y = Src.Y; TopLeft.X = Src.X; TopLeft.Y = Src.Y; Boolean Found = false; if (Contains(ButtomRight, Dest)) //if (Dest.Contains(ButtomRight)) { Found = true; W = ButtomRight.X - Dest.X; H = ButtomRight.Y - Dest.Y; if (W > H) { Dir = CollisionDirection.CD_Up; } else if (H > W) { Dir = CollisionDirection.CD_Left; } else { Dir = CollisionDirection.CD_TopLeft; } } if (Contains(ButtomLeft, Dest)) // if (Dest.Contains(ButtomLeft)) { Found = true; W = Dest.X + Dest.Width - ButtomLeft.X; H = ButtomLeft.Y - Dest.Y; if (W > H) { Dir = CollisionDirection.CD_Up; } else if (H > W) { Dir = CollisionDirection.CD_Right; } else { Dir = CollisionDirection.CD_TopRight; } } if (Contains(TopRight, Dest)) // if (Dest.Contains(TopRight)) { Found = true; W = TopRight.X - Dest.X; H = Dest.Y + Dest.Height - TopRight.Y; if (W > H) { Dir = CollisionDirection.CD_Down; } else { Dir = CollisionDirection.CD_Left; } } if (Contains(TopLeft, Dest)) // if (Dest.Contains(TopLeft)) { Found = true; W = Dest.X + Dest.Width - TopLeft.X; H = Dest.Y + Dest.Height - TopLeft.Y;// -5; //Bug if (W > H) { Dir = CollisionDirection.CD_Down; } else { Dir = CollisionDirection.CD_Right; } } if (Found == false) { return(null); } else { // For Better Performance..... MainColision.Src = Src; MainColision.Dest = Dest; MainColision.Dir = Dir; MainColision.Type = CollisionType.CT_Moveable; return(MainColision); // Old One //return new Collision(Src, Dest, CollisionType.CT_Moveable, Dir); } }
public void LogMe(Collision c, GraphicObject g) { Logger.Instance.Log_Method(c.Dir.ToString()); Logger.Instance.Step_In(); Logger.Instance.WriteLn("Src Object:" + this.GetType().Name); Logger.Instance.WriteLn("Dest Object:" + g.GetType().Name); Logger.Instance.WriteLn("Src Rectangle:" + c.Src.ToString()); Logger.Instance.WriteLn("Dest Rectangle:" + c.Dest.ToString()); Logger.Instance.Step_Out(); }
public virtual void Intersection(Collision c, GraphicObject g) { //if (this.GetType().Name == "Mario") // if (g.GetType().Name == "BlockSolid") // LogMe(c, g); // if (this.GetType().Name == "Mario") // if (g.GetType().Name == "BlockGrass") // LogMe(c, g); }