/// <summary> /// moves the player forwards or backwards on the board /// </summary> /// <param name="positions"></param> public void MoveTo(int positions) { if (!IsInJail) { if (positions < 0) { for (int i = positions; i < 0; i++) { CurrentTile = CurrentTile.PreviousTile; } } else { for (int i = 0; i < positions; i++) { CurrentTile = CurrentTile.NextTile; if (CurrentTile.Equals(CurrentGame.Start)) { Money += 200; } } } } CurrentTile.DoAction(this); }
//Jobs void UpdateJob(float time) { //If no job is assigned, look for a job if (this.CurrentJob == null) { if (!this.jobs.IsEmpty) { this.CurrentJob = jobs.DequeueValue(); } else { //IDLE as there are no jobs this.CurrentJob = new Job(this.CurrentTile, JobList.JobFunctions[(int)JobList.Jobs.Idle], 5f); this.adjacentJobTile = this.CurrentTile; } } else { //If standing on the right tile, do the job if (CurrentTile.Equals(this.adjacentJobTile)) { //Job is performed regardless of outcome here if (this.CurrentJob.PerformJob(time)) { this.CurrentJob.OnCompleteJob(this.CurrentJob.Tile, this); this.CurrentJob = null; this.adjacentJobTile = null; } } else { //If not in range and not travelling, start to travel if (currentPath == null) { Tile dest = this.CurrentJob.Tile.NearestNeighbourTo(this.CurrentTile.X, this.CurrentTile.Y); SetDest(dest); this.adjacentJobTile = dest; } //Else the villager is travelling but not close enough yet } } }