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); }
public void SpawnCreature(Coords startPoint, Team team, CreatureGenerator generator) { Creature newguy = new Creature(this, startPoint, (UInt16)this.IssueCreatureID(), team, generator); team.MemberRegister(newguy); }
private void MainFrame_Load(object sender, System.EventArgs e) { _timer = new Timer(); _timer.Interval = Constants.defaultTimerPeriod; _timer.Tick += new System.EventHandler(MainFrame_Tick); _zoom = Constants.ZoomDefault; WorldGeneration generator = new WorldGeneration(907); _currentMap = generator.GenerateVillage(Constants.MapSize, Constants.MapSize); _painter = new Painter(this, _currentMap, _zoom); _currentMap.AnalyzeTileAccessibility(); Team team1 = new Team(Color.Red); Team team2 = new Team(Color.Blue); for (int j = 0; j < 2; ++j) { for (int i = 0; i < 5; ++i) { _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, j), team1, Constants.CreatureGeneratorGnome); } } for (int j = 0; j < 2; ++j) { for (int i = 0; i < 5; ++i) { _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, _currentMap.BoundY-1-j), team2, Constants.CreatureGeneratorGnome); } } _currentMap.SpawnPlayer(Constants.PlayerStartPos); //_player = _currentMap.PlayerReference; //_screenAnchor = this.TransformCenterAtPlayer(); _scheduler = new Scheduler(_currentMap); _ledger = new Ledger(_scheduler); _timer.Start(); }