Exemplo n.º 1
0
    private void Awake()
    {
        container = InGameManager.Instance.PlayerDataContainer_readonly;

        characterData = GameManager.Instance.CharacterSheet_readonly.m_data[GameManager.Instance.selectedPlayableUnit.index];
        Hp            = characterData.hp;
        IsShield      = true;

        MoveSpeed = characterData.move.moveSpeed;

        Bomb  = 0;
        Pearl = 0;

        gunSheet = GameManager.Instance.gunSheet_readonly;

        for (int count = 0; count < gunSheet.m_data.Count; count++)
        {
            if (gunSheet.m_data[count].name == characterData.firstGunName)
            {
                Debug.Log(gunSheet.m_data[count].name + count + characterData.firstGunName);
                gunData = gunSheet.m_data[count];
                break;
            }
        }
    }
    private void Start()
    {
        player            = GameObject.FindGameObjectsWithTag("Player");
        myplayer          = player[0];
        PlayerStats       = myplayer.GetComponent <PlayerStats>();
        piranyasDualesDM  = bala.GetComponent <BSPiranyasDuales>().bulletDamage;
        piranyasDualesDMK = bala.GetComponent <BSPiranyasDuales>().bulletDamageFireKepot;

        if (_gunSheet == null)
        {
            _gunSheet = FindObjectOfType <GunSheet>();
        }
        _gunSheet.updateBulletsInfo(bulletsLeft + " / " + magazineSize);
    }
Exemplo n.º 3
0
    IEnumerator Disparar()
    {
        Vector3 direccionBala = new Vector3();

        if (fpsCam != null && inputHandler != null && inputHandler.lockOnFlag)
        {
            Ray        ray = fpsCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); //Just a ray through the middle of your current view
            RaycastHit hit;
            //check if ray hits something
            Vector3 targetPoint;
            if (Physics.Raycast(ray, out hit))
            {
                targetPoint = hit.point;
            }
            else
            {
                targetPoint = ray.GetPoint(75); //Just a point far away from the player
            }
            //Calculate direction from attackPoint to targetPoint
            direccionBala = targetPoint - attackPoint.position;
        }



        while (rafaga && bulletsLeft > 0)
        {
            sonidoDisparo.Play();
            muzzleFlash.Emit(1);
            if (fpsCam != null && inputHandler != null && inputHandler.lockOnFlag)
            {
                GameObject currentBullet = Instantiate(bala, spawner.position, spawner.rotation);
                currentBullet.transform.forward = direccionBala.normalized;
            }
            else
            {
                Instantiate(bala, spawner.position, spawner.rotation);
            }

            bulletsLeft--;
            playerInventory.PDBleft = bulletsLeft;
            //Debug.Log(bulletsLeft+" / "+magazineSize);
            if (_gunSheet == null)
            {
                _gunSheet = FindObjectOfType <GunSheet>();
            }

            _gunSheet.updateBulletsInfo(bulletsLeft + " / " + magazineSize);
            yield return(new WaitForSeconds(cadencia));
        }
    }
    public void Awake()
    {
        fpsCam          = FindObjectOfType <Camera>();
        inputHandler    = FindObjectOfType <InputHandler>();
        playerInventory = FindObjectOfType <PlayerInventory>();

        if (playerInventory.primeraCargaCC)
        {
            bulletsLeft                    = magazineSize;
            playerInventory.CCBleft        = magazineSize;
            playerInventory.primeraCargaCC = false;
        }
        else
        {
            bulletsLeft = playerInventory.CCBleft;
        }

        _gunSheet = FindObjectOfType <GunSheet>();
    }