private void OnConnect(NetworkConnection connection) { Debug.Log("Accepted a connection"); Client new_client = new Client(); new_client.id = connection.InternalId.ToString(); new_client.color.R = Random.Range(0.0f, 1.0f); new_client.color.G = Random.Range(0.0f, 1.0f); new_client.color.B = Random.Range(0.0f, 1.0f); NewPlayer new_player = new NewPlayer(new_client); foreach (Client client in clients) { SendData(new_player, client); } new_player.cmd = Commands.OWN_ID; Debug.Log("Send ID"); SendData(new_player, connection); Debug.Log("Send List"); SendData(new ConnectedPlayer(clients), connection); clients.Add(new_client); players.Add(new GameObject()); m_Connections.Add(connection); }
public static PlayerBase CreateMainPlayerLogic(BriefAttr briefAttr)//GameMsg_S2C_CreateRoleSuc createMsg) { GameObject go = new GameObject("MainPlayer"); GameObject.DontDestroyOnLoad(go); NewPlayer newPlayer = go.AddComponent <NewPlayer>(); if (newPlayer != null) { newPlayer.IsToShow = true; newPlayer.RoleAttr = new PlayerAttr(); newPlayer.RoleAttr.Serialize(briefAttr); CommonLogicData.MainPlayer = newPlayer; CommonLogicData.MainPlayerID = newPlayer.RoleAttr.RoleID; //MainPlayerItem roleItem = new MainPlayerItem(); //roleItem.InitItemList(9);//newPlayer.RoleAttr.BadgeGridNum); //newPlayer.RoleItem = roleItem; } else { Debug.LogError("PlayerManager CreateMainPlayerLogic ,newPlayer can not be null."); } return(newPlayer); }
void SpawnPlayers() { if (lastestGameState.players.Length > 0 && ClientID == null) { ClientID = lastestGameState.players[lastestGameState.players.Length - 1].id; } while (len <= lastestGameState.players.Length - 1) { NewPlayer temp = new NewPlayer(); temp.playerObj = GameObject.CreatePrimitive(PrimitiveType.Cube); Renderer rend = temp.playerObj.GetComponent <Renderer>(); rend.material = new Material(Shader.Find("Standard")); temp.playerObj.GetComponent <Renderer>().material = rend.material; temp.playerObj.transform.position = new Vector3(len * 2, 0, 0); temp.playerObj.AddComponent <ClientCube>(); temp.player.color = lastestGameState.players[len].color; temp.player.id = lastestGameState.players[len].id; temp.playerObj.GetComponent <ClientCube>().id = temp.player.id; temp.playerObj.AddComponent <PlayerCS>(); temp.playerObj.GetComponent <PlayerCS>().id = temp.player.id; temp.playerObj.GetComponent <PlayerCS>().netMan = this; newPlayers.Add(temp); len++; } }
private void Start() { _sentences = new Queue <string>(); _canvasManager = FindObjectOfType <CanvasManager>(); _player = FindObjectOfType <NewPlayer>(); _gammie = FindObjectOfType <Gammie>(); if (_player == null) { Debug.Log("Player is NULL"); } if (_canvasManager == null) { Debug.Log("UI Manager is NULL"); } _eventManager = EventManager.Instance != null ? EventManager.Instance : FindObjectOfType <EventManager>(); if (_eventManager == null) { Debug.Log("Event Manager is null"); } _initialDialogHelp = true; _currentChar = ""; _typeWriterComplete = true; }
public async Task <Player> Register(NewPlayer model, bool sudo = false) { var game = await GameStore.Retrieve(model.GameId); if (!sudo && !game.RegistrationActive) { throw new RegistrationIsClosed(); } var user = await Store.GetUserEnrollments(model.UserId); if (user.Enrollments.Any(p => p.GameId == model.GameId)) { throw new AlreadyRegistered(); } var entity = Mapper.Map <Data.Player>(model); entity.TeamId = Guid.NewGuid().ToString("n"); entity.Role = PlayerRole.Manager; entity.ApprovedName = user.ApprovedName; entity.Name = user.ApprovedName; entity.Sponsor = user.Sponsor; entity.SessionMinutes = game.SessionMinutes; await Store.Create(entity); return(Mapper.Map <Player>(entity)); }
// Use this for initialization void Start() { playerFloorLight = GameObject.Find("floorLight").GetComponent <Light>(); originalLightColor = playerFloorLight.color; player = GameObject.Find("newPlayer").GetComponent <NewPlayer>(); spectrum = GameObject.FindGameObjectWithTag("songMan").GetComponent <AudioSpectrum>(); Collider[] windows = Physics.OverlapSphere(new Vector3(25, 30, 9), sphereRadius, windowsLayer); preLights = new MeshRenderer[windows.Length]; //Debug.Log(windows.Length); for (int i = 0; i < windows.Length; i++) { preLights[i] = windows[i].GetComponent <MeshRenderer>(); } float s, v; Color.RGBToHSV(originalLightColor, out lightHue, out s, out v); originalHue = lightHue; originalMoonEuler = moon.eulerAngles; }
private void SetVisibility(bool exit, bool newPlayer, bool firstPick, bool confirmation) { ExitConfirmation.SetActive(exit); NewPlayer.SetActive(newPlayer); FirstPick.SetActive(firstPick); Confirmation.SetActive(confirmation); }
static void Main(string[] args) { PlayerManager playermanager = new PlayerManager(); GameManager gamemanager = new GameManager(); NewPlayer player1 = new NewPlayer() { PlayerName = "Ahmet", PlayerSurname = "Akoguz", PlayerTc = "123456789", PlayerDate = new DateTime(2003, 05, 01) }; Games newgame = new Games() { GameName = "BTD5", Price = 100, DiscountPrice = 0 }; Games newgame1 = new Games() { GameName = "abc", Price = 50, DiscountPrice = 0 }; Games newgame2 = new Games() { GameName = "abcd", Price = 70, DiscountPrice = 0 }; Games newgame3 = new Games() { GameName = "abcde", Price = 120, DiscountPrice = 0 }; gamemanager.AddGame(newgame); gamemanager.AddGame(newgame1); gamemanager.AddGame(newgame2); gamemanager.AddGame(newgame3); playermanager.PlayerSignIn(player1); }
// Start is called before the first frame update private void Start() { //reference player rage _bc = GetComponent <BoxCollider2D>(); _rb = GetComponent <Rigidbody2D>(); _player = FindObjectOfType <NewPlayer>(); }
public static PlayerBase CreateLogic(GameObject targetObject, BriefAttr briefAttr, bool bVisible, NetReadBuffer itemBuf, NetReadBuffer geneBuf, bool dontDestroyOnLoad) { NewPlayer newPlayer = null; if (targetObject == null) { targetObject = new GameObject(briefAttr.m_strRoleName); } if (dontDestroyOnLoad) { GameObject.DontDestroyOnLoad(targetObject); } newPlayer = targetObject.AddComponent <NewPlayer>(); if (newPlayer != null) { //newPlayer.RoleBone = targetObject.GetComponentInChildren<PlayerBone>(); //if (newPlayer.RoleBone != null) //{ // newPlayer.RoleBody = targetObject; //} newPlayer.IsToShow = bVisible; //newPlayer.PlayerMoveType = SystemManager.SysMgr.m_DefPlayerMoveType; newPlayer.RoleAttr = new PlayerAttr(); newPlayer.RoleAttr.Serialize(briefAttr); } else { Debug.LogError("PlayerManager CreateLogic ,newPlayer can not be null."); } return(newPlayer); }
void OnReceived(IAsyncResult result) { // this is what had been passed into BeginReceive as the second parameter: UdpClient socket = result.AsyncState as UdpClient; // points towards whoever had sent the message: IPEndPoint source = new IPEndPoint(0, 0); // get the actual message and fill out the source: byte[] message = socket.EndReceive(result, ref source); // do what you'd like with `message` here: string returnData = Encoding.ASCII.GetString(message); Debug.Log("Got this: " + returnData); latestMessage = JsonUtility.FromJson <Message>(returnData); try{ switch (latestMessage.cmd) { case commands.SERVER_CONNECTED: { NewPlayer newPlayer = JsonUtility.FromJson <NewPlayer>(returnData); clientId = newPlayer.player.id; newPlayers.Add(newPlayer.player); break; } case commands.NEW_CLIENT: { NewPlayer newPlayer = JsonUtility.FromJson <NewPlayer>(returnData); newPlayers.Add(newPlayer.player); break; } case commands.UPDATE: previousTime = latestTime; previousGameState = lastestGameState; latestTime = currentTime; lastestGameState = JsonUtility.FromJson <GameState>(returnData); break; case commands.CLIENT_DROPPED: NewPlayer droppedPlayer = JsonUtility.FromJson <NewPlayer>(returnData); disconnectedPlayers.Add(droppedPlayer.player); break; default: Debug.Log("Error"); break; } } catch (Exception e) { Debug.Log(e.ToString()); } // schedule the next receive operation once reading is done: socket.BeginReceive(new AsyncCallback(OnReceived), socket); }
public async Task <Player> CreatePlayer([FromBody] NewPlayer newPlayer) { DateTime birthDate = new DateTime(newPlayer.Year, newPlayer.Month, newPlayer.Day); if ((DateTime.Now - birthDate).TotalSeconds < 0) { //Syntymäpäivä oli tulevaisuudesta //Heitetäänkö jonkilainen error? throw new InvalidDateException(); } Player player = new Player() { Nationality = newPlayer.Nationality, Id = Guid.NewGuid().ToString(), CreationDate = DateTime.Now, BirthDate = new DateTime(newPlayer.Year, newPlayer.Month, newPlayer.Day), Gender = newPlayer.Gender, Sessions = 0, // BirthDate = birthDate, // Gender = newPlayer.Gender }; return(await _repository.CreatePlayer(player)); }
public void new_new_player(string name) { NewPlayer newPlayer = new NewPlayer(); newPlayer.Name = name; Create(newPlayer); }
void LateUpdate() { if (target == null) { var col = FindObjectsOfType <NewPlayer>().Where(x => x.ID == MultiplayerManager.connectionID).ToList(); if (col.Count == 0) { return; } _player = col.First(); if (_player) { target = _player.gameObject; } optimize = true; return; } if (follow) { transform.position = target.transform.position; transform.position -= target.transform.forward * distance; transform.position += Vector3.up * height; } transform.LookAt(target.transform); }
private void Btn_newPlayer_Click(object sender, EventArgs e) { NewPlayer form = new NewPlayer(); form.NewPlayerCreated += NewPlayerCreated; form.Show(); }
private void OnData(DataStreamReader stream) { NativeArray <byte> message = new NativeArray <byte>(stream.Length, Allocator.Temp); stream.ReadBytes(message); string returnData = Encoding.ASCII.GetString(message.ToArray()); NetworkHeader header = new NetworkHeader(); header = JsonUtility.FromJson <NetworkHeader>(returnData); switch (header.cmd) { case Commands.NEW_CLIENT: { Debug.Log("New client"); NewPlayer np = JsonUtility.FromJson <NewPlayer>(returnData); Debug.Log("NEW_CLIENT: " + np.player.ToString()); SpawnPlayers(np.player); break; } case Commands.UPDATE: { UpdatedPlayer up = JsonUtility.FromJson <UpdatedPlayer>(returnData); UpdatePlayers(up.update); break; } case Commands.CLIENT_DROPPED: { DisconnectedPlayer dp = JsonUtility.FromJson <DisconnectedPlayer>(returnData); DestroyPlayers(dp.disconnect); Debug.Log("Client dropped"); break; } case Commands.CLIENT_LIST: { ConnectedPlayer cp = JsonUtility.FromJson <ConnectedPlayer>(returnData); SpawnPlayers(cp.connect); Debug.Log("Client list"); break; } case Commands.OWN_ID: { NewPlayer p = JsonUtility.FromJson <NewPlayer>(returnData); myID = p.player.id; SpawnPlayers(p.player); Debug.Log("OWN_ID: " + myID); break; } default: Debug.Log("Error"); break; } }
public async Task <Player> Create([FromBody] NewPlayer newPlayer) { logger.LogInformation("Creating player with name " + newPlayer.Name); Player nPlayer = new Player( ); nPlayer.Name = newPlayer.Name; return(await repo.Create(nPlayer)); }
public Task <Player> Create(NewPlayer player) { Player newPlayer = new Player( ); newPlayer.Id = new Guid( ); newPlayer.Name = player.Name; return(repo.Create(newPlayer)); }
/// <summary> /// Apenas consulta de estrutuda dos dados a serem enviados no formato Json /// </summary> /// <returns>Exemplo da estrutura para criação de um novo jogador</returns> // GET: api/UpdScores public NewPlayer Get() { NewPlayer player = new NewPlayer { CallerID = "ID do APP fazendo request", CallerPW = "password", Nickname = "Nick do Novo usuário", Password = "******" }; return(player); }
public void Constructor_MultipleBotsOfSameTypeIsAllowed() { var bot = new NewPlayer( new PlayerHandle("Resistance is futile"), PlayerType.Bot); Assert.NotNull(new PlayerList(randomFirstPlayer: false, bot, bot)); }
private void Start() { _anim = GetComponent <Animator>(); _player = FindObjectOfType <NewPlayer>(); _bc = GetComponent <BoxCollider2D>(); _sfxVol = 1.5f; }
public override void OnEvent(NewPlayer evnt) { GameObject[] tanks = GameObject.FindGameObjectsWithTag("tank"); if (tanks.Length > 1) { Complete.GameManager.instance.Begin(); } }
private void Start() { _player = FindObjectOfType <NewPlayer>(); _anim = GetComponent <Animator>(); _bc = GetComponent <BoxCollider2D>(); Physics2D.IgnoreCollision(_bc, _table.GetComponent <BoxCollider2D>()); }
public async Task<Player> Create(NewPlayer player) { Player player2 = new Player(); player2.Name = player.Name; player2.Id = Guid.NewGuid(); player2.Level = 1; var value = await repo.Create(player2); return value; }
public async Task <Player> Create(NewPlayer nPlaya) { Player p = new Player(Guid.NewGuid(), nPlaya.Name) { Lvl = nPlaya.Lvl }; return(await repo.Create(p)); }
public Task <Player> Create([FromBody] NewPlayer player) { Player newPlayer = new Player() { Id = Guid.NewGuid(), Name = player.Name }; return(_repository.Create(newPlayer)); }
public Task <Player> Create([FromBody] NewPlayer player) { var value = plaPro.Create(player); if (value == null) { return(null); } return(value); }
public NewPlayer SpawnPlayer(int id) { GameObject go = Instantiate(model); go.transform.localPosition = new Vector3(0, 0, 0); NewPlayer player = go.GetComponent <NewPlayer>(); player.ID = id; return(player); }
public Task <Player> AddNewPlayer([FromBody] NewPlayer newPlayer) { logger.LogInformation("Creating player with name " + newPlayer.Name); Player player = new Player( ) { Name = newPlayer.Name }; return(repo.AddNewPlayer(player)); }
public Task <Player> Create(NewPlayer newPlayer) { Player player = new Player() { Id = Guid.NewGuid(), Name = newPlayer.Name }; return(_repository.CreatePlayer(player)); }