The game is dead but goddammit I tried

master
BraydonKains 5 years ago
parent 0229f9f055
commit 51f5d963cd

@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace SeeNoEvil.Character {
@ -7,8 +9,18 @@ namespace SeeNoEvil.Character {
Width = AnimationController.Width;
Height = AnimationController.Height;
Facing = facing;
//FIXME Can probably share this code
switch(Facing) {
ChooseAnimation(Facing);
}
public override void Move(Direction direction) {
if(!Moving) {
ChooseAnimation(direction);
base.Move(direction);
}
}
private void ChooseAnimation(Direction direction) {
switch(direction) {
case Direction.Up:
AnimationController.ChangeAnimation(3);
break;
@ -24,23 +36,20 @@ namespace SeeNoEvil.Character {
}
}
public override void Move(Direction direction) {
if(!Moving) {
switch(direction) {
case Direction.Up:
AnimationController.ChangeAnimation(3);
break;
case Direction.Down:
AnimationController.ChangeAnimation(4);
break;
case Direction.Left:
AnimationController.ChangeAnimation(1);
break;
case Direction.Right:
AnimationController.ChangeAnimation(2);
break;
}
base.Move(direction);
public void Scared() {
switch(Facing) {
case Direction.Up:
AnimationController.ChangeAnimation(7);
break;
case Direction.Down:
AnimationController.ChangeAnimation(8);
break;
case Direction.Left:
AnimationController.ChangeAnimation(5);
break;
case Direction.Right:
AnimationController.ChangeAnimation(6);
break;
}
}
}

@ -13,10 +13,10 @@ namespace SeeNoEvil.Character {
protected AnimationController AnimationController;
protected int Width;
protected int Height;
protected Direction Facing;
protected PlayField Field;
protected bool Moving =>
public Direction Facing;
public bool Moving =>
!Destination.Equals(Vector2.Zero) &&
!Velocity.Equals(Vector2.Zero) &&
!Position.Equals(Destination);

@ -16,21 +16,20 @@ namespace SeeNoEvil.Character {
).ToList();
}
public void LoadAll(ContentManager content, PlayField playField) {
public void LoadAll(ContentManager content, PlayField playField) =>
Ghosts.ForEach(ghost => ghost.Load(content, playField));
}
public void DrawAll(SpriteBatch spriteBatch) {
public void DrawAll(SpriteBatch spriteBatch) =>
Ghosts.ForEach(ghost => ghost.Draw(spriteBatch));
}
public void UpdateAll() {
public void UpdateAll() =>
Ghosts.ForEach(ghost => ghost.Update());
}
public void MoveGhosts() {
public void MoveGhosts() =>
Ghosts.ForEach(ghost => ghost.DecideMove());
}
public bool AreGhostsHere(IEnumerable<Vector2> lineOfSight) =>
Ghosts.Any(ghost => lineOfSight.Contains(ghost.Position));
}
public class Ghost : Character {

@ -19,7 +19,7 @@ namespace SeeNoEvil.Level {
}
//FIXME Don't need velocity anymore?
public void Update(Vector2 position, Vector2 velocity) {
public void Update(Vector2 position) {
Centre = position;
Transform = Matrix.CreateTranslation(TranslationVector);
}

@ -39,7 +39,7 @@ namespace SeeNoEvil.Level {
public PlayField GetPlayField() {
Map.View.TryGetValue("Ground", out List<TileLocation> ground);
return new PlayField(ground.Where(tile => tile.tile.gid != 0));
return new PlayField(ground);
}
public IEnumerable<ObjectCoordinate> GetGhostCoordinates() {

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SeeNoEvil.Character;
using SeeNoEvil.Tiled;
namespace SeeNoEvil.Level {
@ -13,6 +15,13 @@ namespace SeeNoEvil.Level {
}
public bool TryWalk(Vector2 newLocation) =>
Tiles.Any(tile => tile.location.Equals(newLocation));
}
Tiles.Any(tile => tile.location.Equals(newLocation) && tile.tile.gid != 0);
public IEnumerable<Vector2> GetLineOfSight(Direction facing, Vector2 position) {
return new List<Vector2>();
}
private bool Between(float pos1, float pos2, float bound) =>
(bound - pos1) >= (pos2 - pos1);
}
}

@ -20,6 +20,7 @@ namespace SeeNoEvil
Cat player;
GhostController enemyController;
PlayField playField;
bool scared;
public SeeNoEvilGame()
{
@ -54,7 +55,6 @@ namespace SeeNoEvil
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
camera.Update(player.Position, Vector2.Zero);
if(Keyboard.GetState().IsKeyDown(Keys.Down)) {
player.Move(Direction.Down);
enemyController.MoveGhosts();
@ -73,7 +73,11 @@ namespace SeeNoEvil
}
player.Update();
enemyController.UpdateAll();
camera.Update(player.Position);
if(!player.Moving)
scared = enemyController.AreGhostsHere(playField.GetLineOfSight(player.Facing, player.Position));
if(scared)
player.Scared();
base.Update(gameTime);
}

Loading…
Cancel
Save