private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            instance.healthbar  = FindObjectOfType <HealthBarController>();
            instance.hudManager = FindObjectOfType <HUDmanager>();
            instance.respawner  = FindObjectOfType <RespawnBehavior>();
            instance.deathSound = FindObjectOfType <DeathSoundBehavior>();
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        hudManager = FindObjectOfType <HUDmanager>();
        healthbar  = FindObjectOfType <HealthBarController>();
        respawner  = FindObjectOfType <RespawnBehavior>();
        deathSound = FindObjectOfType <DeathSoundBehavior>();
    }
Beispiel #2
0
    private void Start()
    {
        rigidBody.drag = playerDeceleration;

        life                = maxLife;
        score               = 0;
        canShoot            = true;
        canShield           = true;
        damageable          = true;
        stunSlider.maxValue = stunTime;

        lifeText.text = "Vida: " + life;
        scoreText.GetComponent <TMPro.TextMeshProUGUI>().text = score + " pts";
        hudManager = GetComponent <HUDmanager>();
        GetBalaIndex();
        if (PhotonNetwork.IsConnected && PV.IsMine)
        {
            canvas.SetActive(true);
            mainCamera.enabled      = true;
            playerInput.enabled     = true;
            mobileCharacter.enabled = true;
            audioListener.enabled   = true;
            sAlas.Play();
        }
        if (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient)
        {
            matchController = FindObjectOfType <MatchController>();
            matchController.AddPlayer(this);
            teamId = FindObjectOfType <RoomManager>().FindTeamIdByPlayer(PV.Owner);
            if (teamId == -1)
            {
                teamId = 0;
                Debug.Log("No se ha encontrado el teamId, se le ha añadido al equipo 0");
            }
            PV.RPC("GetSpawnpoint_RPC", RpcTarget.All, teamId);
        }
        else if (!PhotonNetwork.IsConnected)
        {
            canvas.SetActive(true);
            mainCamera.enabled      = true;
            playerInput.enabled     = true;
            mobileCharacter.enabled = true;
            RoomManagerOffline RMO = FindObjectOfType <RoomManagerOffline>();
            if (RMO.gamemodeIndex == 3)
            {
                teamId = 0;
            }
            else
            {
                teamId = RMO.jugadoresInfo[GetComponentInChildren <PlayerInput>().playerIndex + 1][1];
            }
            if (playerInput.playerIndex == 0)
            {
                audioListener.enabled = true;
            }
            matchController = FindObjectOfType <MatchController>();
            matchController.AddPlayer(this);
            spawnPoint = matchController.GetSpawnPoint(this);
            GetComponent <Transform>().position = spawnPoint.transform.position;
            hudManager.setBackground();
        }

        movementSM = new StateMachine();

        groundedState = new GroundedState(this, movementSM);
        shootingState = new ShootingState(this, movementSM);
        shieldState   = new ShieldState(this, movementSM);
        deadState     = new DeadState(this, movementSM);
        stunState     = new StunState(this, movementSM);
        feederState   = new FeederState(this, movementSM);

        movementSM.Initialize(groundedState);
    }
Beispiel #3
0
 private void Start()
 {
     cam = this.gameObject.GetComponentInChildren<Camera>();
     hud = (HUDmanager)GameObject.FindObjectOfType(typeof(HUDmanager));
 }
 private void Start()
 {
     cam = this.gameObject.GetComponentInChildren <Camera>();
     hud = (HUDmanager)GameObject.FindObjectOfType(typeof(HUDmanager));
 }