Example #1
0
    public override void Update()
    {
        NameComponent    name    = Container.GetComponent <NameComponent>();
        SpatialComponent spatial = Container.GetComponent <SpatialComponent>();

        Console.WriteLine(name.EntityName + " is at: (" + spatial.X + ", " + spatial.Y + ")");
    }
Example #2
0
 /// <summary>
 /// Constructs an entity with the given identifier.
 /// </summary>
 /// <param name="identifier"></param>
 public Entity(Guid identifier)
 {
     Identifier = identifier;
     Components = new ComponentDictionary(this);
     Spatial    = new SpatialComponent();
     Components.Add(Spatial);
 }
Example #3
0
    public override void Update()
    {
        Console.WriteLine();
        Console.WriteLine("-------------------------");
        Console.WriteLine();
        Console.WriteLine("Which way to move?: WASD");

        char             direction = Console.ReadKey().KeyChar;
        SpatialComponent spatial   = Container.GetComponent <SpatialComponent>();

        switch (direction)
        {
        case 'w':
            spatial.Y += spatial.Speed;
            break;

        case 'a':
            spatial.X -= spatial.Speed;
            break;

        case 's':
            spatial.Y -= spatial.Speed;
            break;

        case 'd':
            spatial.X += spatial.Speed;
            break;
        }

        Console.WriteLine();
        Console.WriteLine("_____________________");
        Console.WriteLine("   Player Location   ");
        Console.WriteLine("_____________________");
        Console.WriteLine();
    }
Example #4
0
    public override void Update()
    {
        SpatialComponent spatial       = Container.GetComponent <SpatialComponent>();
        SpatialComponent spatialPlayer = playerSpace.GetComponent <SpatialComponent>();

        if (spatial.X == spatialPlayer.X && spatial.Y == spatialPlayer.Y)
        {
            isPlayerAlive = false;
        }
    }
Example #5
0
    public override void Update()
    {
        SpatialComponent spatialPowerUp = Container.GetComponent <SpatialComponent>();
        SpatialComponent spatialPlayer  = playerSpace.GetComponent <SpatialComponent>();
        Random           x = new Random();
        Random           y = new Random();

        if (spatialPowerUp.X == spatialPlayer.X && spatialPowerUp.Y == spatialPlayer.Y)
        {
            Console.WriteLine("Player Teleported!");
            spatialPlayer.X = y.Next(-10, 10);
            spatialPlayer.Y = y.Next(-10, 10);
        }
    }
Example #6
0
    public override void Update()
    {
        SpatialComponent spatial = Container.GetComponent <SpatialComponent>();

        if (spatial.X > MaxBound)
        {
            spatial.X = MaxBound;
        }
        if (spatial.X < -1 * MaxBound)
        {
            spatial.X = -1 * MaxBound;
        }
        if (spatial.Y > MaxBound)
        {
            spatial.Y = MaxBound;
        }
        if (spatial.Y < -1 * MaxBound)
        {
            spatial.Y = -1 * MaxBound;
        }
    }
Example #7
0
    public override void Update()
    {
        SpatialComponent spatial       = Container.GetComponent <SpatialComponent>();
        SpatialComponent spatialPlayer = playerSpace.GetComponent <SpatialComponent>();

        if (spatial.X > spatialPlayer.X)
        {
            spatial.X -= 1;
        }
        else if (spatial.X < spatialPlayer.X)
        {
            spatial.X += 1;
        }
        else if (spatial.Y > spatialPlayer.Y)
        {
            spatial.Y -= 1;
        }
        else if (spatial.Y < spatialPlayer.Y)
        {
            spatial.Y += 1;
        }
    }
Example #8
0
    public override void Update()
    {
        SpatialComponent spatial       = Container.GetComponent <SpatialComponent>();
        SpatialComponent spatialPlayer = playerSpace.GetComponent <SpatialComponent>();

        if (spatial.X == spatialPlayer.X && spatial.Y == spatialPlayer.Y)
        {
            Console.WriteLine("Speed Boost Get!");
            turn = 6;
            spatialPlayer.Speed = 2;
        }

        if (turn > 0)
        {
            turn--;
            Console.WriteLine(turn + " turns left of boost");
        }

        if (turn == 0)
        {
            spatialPlayer.Speed = 1;
        }
    }
Example #9
0
 private void add(SpatialComponent spatial)
 {
     spatials_.Add(spatial);
 }
Example #10
0
 private void remove(SpatialComponent spatial)
 {
     spatials_.Remove(spatial);
 }
 public void AttachTo(IGameEntity entity)
 {
     _spatial = (SpatialComponent)entity.GetComponent("Spatial");
     OnAttach();
 }