public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) { GameObject startingCity = GameObject.Find("Board/Cities/Atlanta"); GameObject localPlayer = Instantiate(this.playerObjectPrefab, Vector3.zero, Quaternion.identity); GameScript curGame = game.GetComponent <GameScript>(); RoleScript role = curGame.getRole(); localPlayer.GetComponent <PlayerScript>().init("AAAAA", startingCity, role); //localPlayer.GetComponent<Renderer>().material = roleMaterial; Color pawnColor = Color.black; switch (role.getRoleName()) { case Role.ContingencyPlanner: pawnColor = Color.cyan; break; case Role.Dispatcher: pawnColor = Color.magenta; break; case Role.Medic: pawnColor = Color.yellow; break; case Role.OperationsExpert: pawnColor = Color.grey; break; case Role.QuarantineSpecialist: pawnColor = Color.green; break; case Role.Researcher: pawnColor = Color.red; break; case Role.Scientist: pawnColor = Color.white; break; default: break; } localPlayer.GetComponent <Renderer>().material.SetColor("_Color", pawnColor); // GameObject actionPanel = Instantiate(this.actionPanelPrefab); // actionPanel.GetComponent<CanvasScript>().init(localPlayer); // localPlayer.GetComponent<PlayerScript>().setActionPanel(actionPanel); // // actionPanel.SetActive(false); // init event trigger controller and action panel this.board.GetComponent <EventTriggerController>().init(); //this.actionPanel.GetComponent<ActionPanelScript>().init(localPlayer); NetworkServer.AddPlayerForConnection(conn, localPlayer, playerControllerId); }
// Use this for initialization void Start() { // Maybe should move this to another method for initialization cities = GameObject.FindGameObjectsWithTag("City"); // Add every role in roleGame so we can choose from them when initializing a player foreach (Role role in PandemicEnum.Role.GetValues(typeof(Role))) { RoleScript newRole = new RoleScript(); newRole.setRole(role); gameRole.Add(newRole); } // Add every cityCard in player deck playerDeck = new Deck(); for (int i = 0; i < cities.Length; i++) { PlayerCityCardScript cityCard = new PlayerCityCardScript(); int population = cities[i].GetComponent <CityScript>().getPopulation(); cityCard.init(cities[i], population); playerDeck.insert(cityCard); } foreach (PhotonPlayer player in PhotonNetwork.otherPlayers) //fill in player list { playersInGame.Add(player.NickName); } roomname = PhotonNetwork.room.Name; //get room name //setupBaseGame (); }
public RoleScript getRole() { int randomIndex = Random.Range(0, this.gameRole.Count); RoleScript role = gameRole[randomIndex]; gameRole.RemoveAt(randomIndex); return(role); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); }); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseAuthentication(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); using var scope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope(); using var context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); if (context.Database.EnsureCreated()) { var roles = RoleScript.Roles(); var admin = AdministratorScript.ApplicationUser(); var adminUser = UserRoleScript.UserRole(roles.FirstOrDefault(x => x.NormalizedName.Equals("ADMINISTRATOR")), admin); var types = TypeScript.GetTypes(); var company = CompanyScript.GetCompany(); var user = UserScript.ApplicationUser(); var userRole = UserRoleScript.UserRole(roles.FirstOrDefault(x => x.NormalizedName.Equals("USER")), user); var vehiclesList = VehicleScript.GetVehicles(); context.Roles.AddRangeAsync(roles).Wait(); context.ApplicationUser.Add(admin); context.UserRoles.Add(adminUser); context.Type.AddRangeAsync(types).Wait(); context.Company.Add(company); context.ApplicationUser.Add(user); context.UserRoles.Add(userRole); context.UserCompany.Add(new UserCompany { CompanyID = company.ID, UserID = user.Id }); context.SaveChangesAsync().Wait(); } }
public void init(string name, GameObject startCity, RoleScript role) { this.playerName = name; this.role = role; this.hand = new List <PlayerCardScript> (); // TODO:: if role == generalist, set total actions to 5 /*if (role.getRoleName() == Role.Generalist) { * this.totalActions = 5; * } * else { * this.totalActions = 4; * }*/ this.totalActions = 4; this.actionsLeft = this.totalActions; setCurrentCity(startCity); }