Esempio n. 1
0
        public async Task SaveDemoData(NewDemoCommand demo)
        {
            var teamA = await _context.Teams.AsNoTracking().FirstOrDefaultAsync(f => f.Id == demo.TeamAId);

            var teamB = await _context.Teams.AsNoTracking().FirstOrDefaultAsync(f => f.Id == demo.TeamBId);

            if (teamA == null || teamB == null)
            {
                throw new HttpStatusCodeException(System.Net.HttpStatusCode.BadRequest, "Command not found");
            }

            var teamADemos = demo.Demo.TeamA.TeamName.ToLower() == teamA.Name.ToLower() ? demo.Demo.TeamA :
                             demo.Demo.TeamB.TeamName.ToLower() == teamA.Name.ToLower() ? demo.Demo.TeamB :
                             throw new HttpStatusCodeException(System.Net.HttpStatusCode.BadRequest, $"Team {teamA.Name} from demo files not found");

            teamADemos.TeamId = teamA.Id;

            var teamBDemos = demo.Demo.TeamA.TeamName.ToLower() == teamB.Name.ToLower() ? demo.Demo.TeamA :
                             demo.Demo.TeamB.TeamName.ToLower() == teamB.Name.ToLower() ? demo.Demo.TeamB :
                             throw new HttpStatusCodeException(System.Net.HttpStatusCode.BadRequest, $"Team {teamB.Name} from demo files not found");

            teamBDemos.TeamId = teamB.Id;

            demo.Demo.TeamA = teamADemos;
            demo.Demo.TeamB = teamBDemos;

            var newDemo = new GameDemo
            {
                TeamAId     = teamA.Id,
                TeamBId     = teamB.Id,
                DateCreated = DateTime.UtcNow,
                DemoData    = JsonConvert.SerializeObject(demo.Demo),
            };

            _context.Demos.Add(newDemo);
            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
	//Show Demo
	protected abstract void ShowDemo(GameDemo.OnDemoDelegate onDemo);
Esempio n. 3
0
	protected virtual void OnDemo(GameDemo thisDemo, bool complete)	{
		if (complete) {			
			this.Reset(true);
		}else{
			thisDemo.demoLevel ++;
			thisDemo.StartDemo();
		}
	}