Ejemplo n.º 1
0
 public void ProcessCreationRequest(int clientId, Vector3 creationPosition, ObjectEnum objectType)
 {
     Debug.Log("Creation request received from client " + clientId + " position " + creationPosition);
     if (objectType.Equals(ObjectEnum.Ball))
     {
         Ball newBall = _objectFactory.CreateBall(creationPosition, clientId);
         _eventManager.BroadcastEventAction(new CreationAction(newBall.Position, newBall.ObjectId, ObjectEnum.Ball));
         _eventManager.SendEventAction(new AssignPlayerAction(newBall.ObjectId), clientId);
         BallController ballController = Instantiate(ballPrefab).GetComponent <BallController>();
         ballController.SetBall(newBall);
         _balls.Add(ballController);
     }
 }
Ejemplo n.º 2
0
    public void ProcessCreationRequest(int clientId, Vector3 creationPosition, ObjectEnum objectType)
    {
        Debug.Log("Creation request received from client " + clientId + " " + objectType + " at " + creationPosition);
        if (objectType.Equals(ObjectEnum.Player))
        {
            int objectId = _objectIdManager.GetNext();
            PlayerController playerController = Instantiate(PlayerPrefab).GetComponent <PlayerController>();
            playerController.InitializeServer(objectId, clientId, creationPosition, HealthWatcher);
            _objects.Add(playerController);

            _eventManager.BroadcastEventAction(new CreationAction(creationPosition, objectId, objectType));
            _eventManager.SendEventAction(new AssignPlayerAction(objectId), clientId);
        }
    }
Ejemplo n.º 3
0
 public void ProcessObjectCreation(int objectId, Vector3 creationPosition, ObjectEnum objectType, int clientId)
 {
     Debug.Log("Creation action received from server.");
     if (objectType.Equals(ObjectEnum.Ball))
     {
         Ball           newBall        = new Ball(clientId, objectId, creationPosition);
         BallController ballController = Instantiate(ballPrefab).GetComponent <BallController>();
         ballController.SetBall(newBall);
         if (newBall.ObjectId.Equals(_playerObjectId))
         {
             Camera.GetComponent <CameraController>().SetPlayer(ballController.gameObject);
         }
         _balls.Add(ballController);
     }
 }