Ejemplo n.º 1
0
    IEnumerator waitForSetPlayer(ChimeraController chimeraController, string ids)
    {
        yield return(new WaitForEndOfFrame());

        chimeraController.GetComponent <PhotonChimeraMultiplayerController>().addDelegate();
        chimeraController._setPlayersInFusion(ids);
    }
Ejemplo n.º 2
0
    IEnumerator createChimera(List <GameObject> _players)
    {
        yield return(new WaitForEndOfFrame());

        if (_isHost())
        {
            Debug.Log("SOY HOST - CREAR CHIMERA");

            //Calcular punto medio
            float xPos = 0;
            float yPos = 0;

            foreach (var player in _players)
            {
                xPos += player.transform.position.x;
                yPos += player.transform.position.y;
            }

            xPos = xPos / _players.Count;
            yPos = yPos / _players.Count;

            Vector2 newPos = new Vector2(xPos, yPos);

            //Saber qué chimera crear
            GameObject chimeraTocreate = selectCorrectChimera(_players);
            string     chimeraName     = chimeraTocreate.name;

            //Crear chimera
            GameObject _chimera = PhotonNetwork.Instantiate(chimeraName, newPos, Quaternion.identity);
            _chimera.transform.position = newPos;

            foreach (var player in _players)
            {
                player.GetComponent <FusionTrigger>().IsOnFusion = true;
            }

            ChimeraController chimeraController = _chimera.GetComponent <ChimeraController>();

            //crear cadena de ids
            string ids = _players[0].GetComponent <FusionTrigger>()._myID();

            for (int i = 1; i < _players.Count; i++)
            {
                string newId = "#" + _players[i].GetComponent <FusionTrigger>()._myID();
                ids += newId;
            }

            //Se debe llamar en los demás también
            chimeraController.setPlayersInFusion(ids);                //local

            StartCoroutine(waitForSetPlayer(chimeraController, ids)); //para todas las maquinas
        }
    }
Ejemplo n.º 3
0
    public void setOnFusion(GameObject chimeraController, int fusionID)
    {
        Debug.Log("Set On Fusion entre (" + chimeraController.name + " y " + gameObject.name + ")");

        //Saber si estoy en fusion y mi id para la chimera
        _isOnFusion = true;
        _onFusionID = fusionID;

        //Informaciónd e la chimera en la que estoy
        _currentChimeraParent = chimeraController.GetComponent <ChimeraController>();

        transform.SetParent(chimeraController.transform);
        transform.localPosition = Vector3.zero;

        //assingSkillsTochimera(chimeraController);

        Debug.Log("Set On Fusion SALÍ");
    }
    public void addDelegate()
    {
        _chimeraController = GetComponent <ChimeraController>();
        _chimeraSkills     = GetComponent <ChimeraSkillsController>();
        _chimeraHP         = GetComponent <PlayerHPControl>();

        _chimeraController._setPlayersInFusion  = new ChimeraController.DelegateMultiplayerControllerIDs(pushSetPlayersInFusion);
        _chimeraController._isMine              = new ChimeraController.DelegateMultiplayerController(isMine);
        _chimeraController._sendMovement        = new ChimeraController.DelegateMultiplayerControllerIMove(pushsendMovement);
        _chimeraController._sendPlayerInChimera = new ChimeraController.DelegateMultiplayerControllerSendPlayerInChimera(sendSetPlayersInChimera);
        _chimeraController._isHost              = new ChimeraController.DelegateMultiplayerController(isHost);
        _chimeraController._destroySelf         = new ChimeraController.DelegateMultiplayerControllerSendPlayerInChimera(destroySelf);
        _chimeraController._sendUnFusion        = new ChimeraController.DelegateMultiplayerControllerSendUnFusion(pushSendUnFusion);
        _chimeraController._unFusion            = new ChimeraController.DelegateMultiplayerControllerSendPlayerInChimera(pushUnFusion);

        _chimeraSkills._isMine         = new ChimeraSkillsController.DelegateMultiplayerSkillController(isMine);
        _chimeraSkills._isHost         = new PlayerSkills.DelegateMultiplayerController(isHost);
        _chimeraSkills._directionShoot = new ChimeraSkillsController.DelegateMultiplayerSkillControllerDirectionShoot(sendDirectionShoot);

        _chimeraHP._isMine      = new PlayerHPControl.DelegateMultiplayerController(isMine);
        _chimeraHP._destroySelf = new PlayerHPControl.DelegateMultiplayerControllerDestroy(destroySelf);
    }