void OnTriggerStay2D(Collider2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            if (Input.GetAxis("Fire2") != 0.0f && axisInUse == false)
            {
                axisInUse = true;

                if (currentState == DoorState.LOCKED)
                {
                    bool tryToUnlock = TryToUnlock();
                    if (tryToUnlock)
                    {
                        SetState(DoorState.UNLOCKED);

                        FXAudio.PlayClip("DoorUnlocked");
                    }
                    else
                    {
                        FXAudio.PlayClip("DoorLocked");
                    }
                }
                else if (currentState == DoorState.OPEN)
                {
                    GameState.SetState(GameState.ResultType.WIN);
                    SceneManager.LoadScene("Result", LoadSceneMode.Single);
                }
            }
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        FXAudio.Init();
        MusicAudio.Init();

        offset = transform.position - player.transform.position;
    }
Exemplo n.º 3
0
 private void Awake()
 {
     if (_FxAudio != null)
     {
         _FxAudio = GameObject.FindGameObjectWithTag(GENERAL_TAG.FXAUDIO).GetComponent <FXAudio>();
     }
 }
Exemplo n.º 4
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (healthPoints > 0)
        {
            if (col.gameObject.tag == "ground" && col.contacts [0].collider.sharedMaterial == null)
            {
                SetMovementLimits(col.contacts [0]);
            }
            else if (col.gameObject.tag == "Player")
            {
                if (Mathf.Approximately(col.contacts [0].normal.x, 1.0f) || Mathf.Approximately(col.contacts [0].normal.x, -1.0f))
                {
                    Attack(col.gameObject, col.contacts [0].normal);
                }
            }
            else if (col.gameObject.layer == LayerMask.NameToLayer("ThrownObject"))
            {
                if (Mathf.Abs(col.rigidbody.velocity.x) > 10.0f)
                {
                    ReceiveDamage(1.0f);
                }
            }
            else
            {
                Flip();
            }
        }

        FXAudio.PlayClip("Hit");
    }
Exemplo n.º 5
0
    void Update()
    {
        if (PlayerState.HealthPoints > 0.0f)
        {
            if (hasShoot)
            {
                myShootDelay -= Time.deltaTime;
            }

            if (myShootDelay <= 0)
            {
                hasShoot     = false;
                myShootDelay = shootDelay;
            }

            if (Input.GetAxis("Fire1") > 0.0f && hasShoot == false)
            {
                hasShoot = true;
                FXAudio.PlayClip("Shoot");
                CreateNewBullet();
                PlayerState.IsShooting = true;
            }

            if (Input.GetAxis("Fire1") == 0.0f)
            {
                PlayerState.IsShooting = false;
            }
        }
    }
Exemplo n.º 6
0
 private void FxVolumeSliderValueChanged(float value)
 {
     if (fxVolumeSlider != null)
     {
         FXAudio.SetVolume(value / fxVolumeSlider.maxValue);
         FXAudio.PlayClip("Hit");
     }
 }
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Player" && PlayerState.HealthPoints > 0.0f)
     {
         PlayerState.Score += value;
         FXAudio.PlayClip("PickupCoin");
         Destroy(gameObject);
     }
 }
Exemplo n.º 8
0
    public void ReceiveImpact(Vector2 force)
    {
        if (force.y == 0.0f)
        {
            force.y = impactVerticalForce;
        }

        onStun             = true;
        myStunRecoveryTime = stunRecoveryTime;
        myRigidbody.AddForce(force);
        PlayHitParticleSystem();
        FXAudio.PlayClip("Hit");
    }
Exemplo n.º 9
0
    private void ProcessJump()
    {
        float jumpAxis = Input.GetAxis("Jump");

        if (jumpAxis != 0.0f && isOnGround == true && jumpAxisInUse == false)
        {
            jumpAxisInUse = true;
            FXAudio.PlayClip("Jump");
            myRigidbody.AddForce(Vector3.up * jumpForce);
        }

        jumpAxisInUse = jumpAxis > 0.0f;
    }
Exemplo n.º 10
0
    void Start()
    {
        if (Time.timeScale == 0.0f)
        {
            Time.timeScale = 1.0f;
        }

        FXAudio.Init();
        MusicAudio.Init();

        InitMainMenuButtons();
        InitSettingsPanelAndButtons();
        LoadSettings();
    }
Exemplo n.º 11
0
    public void ReceiveDamage(float damage)
    {
        PlayHitParticleSystem();

        if (!onStun)
        {
            PlayerState.HealthPoints -= damage;
            if (PlayerState.HealthPoints <= 0)
            {
                PlayerState.IsDead = true;
                FXAudio.PlayClip("Explosion");
            }
        }
    }
Exemplo n.º 12
0
    void Start()
    {
        myPlayerState      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerState> ();
        shootOrigin        = gameObject.transform.Find("ShootOrigin").gameObject;
        shootLineRenderer  = shootOrigin.GetComponent <LineRenderer> ();
        myAudioSource      = gameObject.GetComponent <AudioSource> ();
        myAudioSource.clip = FXAudio.GetClip("fire");
        shootTimer         = shootSpeed;

        int playerBitMask  = 1 << LayerMask.NameToLayer("Player");
        int defaultBitMask = 1 << LayerMask.NameToLayer("Default");

        shootBitMask = playerBitMask | defaultBitMask;
    }
Exemplo n.º 13
0
    public void OnCollisionEnter2D(Collision2D col)
    {
        myRigidBody.velocity = Vector2.zero;
        hasCollisioned       = true;

        myAnimator.SetTrigger("Impact");

        FXAudio.PlayClip("Explosion");

        if (col.gameObject.tag == "Enemy")
        {
            ZombieController zc = col.gameObject.GetComponent <ZombieController> ();
            zc.ReceiveDamage(1.0f);
        }
    }
        /// <summary>
        /// Rellena los componentes automaticamente si no hay nigun elemento en el inspector
        /// </summary>
        private void FillComponents()
        {
            _fxAudio = _fxAudio == null
                ? GameObject.FindGameObjectWithTag(TAGS.FXAUDIO).GetComponent <FXAudio>()
                : _fxAudio;

            _scoreManager = _scoreManager == null
                ? GameObject.FindGameObjectWithTag(TAGS.SCORE_MANAGER).GetComponent <ScoreManager>()
                : _scoreManager;

            _QuestionChooseManager = _QuestionChooseManager == null
                ? GetComponentInParent <QuestionChooseManager>()
                : _QuestionChooseManager;

            _imageComponent = GetComponent <Image>();
        }
Exemplo n.º 15
0
    public IEnumerator ReloadGun(float delay)
    {
        reloadingGun = true;

        FXAudio.PlayClip("reload");

        remainingAmmoPacks--;

        int amountToReload = totalAmmoPerPack - currentAmmo;

        yield return(new WaitForSecondsRealtime(delay));

        currentAmmo += amountToReload;

        reloadingGun = false;
    }
        /// <summary>
        /// Rellena un arreglo con elementos que tienen el Script AnswerChooseManager
        /// Busca e inicializa sino ha sido añadida el Navegation Manager
        /// </summary>
        private void FillAnswerArray()
        {
            _Answers           = GetComponentsInChildren <AnwserChooseManager>();
            _navegationManager = _navegationManager == null
                ? GameObject.FindGameObjectWithTag(TAGS.NAVEGATION_MANAGER)
                                 .GetComponent <NavegationManager>()
                : _navegationManager;

            _scoreManager = _scoreManager == null
                ? GameObject.FindGameObjectWithTag(TAGS.SCORE_MANAGER).GetComponent <ScoreManager>()
                            .GetComponent <ScoreManager>()
                : _scoreManager;

            _fxAudio = _fxAudio == null
                ? GameObject.FindGameObjectWithTag(TAGS.FXAUDIO).GetComponent <FXAudio>()
                : _fxAudio;
        }
Exemplo n.º 17
0
    private void HandleMove()
    {
        float jumpAxis;
        float horizontalAxis;

        horizontalAxis = Input.GetAxis("Horizontal");
        jumpAxis       = Input.GetAxis("Jump");

        if (jumpAxisInUse)
        {
            myJumpDelay -= Time.deltaTime;
        }

        if (myJumpDelay <= 0.0f)
        {
            jumpAxisInUse = false;
            myJumpDelay   = jumpDelay;
        }

        float velocityY = 0.0f;
        float velocityX = 0.0f;

        if (jumpAxis > 0 && PlayerState.IsOnGround && jumpAxisInUse == false)
        {
            jumpAxisInUse = true;
            velocityY     = jumpForce;
            FXAudio.PlayClip("Jump");
        }
        else
        {
            velocityY = myRigidbody.velocity.y;
        }

        if (horizontalAxis != 0.0f)
        {
            velocityX = horizontalAxis * horizontalSpeed;
        }
        else
        {
            velocityX = myRigidbody.velocity.x;
        }

        myRigidbody.velocity = new Vector2(velocityX, velocityY);

        PlayerState.HorizontalDirection = horizontalAxis;
    }
Exemplo n.º 18
0
    private void Shoot(float deltaTime)
    {
        if (myShootTimer <= 0.0 || myShootTimer == shootRate)
        {
            GameplayState.TotalShoots++;

            RaycastHit hitInfo;
            bool       hasHit = Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo, shootMaxDistance, shootBitMask);

            Vector3 targetPosition;

            if (hasHit)
            {
                targetPosition = hitInfo.point;

                if (hitInfo.collider.gameObject.tag == "Enemy")
                {
                    GameplayState.SuccessShoots++;

                    HealthState enemyHealthState = hitInfo.collider.gameObject.GetComponent <HealthState> ();

                    enemyHealthState.ReceiveDamage(shootDamage);
                }

                ParticleSystem currentPS = ParticleSystemManager.GetParticleInstance("PSShootImpact", GameplayState.TotalShoots);
                currentPS.transform.position = hitInfo.point;
                currentPS.Stop();
                currentPS.Play();
            }
            else
            {
                targetPosition = Camera.main.transform.forward * shootMaxDistance;
            }

            FXAudio.PlayClip("fire");
            StartCoroutine(DrawShootLine(targetPosition, shootRate * 0.5f));

            currentAmmo--;
            myShootTimer = shootRate;
        }

        myShootTimer -= deltaTime;
    }
Exemplo n.º 19
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (PlayerState.HealthPoints > 0.0f)
        {
            if (col.gameObject.tag == "Enemy" && col.contacts [0].normal.y > 0)
            {
                col.gameObject.GetComponent <ZombieController> ().ReceiveDamage(smashEnemyHeadDamage);
                myRigidbody.AddForce(Vector2.up * smashEnemyHeadBounceForce);
                myAnimator.SetTrigger("triggerBounce");

                FXAudio.PlayClip("PickupCoin");
            }
            else if (col.gameObject.tag == "ground" || col.gameObject.layer == groundLayer)
            {
                if (Mathf.Abs(col.relativeVelocity.y) >= resistenceOnFalling)
                {
                    ReceiveDamage(PlayerState.HealthPoints);
                }
            }
        }
    }
Exemplo n.º 20
0
    void OnTriggerStay2D(Collider2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            if (Input.GetAxisRaw("Fire2") != 0.0f && axisInUse == false)
            {
                axisInUse = true;
                SetState(!currentState);

                if (currentState)
                {
                    FXAudio.PlayClip("SwitchGreen");
                    PlayerState.ActivatedDoorSwitches++;
                }
                else
                {
                    FXAudio.PlayClip("SwitchRed");
                    PlayerState.ActivatedDoorSwitches--;
                }
            }
        }
    }
Exemplo n.º 21
0
 public override void Awake()
 {
     base.Awake();
     FXAudio.Init();
     ParticleSystemManager.Init();
 }
Exemplo n.º 22
0
 public override void OnDead()
 {
     FXAudio.PlayClip("Scream_Male_01");
 }