1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brains.Framework;
using AIRendering;
using Microsoft.Xna.Framework;
namespace AIDemos.GameClasses
{
public class GameActor:DrawableActor
{
public GameActor(Vector2 position,float radius):base(position,radius)
{
}
public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
base.Update(gameTime);
WrapAround();
}
private void WrapAround()
{
Vector2 newPosition=Position;
Vector2 topLeft = ParentWorld.Map.TopLeft;
Vector2 bottomRight=ParentWorld.Map.BottomRight;
if (Position.X < 0)
newPosition.X = bottomRight.X;
if (Position.X > bottomRight.X)
newPosition.X = topLeft.X;
if (Position.Y < 0)
newPosition.Y = bottomRight.Y;
if (Position.Y > bottomRight.Y)
newPosition.Y = topLeft.Y;
Position = newPosition;
}
}
} |