コード例 #1
0
        // Constructs an xSize by ySize map. Default Tile set to TileBasicFloor.
        public Map(UInt16 xSize, UInt16 ySize, Int32 seed)
        {
            // creates and fills the tile array
            this._xMax = xSize;
            this._yMax = ySize;

            this._pixelMaxX = (UInt32)(xSize * Constants.TileSize);
            this._pixelMaxY = (UInt32)(ySize * Constants.TileSize);

            _tiles         = new Tile[xSize, ySize];
            _visibilityMap = new float[xSize, ySize];
            // tiles = new TileBasicFloor[xSize, ySize];
            for (Int32 i = 0; i < xSize; i++)
            {
                for (Int32 j = 0; j < ySize; j++)
                {
                    _tiles[i, j] = new TilePassable(this, new Coords(CoordsType.Tile, i, j), Constants.TileGeneratorGrass);
                }
            }

            this._passabilityMap = new BitArray[xSize];
            for (int i = 0; i < xSize; ++i)
            {
                _passabilityMap[i] = new BitArray(ySize);
            }

            this._myCollider          = new Collider(xSize, ySize, Constants.TileSize, Constants.TileSize, _passabilityMap);
            this._myVisibilityTracker = new VisiblityTracker(xSize, ySize, Constants.TileSize, Constants.TileSize, _passabilityMap, _visibilityMap);
            this._myPathfinder        = new Pathfinder(_passabilityMap);

            // initializes the random number generator associated with this map
            this._randomator = new RandomStuff(seed);
        }
コード例 #2
0
        public Creature(Map currentMap, Coords startPos, UInt16 ID, Team team, CreatureGenerator generator)
        {
            this._name   = generator.name;
            this._myTeam = team;

            this._myInventory = new Inventory(this);
            this._myBitmap    = generator.creatureBitmaps;
            this._radiusX     = Constants.StandardUnitRadiusX;
            this._radiusY     = Constants.StandardUnitRadiusY;

            this._inhabitedMap = currentMap;
            this._uniqueID     = ID;
            this._inhabitedMap.MenagerieAddCreatureTo(ID, this);

            this._myCollider          = _inhabitedMap.MyCollider;
            this._myVisibilityTracker = _inhabitedMap.MyVisibilityTracker;
            this._myPathfinder        = _inhabitedMap.MyPathfinder;

            this._creatureBrain       = new BrainRandomWalk();
            _creatureBrain.MyCreature = this;

            this._fieldOfView = new BitArray[currentMap.BoundX];
            for (int i = 0; i < currentMap.BoundX; ++i)
            {
                _fieldOfView[i] = new BitArray(currentMap.BoundY);
            }

            _statHPMax       = generator.StatHPMax;
            _statHP          = _statHPMax;
            _statDamage      = generator.StatDamage;
            _statArmor       = generator.StatArmor;
            _statSightRange  = generator.StatSight;
            _statAttackTime  = generator.StatAttackTime;
            _statAttackRange = generator.StatAttackRange;

            _moveSpeedMax          = generator.StatMoveSpeed;
            this._moveSpeedCurrent = 0;
            _moveAcceleration      = _moveSpeedMax / 10;

            Tile temp = this._inhabitedMap.GetTile(startPos);

            this.PositionDouble = new Vector(temp.PixelTopLeft() + new Coords(CoordsType.Pixel, _radiusX, _radiusY));

            this._inhabitedMap.MyCollider.RegisterCreature(this);
        }
コード例 #3
0
        // Creates the creature at startPos on the Map
        public Creature(Map currentMap, SpriteBatchCreature myBitmap, Coords startPos, UInt32 ID, UInt16 sightRange, Brain mind)
        {
            this._myInventory = new Inventory(this);
            this._myBitmap    = myBitmap;
            this._radiusX     = Constants.StandardUnitRadiusX;
            this._radiusY     = Constants.StandardUnitRadiusY;

            this._statSightRange      = sightRange;
            this._inhabitedMap        = currentMap;
            this._myCollider          = _inhabitedMap.MyCollider;
            this._myVisibilityTracker = _inhabitedMap.MyVisibilityTracker;
            this._myPathfinder        = _inhabitedMap.MyPathfinder;

            this._uniqueID = ID;
            this._inhabitedMap.MenagerieAddCreatureTo(ID, this);

            this._creatureBrain = mind;
            mind.MyCreature     = this;

            this._fieldOfView = new BitArray[currentMap.BoundX];
            for (int i = 0; i < currentMap.BoundX; ++i)
            {
                _fieldOfView[i] = new BitArray(currentMap.BoundY);
            }

            Tile temp = this.InhabitedMap.GetTile(startPos);

            this.PositionDouble = new Vector(temp.PixelTopLeft() + new Coords(CoordsType.Pixel, _radiusX, _radiusY));

            /*
             * this.MyBody = new UInt16[] {Constants.StatsMax, Constants.StatsMax, Constants.StatsMax, Constants.StatsMax,
             *  Constants.StatsMax, Constants.StatsMax};
             */

            this._inhabitedMap.MyCollider.RegisterCreature(this);

            this._moveSpeedCurrent = 0;
        }
コード例 #4
0
        // Constructs an xSize by ySize map. Default Tile set to TileBasicFloor.
        public Map(UInt16 xSize, UInt16 ySize, Int32 seed)
        {
            // creates and fills the tile array
            this._xMax = xSize;
            this._yMax = ySize;

            this._pixelMaxX = (UInt32)(xSize * Constants.TileSize);
            this._pixelMaxY = (UInt32)(ySize * Constants.TileSize);

            _tiles = new Tile[xSize, ySize];
            _visibilityMap = new float[xSize, ySize];
            // tiles = new TileBasicFloor[xSize, ySize];
            for (Int32 i = 0; i < xSize; i++)
            {
                for (Int32 j = 0; j < ySize; j++)
                {
                    _tiles[i, j] = new TilePassable(this, new Coords(CoordsType.Tile, i, j), Constants.TileGeneratorGrass);
                }
            }

            this._passabilityMap = new BitArray[xSize];
            for (int i = 0; i < xSize; ++i)
            {
                _passabilityMap[i] = new BitArray(ySize);
            }

            this._myCollider = new Collider(xSize, ySize, Constants.TileSize, Constants.TileSize, _passabilityMap);
            this._myVisibilityTracker = new VisiblityTracker(xSize, ySize, Constants.TileSize, Constants.TileSize, _passabilityMap, _visibilityMap);
            this._myPathfinder = new Pathfinder(_passabilityMap);

            // initializes the random number generator associated with this map
            this._randomator = new RandomStuff(seed);
        }
コード例 #5
0
        public Creature(Map currentMap, Coords startPos, UInt16 ID, Team team, CreatureGenerator generator)
        {
            this._name = generator.name;
            this._myTeam = team;

            this._myInventory = new Inventory(this);
            this._myBitmap = generator.creatureBitmaps;
            this._radiusX = Constants.StandardUnitRadiusX;
            this._radiusY = Constants.StandardUnitRadiusY;

            this._inhabitedMap = currentMap;
            this._uniqueID = ID;
            this._inhabitedMap.MenagerieAddCreatureTo(ID, this);

            this._myCollider = _inhabitedMap.MyCollider;
            this._myVisibilityTracker = _inhabitedMap.MyVisibilityTracker;
            this._myPathfinder = _inhabitedMap.MyPathfinder;

            this._creatureBrain = new BrainRandomWalk();
            _creatureBrain.MyCreature = this;

            this._fieldOfView = new BitArray[currentMap.BoundX];
            for (int i = 0; i < currentMap.BoundX; ++i)
            {
                _fieldOfView[i] = new BitArray(currentMap.BoundY);
            }

            _statHPMax = generator.StatHPMax;
            _statHP = _statHPMax;
            _statDamage = generator.StatDamage;
            _statArmor = generator.StatArmor;
            _statSightRange = generator.StatSight;
            _statAttackTime = generator.StatAttackTime;
            _statAttackRange = generator.StatAttackRange;

            _moveSpeedMax = generator.StatMoveSpeed;
            this._moveSpeedCurrent = 0;
            _moveAcceleration = _moveSpeedMax / 10;

            Tile temp = this._inhabitedMap.GetTile(startPos);
            this.PositionDouble = new Vector(temp.PixelTopLeft() + new Coords(CoordsType.Pixel, _radiusX, _radiusY));

            this._inhabitedMap.MyCollider.RegisterCreature(this);
        }
コード例 #6
0
        // Creates the creature at startPos on the Map
        public Creature(Map currentMap, SpriteBatchCreature myBitmap, Coords startPos, UInt32 ID, UInt16 sightRange, Brain mind)
        {
            this._myInventory = new Inventory(this);
            this._myBitmap = myBitmap;
            this._radiusX = Constants.StandardUnitRadiusX;
            this._radiusY = Constants.StandardUnitRadiusY;

            this._statSightRange = sightRange;
            this._inhabitedMap = currentMap;
            this._myCollider = _inhabitedMap.MyCollider;
            this._myVisibilityTracker = _inhabitedMap.MyVisibilityTracker;
            this._myPathfinder = _inhabitedMap.MyPathfinder;

            this._uniqueID = ID;
            this._inhabitedMap.MenagerieAddCreatureTo(ID, this);

            this._creatureBrain = mind;
            mind.MyCreature = this;

            this._fieldOfView = new BitArray[currentMap.BoundX];
            for (int i = 0; i < currentMap.BoundX; ++i)
            {
                _fieldOfView[i] = new BitArray(currentMap.BoundY);
            }

            Tile temp = this.InhabitedMap.GetTile(startPos);
            this.PositionDouble = new Vector(temp.PixelTopLeft() + new Coords(CoordsType.Pixel, _radiusX, _radiusY));

            /*
            this.MyBody = new UInt16[] {Constants.StatsMax, Constants.StatsMax, Constants.StatsMax, Constants.StatsMax,
                Constants.StatsMax, Constants.StatsMax};
            */

            this._inhabitedMap.MyCollider.RegisterCreature(this);

            this._moveSpeedCurrent = 0;
        }