public override void Update(Microsoft.Xna.Framework.GameTime t, Dictionary <String, Actor> .ValueCollection targets) { UpdateFrame(t); switch (frame) { case 0: AvailableLow.LStickAction = null; AvailableLow.NoButton = null; AvailableHigh.LStickAction = null; break; case 1: AvailableLow.LStickAction = "Walking"; AvailableLow.NoButton = "Standing"; AvailableHigh.LStickAction = "Running"; AvailableHigh.NoButton = "Standing"; break; } Vector3 update = new Vector3(30 * Actor.Facing, 0); CollisionCylinder CheckBox = new CollisionCylinder(Actor.Location + update, 50f, 50f); foreach (Actor y in targets) { if ((CheckBox.IntersectsType(y.Bounds) && !Actor.Equals(y))) //Collision Detection. Ideally reduces movement to outside collision bounds. { y.Interacting = true; } } }
public override void Update(GameTime t, Dictionary <String, Actor> .ValueCollection targets) { UpdateFrame(t); switch (frame) { case 0: Actor.ImageXindex = 3; break; case 3: Actor.ImageXindex = 4; break; case 6: Actor.ImageXindex = 5; break; case 9: Actor.ImageXindex = 6; break; case 12: Actor.ImageXindex = 7; break; case 15: Actor.ImageXindex = 8; break; } Actor.UpdateFacing(Actor.Facing); Vector3 update = (float)t.ElapsedGameTime.TotalSeconds * Actor.Speed * new Vector3(Actor.Facing, 0); CollisionCylinder CheckBox = Actor.GetBounds(update); foreach (Actor y in targets) { if (Actor != y) { Vector3 adjust = (CheckBox.Intersection(y.Bounds)); update -= adjust; } } Actor.AdjustUpdateVector(update); }
public Vector3 Intersection(CollisionCylinder target) { Vector3 difference = location - target.location; float distance = difference.X * difference.X + difference.Y * difference.Y; if ((distance < (radius + target.Radius) * (radius + target.Radius))) { if ((target.LocationZ + target.Height) > LocationZ - 10 && location.Z > target.LocationZ) { return(new Vector3(0, 0, location.Z - target.Height - target.location.Z)); } else if (location.Z + Height > target.LocationZ && location.Z < target.LocationZ) { return(new Vector3(0, 0, target.location.Z - Height - location.Z)); } else { difference.Z = 0; difference.Normalize(); return(difference * (float)(Math.Sqrt(distance) - radius - target.Radius)); } } else { return(Vector3.Zero); } }
public bool IntersectsType(CollisionCylinder target) { if (target.Location.X < location.X - width / 2) { if (target.Location.Y < location.Y - depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, -depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(distance < target.Radius * target.Radius); } else if (target.Location.Y > location.Y + depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, +depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(distance < target.Radius * target.Radius); } else { return(target.Location.X > location.X - width / 2 - target.Radius); } } else if (target.Location.X > location.X + width / 2) { if (target.Location.Y < location.Y - depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, -depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(distance < target.Radius * target.Radius); } else if (target.Location.Y > location.Y + depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, +depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(distance < target.Radius * target.Radius); } else { return(target.Location.X < location.X + width / 2 + target.Radius); } } else { return((target.Location.Y < location.Y + depth / 2 + target.Radius && target.Location.Y > Location.Y) || (target.Location.Y < location.Y && target.Location.Y > Location.Y - depth / 2 - target.Radius)); } }
public override void Update(GameTime t, Dictionary <string, Actor> .ValueCollection targets) { UpdateFrame(t); switch (frame) { case 0: updateAmount = 0f; fatigue = -1f; Actor.UpdateFacing(Vector2.Zero); AvailableHigh.LStickAction = null; AvailableLow.LStickAction = null; AvailableHigh.NoButton = null; AvailableLow.NoButton = null; updateZ = 3f; break; case 1: fatigue = -3f; updateAmount = 9f; break; case 2: fatigue = 0f; break; case 5: updateAmount = 2f; updateZ = 0; break; case 8: updateAmount = 0f; break; case 12: AvailableHigh.LStickAction = "DashJump"; AvailableLow.LStickAction = "Dash"; AvailableHigh.NoButton = "FightStance"; AvailableLow.NoButton = "FightStance"; break; } Vector3 update = (float)t.ElapsedGameTime.TotalSeconds * Actor.Speed * new Vector3(direction * updateAmount, updateZ); CollisionCylinder CheckBox = Actor.GetBounds(update); bool legal = true; foreach (Actor y in targets) { Vector3 adjust = (CheckBox.Intersection(y.Bounds)); update -= adjust; } Actor.AdjustUpdateVector(update); }
public bool IntersectsType(CollisionCylinder target) { Vector3 difference = location - target.location; float distance = difference.X * difference.X + difference.Y * difference.Y; if ((distance < radius * radius || distance < target.Radius * target.Radius) && (difference.Z < target.Height || difference.Z > -height)) { return(true); } else { return(false); } }
public Vector3 Intersection(CollisionCylinder target) { if (target.Location.X < location.X - width / 2) { if (target.Location.Y < location.Y - depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, -depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(difference); } else if (target.Location.Y > location.Y + depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, +depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(difference); } else { return((target.Location.X - location.X - width / 2 - target.Radius) * Vector3.UnitY); } } else if (target.Location.X > location.X + width / 2) { if (target.Location.Y < location.Y - depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, -depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(difference); } else if (target.Location.Y > location.Y + depth / 2) { Vector3 difference = location - target.Location + new Vector3(-width / 2, +depth / 2, 0); float distance = difference.X * difference.X + difference.Y * difference.Y; return(difference); } else { return((target.Location.X - location.X - width / 2 - target.Radius) * Vector3.UnitY); } } else { return((target.Location.Y - location.Y + depth / 2 + target.Radius) * Vector3.UnitX); } }
public bool IntersectsType(CollisionCylinder target) { Vector3 difference = location - target.Location; float distance = difference.X * difference.X + difference.Y * difference.Y; if ((distance < (radius + target.Radius) * (radius + target.Radius)) && (difference.Z < target.Height || difference.Z > -height)) { float angle = (float)Math.Atan2(-difference.Y, -difference.X); return(angle < centerAngle + angleWidth / 2 && angle > centerAngle - angleWidth / 2); } else { return(false); } }
public override void Update(GameTime t, Dictionary <string, Actor> .ValueCollection targets) { UpdateFrame(t); switch (frame) { case 0: updateAmount = 6f; fatigue = -.5f; Actor.UpdateFacing(direction); AvailableHigh.LStickAction = null; AvailableLow.LStickAction = null; AvailableHigh.NoButton = null; AvailableLow.NoButton = null; break; case 1: fatigue = 0f; break; case 2: fatigue = 0f; break; case 4: updateAmount = 0f; break; case 14: AvailableHigh.LStickAction = "DashJump"; AvailableLow.LStickAction = "Dash"; AvailableHigh.NoButton = "FightStance"; AvailableLow.NoButton = "FightStance"; break; } Vector3 update = (float)t.ElapsedGameTime.TotalSeconds * Actor.Speed * updateAmount * new Vector3(direction, 0); CollisionCylinder CheckBox = Actor.GetBounds(update); bool legal = true; foreach (Actor y in targets) { Actor.UpdateVector += (CheckBox.Intersection(y.Bounds)); //Collision Detection. Ideally reduces movement to outside collision bounds. } }
public override void Update(GameTime t, Dictionary <string, Actor> .ValueCollection targets) { UpdateFrame(t); switch (frame) { case 0: Actor.ImageXindex = 0; break; case 114: Actor.ImageXindex = 1; break; case 115: Actor.ImageXindex = 2; break; case 117: Actor.ImageXindex = 1; break; case 118: Actor.ImageXindex = 0; break; case 119: Actor.ImageXindex = 1; break; case 120: Actor.ImageXindex = 2; break; case 122: Actor.ImageXindex = 1; break; } Actor.UpdateFacing(Vector2.UnitX); Vector3 update = Vector3.Zero; CollisionCylinder CheckBox = Actor.GetBounds(update); foreach (Actor y in targets) { if (Actor != y) { Vector3 adjust = (CheckBox.Intersection(y.Bounds)); update -= adjust; } } Actor.AdjustUpdateVector(update); }
public override void Update(GameTime t, Dictionary <String, Actor> .ValueCollection targets) { float updateZ = 0; UpdateFrame(t); switch (frame) { case 0: fatigue = -2f; AvailableLow.NoButton = null; AvailableLow.LStickAction = null; AvailableHigh.NoButton = null; AvailableHigh.LStickAction = null; Actor.ImageXindex = 0; Actor.ImageYindex = 0; updateZ = 7; Actor.UpdateFacing(Vector2.UnitX); break; case 1: fatigue = 0f; Actor.ImageXindex = 0; Actor.ImageYindex = 0; updateZ = 4; break; case 2: Actor.ImageXindex = 0; Actor.ImageYindex = 0; updateZ = 4; break; case 3: updateZ = 2; break; case 4: updateZ = 2; break; case 5: updateZ = 2; break; case 6: updateZ = 1; break; case 7: updateZ = 1; break; case 8: updateZ = 1; break; case 9: updateZ = 1; break; case 10: updateZ = 0; break; case 11: updateZ = 0; break; case 12: updateZ = 0; break; case 13: break; case 14: Random rand = new Random(); if (rand.Next(2) < 1) { AvailableHigh.NoButton = "Fall Down"; } else { AvailableLow.NoButton = "Standing"; AvailableLow.LStickAction = "Walking"; AvailableHigh.LStickAction = "Running"; AvailableHigh.NoButton = "Standing"; } break; default: break; } Vector3 update = (float)t.ElapsedGameTime.TotalSeconds * Actor.Speed * 2.5f * new Vector3(Actor.Facing, updateZ); CollisionCylinder CheckBox = Actor.GetBounds(update); bool legal = true; foreach (Actor y in targets) { if (Actor != y) { // Vector3 adjust = (CheckBox.Intersection(y.Bounds)); //update -= adjust; } } Actor.AdjustUpdateVector(update); }
public override void Update(GameTime t, Dictionary <String, Actor> .ValueCollection targets) { UpdateFrame(t); Vector3 update = (float)t.ElapsedGameTime.TotalSeconds * Actor.Speed * new Vector3(Actor.Facing, 0); switch (frame) { case 0: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 1: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 2: Actor.ImageXindex = 0; Actor.ImageYindex = 0; update /= 4; break; case 3: Actor.ImageXindex = 1; update /= 4; break; case 4: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 5: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 6: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 7: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 8: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 9: Actor.ImageXindex = 1; Actor.ImageYindex = 0; update /= 4; break; case 10: Actor.ImageXindex = 0; Actor.ImageYindex = 0; update /= 2; break; case 11: Actor.ImageXindex = 0; Actor.ImageYindex = 0; update /= 2; break; case 12: Actor.ImageXindex = 0; Actor.ImageYindex = 0; update /= 2; break; case 13: Actor.ImageXindex = 0; Actor.ImageYindex = 0; update /= 2; break; case 14: Actor.ImageXindex = 0; Actor.ImageYindex = 0; update /= 2; break; default: Actor.ImageYindex = 0; break; } CollisionCylinder CheckBox = Actor.GetBounds(update); bool legal = true; Actor.UpdateVector = update; foreach (Actor y in targets) { if (Actor != y) { Vector3 adjust = (CheckBox.Intersection(y.Bounds)); update -= adjust; } } Actor.AdjustUpdateVector(update); }