public void SwordCollision(Vector2 check) { gotype swordcoll = CollisionObject(check); switch (swordcoll) { case gotype.Space: Program.map.InitGameObject('┼', check.X, check.Y); break; case gotype.Wall: // play sound:bounceoff; break; case gotype.Stone: // play sound:bounceoff; break; case gotype.Enemy: // Render(); // Enemy.LifePoints -= Attackpoints; break; case gotype.Heart: // LifePoints += 1; break; case gotype.Door: // play sound:bounceoff; break; default: break; } }
public void Collision(Vector2 check) { gotype CollisionObj = CollisionObject(check); switch (CollisionObj) { case gotype.Space: Step(ViewingDirection); break; case gotype.Wall: break; case gotype.Stone: if (CollisionObject(NextStep(ViewingDirection, check)) == gotype.Space) { Program.map.InitGameObject('♦', NextStep(ViewingDirection, check).X, NextStep(ViewingDirection, check).Y); Program.map.DestroyGameObject(check); Step(ViewingDirection); } break; case gotype.Enemy: // play sound:hurt; //LifePoints -= 1; break; case gotype.Sword: Step(ViewingDirection); Program.map.DestroyGameObject(check); key = true; break; case gotype.Heart: Step(ViewingDirection); Program.map.DestroyGameObject(check); LifePoints += 1; break; case gotype.Door: if (key == true) { Console.SetCursorPosition(0, 20); Console.WriteLine("Victory!"); Program.victory = true; } else { Console.SetCursorPosition(0, 20); Console.WriteLine("Du brauchst den Schlüssel -> ┼ !"); } break; default: break; } }
protected gotype CollisionObject(Vector2 coordinates) //CollisionDetection { Map map = Program.map; List <gotype> foundObjects = new List <gotype>(); foreach (GameObject go in map.GameObjectList) { if (go.Coordin.X == coordinates.X && go.Coordin.Y == coordinates.Y) { if (go == null) { throw new ArgumentOutOfRangeException(); } if (typeof(Space) == go.GetType()) { type = gotype.Space; } if (typeof(Wall) == go.GetType()) { type = gotype.Wall; } if (typeof(Stone) == go.GetType()) { type = gotype.Stone; } if (typeof(Enemy) == go.GetType()) { type = gotype.Enemy; } if (typeof(Sword) == go.GetType()) { type = gotype.Sword; } if (typeof(Heart) == go.GetType()) { type = gotype.Heart; } if (typeof(Door) == go.GetType()) { type = gotype.Door; } if (typeof(Hero) == go.GetType()) { type = gotype.Hero; } foundObjects.Add(type); } } if (foundObjects.Count == 0) { Program.map.InitGameObject(' ', coordinates.X, coordinates.Y); return(type = gotype.Space); } if (foundObjects.Count == 1) { return(foundObjects[0]); } return(foundObjects.Where(g => g != gotype.Space).First()); }
/* * if (LifePoints <= 0) * { * GameObject.this.destroy; * } */ public override void EnemyControl() { gotype CollisionObj = CollisionObject(NextStep(ViewingDirection, Coordin)); switch (CollisionObj) { case gotype.Space: switch (ViewingDirection) { case 'E': // East OldCoordinates = new Vector2(Coordin.X, Coordin.Y); Coordin.Y++; NewCoordinates = Coordin; break; case 'W': OldCoordinates = new Vector2(Coordin.X, Coordin.Y); Coordin.Y--; NewCoordinates = Coordin; break; } Move(NewCoordinates, OldCoordinates); break; case gotype.Wall: Rotation(ViewingDirection); Render(Coordin, Coordin, ObjectAppearance); break; case gotype.Stone: Rotation(ViewingDirection); Render(Coordin, Coordin, ObjectAppearance); break; case gotype.Enemy: Rotation(ViewingDirection); Render(Coordin, Coordin, ObjectAppearance); break; case gotype.Sword: Rotation(ViewingDirection); Render(Coordin, Coordin, ObjectAppearance); break; case gotype.Heart: Rotation(ViewingDirection); Render(Coordin, Coordin, ObjectAppearance); break; case gotype.Door: Rotation(ViewingDirection); Render(Coordin, Coordin, ObjectAppearance); break; case gotype.Hero: Attack((Hero)GetGameObject(NextStep(ViewingDirection, Coordin))); break; default: break; } }