protected Enemy(Texture2D texture, SpawnAreas spawnArea, AiTypes aiType, float speed, List <Animation> animations) { switch (spawnArea) { case SpawnAreas.Left: spawnX = random.Next(spawnLeft.X, spawnLeft.X + spawnLeft.Width); spawnY = random.Next(spawnLeft.Y, spawnLeft.Y + spawnLeft.Height); break; case SpawnAreas.Middle: spawnX = random.Next(spawnMiddle.X, spawnMiddle.X + spawnMiddle.Width); spawnY = random.Next(spawnMiddle.Y, spawnMiddle.Y + spawnMiddle.Height); break; case SpawnAreas.Right: spawnX = random.Next(spawnRight.X, spawnRight.X + spawnRight.Width); spawnY = random.Next(spawnRight.Y, spawnRight.Y + spawnRight.Height); break; default: throw new ArgumentOutOfRangeException(nameof(spawnArea), spawnArea, null); } CollidableObject = new CollidableObject(texture, new Vector2(spawnX, spawnY), new Rectangle(0, 0, 100, 100), 0f); _aiType = aiType; this.speed = speed; _animationSet = new AnimationSet(animations, AnimationStates.Walk, AnimationDirections.Down); Rectangle initialSourceRectangle = Rectangle.Empty; // Set initialSourceRectangle to the first frame in the first animation animations[0].SetToFrame(ref initialSourceRectangle, 0); // Set initial targets switch (aiType) { case AiTypes.Brute: SetTarget(Targets.Knight); break; case AiTypes.Smart: SetTarget(Targets.Door); break; case AiTypes.Rush: SetTarget(Targets.Door); break; default: throw new ArgumentOutOfRangeException(nameof(aiType), aiType, null); } }
protected Player(Texture2D texture, Vector2 spawnPosition, PlayerControlScheme controlScheme, List <Animation> animations) { _controlScheme = controlScheme; _animationSet = new AnimationSet(animations, AnimationStates.Idle, AnimationDirections.Down); Rectangle initialSourceRectangle = Rectangle.Empty; // Set initialSourceRectangle to the first frame in the first animation animations[0].SetToFrame(ref initialSourceRectangle, 0); CollidableObject = new CollidableObject(texture, spawnPosition, initialSourceRectangle, 0f); }