Esempio n. 1
0
    private void Start()
    {
        GetBalaIndex();

        GetRigidBody().drag = GetPlayerDeceleration();

        life  = 1;
        score = 0;
        SetCanShoot(true);
        damageable = true;

        matchController = FindObjectOfType <MatchController>();
        //matchController.AddPlayer(this);
        spawnPoint = matchController.GetSpawnPoint(this);

        teamId = 5;

        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(shootingState);
    }
 public void setState(bool OnOff)
 {
     if (OnOff)
     {
         feederState = FeederState.ON;
     }
     else
     {
         feederState = FeederState.OFF;
     }
 }
        public TankFeeder(int pop)
        {
            doseSize  = pop / 2;
            frequency = 12;

            if (pop != 0)
            {
                feederState = FeederState.ON;
            }
            else
            {
                feederState = FeederState.OFF;
            }
        }
Esempio n. 4
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);
    }