Ejemplo n.º 1
0
        public static Vec2Int ReadFrom(BinaryReader reader)
        {
            var result = new Vec2Int();

            result.X = reader.ReadInt32();
            result.Y = reader.ReadInt32();
            return(result);
        }
Ejemplo n.º 2
0
 public DebugState(Vec2Int windowSize, Vec2Float mousePosWindow, Vec2Float mousePosWorld, string[] pressedKeys, Camera camera, int playerIndex)
 {
     WindowSize     = windowSize;
     MousePosWindow = mousePosWindow;
     MousePosWorld  = mousePosWorld;
     PressedKeys    = pressedKeys;
     Camera         = camera;
     PlayerIndex    = playerIndex;
 }
Ejemplo n.º 3
0
        public static MoveAction ReadFrom(BinaryReader reader)
        {
            var result = new MoveAction();

            result.Target = Vec2Int.ReadFrom(reader);
            result.FindClosestPosition = reader.ReadBoolean();
            result.BreakThrough        = reader.ReadBoolean();
            return(result);
        }
Ejemplo n.º 4
0
 public Entity(int id, int?playerId, EntityType entityType, Vec2Int position, int health, bool active)
 {
     Id         = id;
     PlayerId   = playerId;
     EntityType = entityType;
     Position   = position;
     Health     = health;
     Active     = active;
 }
Ejemplo n.º 5
0
        public static BuildAction ReadFrom(BinaryReader reader)
        {
            var result = new BuildAction();

            switch (reader.ReadInt32())
            {
            case 0:
                result.EntityType = EntityType.Wall;
                break;

            case 1:
                result.EntityType = EntityType.House;
                break;

            case 2:
                result.EntityType = EntityType.BuilderBase;
                break;

            case 3:
                result.EntityType = EntityType.BuilderUnit;
                break;

            case 4:
                result.EntityType = EntityType.MeleeBase;
                break;

            case 5:
                result.EntityType = EntityType.MeleeUnit;
                break;

            case 6:
                result.EntityType = EntityType.RangedBase;
                break;

            case 7:
                result.EntityType = EntityType.RangedUnit;
                break;

            case 8:
                result.EntityType = EntityType.Resource;
                break;

            case 9:
                result.EntityType = EntityType.Turret;
                break;

            default:
                throw new Exception("Unexpected tag value");
            }

            result.Position = Vec2Int.ReadFrom(reader);
            return(result);
        }
Ejemplo n.º 6
0
        public static DebugState ReadFrom(BinaryReader reader)
        {
            var result = new DebugState();

            result.WindowSize     = Vec2Int.ReadFrom(reader);
            result.MousePosWindow = Vec2Float.ReadFrom(reader);
            result.MousePosWorld  = Vec2Float.ReadFrom(reader);
            result.PressedKeys    = new string[reader.ReadInt32()];
            for (int i = 0; i < result.PressedKeys.Length; i++)
            {
                result.PressedKeys[i] = Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadInt32()));
            }

            result.Camera      = Camera.ReadFrom(reader);
            result.PlayerIndex = reader.ReadInt32();
            return(result);
        }
Ejemplo n.º 7
0
 public BuildAction(EntityType entityType, Vec2Int position)
 {
     EntityType = entityType;
     Position   = position;
 }
Ejemplo n.º 8
0
 public MoveAction(Vec2Int target, bool findClosestPosition, bool breakThrough)
 {
     Target = target;
     FindClosestPosition = findClosestPosition;
     BreakThrough        = breakThrough;
 }
Ejemplo n.º 9
0
        public static Entity ReadFrom(BinaryReader reader)
        {
            var result = new Entity();

            result.Id = reader.ReadInt32();
            if (reader.ReadBoolean())
            {
                result.PlayerId = reader.ReadInt32();
            }
            else
            {
                result.PlayerId = null;
            }

            switch (reader.ReadInt32())
            {
            case 0:
                result.EntityType = EntityType.Wall;
                break;

            case 1:
                result.EntityType = EntityType.House;
                break;

            case 2:
                result.EntityType = EntityType.BuilderBase;
                break;

            case 3:
                result.EntityType = EntityType.BuilderUnit;
                break;

            case 4:
                result.EntityType = EntityType.MeleeBase;
                break;

            case 5:
                result.EntityType = EntityType.MeleeUnit;
                break;

            case 6:
                result.EntityType = EntityType.RangedBase;
                break;

            case 7:
                result.EntityType = EntityType.RangedUnit;
                break;

            case 8:
                result.EntityType = EntityType.Resource;
                break;

            case 9:
                result.EntityType = EntityType.Turret;
                break;

            default:
                throw new Exception("Unexpected tag value");
            }

            result.Position = Vec2Int.ReadFrom(reader);
            result.Health   = reader.ReadInt32();
            result.Active   = reader.ReadBoolean();
            return(result);
        }
Ejemplo n.º 10
0
 public double RangeTo(Vec2Int p2)
 {
     return(Math.Abs(Math.Sqrt(Math.Pow(p2.X - this.X, 2) + Math.Pow(p2.Y - this.Y, 2))));
 }