public Map(string file) { Stream stream = File.Open(basePath + file, FileMode.Open); BinaryReader reader = new BinaryReader(stream); try { sizeX = reader.ReadSingle(); sizeY = reader.ReadSingle(); int numBushes = reader.ReadInt32(); bushes = new Bush[numBushes]; for (int x = 0; x < numBushes; x++) bushes[x] = new Bush(reader); int numCollisions = reader.ReadInt32(); collisions = new Collision[numCollisions]; for (int x = 0; x < numCollisions; x++) collisions[x] = new Collision(reader); int numStructures = reader.ReadInt32(); structures = new Structure[numStructures]; for (int x = 0; x < numStructures; x++) { int type = reader.ReadInt32(); switch ((StructureType)type) { case StructureType.Turret: structures[x] = new Turret(this, reader); break; case StructureType.Nexus: structures[x] = new Nexus(this, reader); break; } } int numLanes = reader.ReadInt32(); lanes = new Lane[numLanes]; for (int x = 0; x < numLanes; x++) lanes[x] = new Lane(reader); } finally { reader.Close(); stream.Close(); } Initialize(); }
public void SetBushes(Bush[] bushes) { this.bushes = bushes; }
public virtual void Move(Vector3 delta) { map.RemoveFromPartitioning(this); if (currentBush != null) team.LeaveBush(currentBush.ID); position += delta; if (map.InCollision(position)) position -= delta; currentBush = map.GetBushAt(position); if (currentBush != null) team.EnterBush(currentBush.ID); map.AddToPartitioning(this); }