Exemple #1
0
        public void Respawn(bool resetHealth, bool useCheckpoint)
        {
            if (resetHealth)
            {
                damageable.SetHealth(damageable.startingHealth);
                HealthUI.ChangeHitPointUI(damageable);
            }

            //we reset the hurt trigger, as we don't want the player to go back to hurt animation once respawned
            m_Animator.ResetTrigger(m_HashHurtPara);
            if (m_FlickerCoroutine != null)
            {//we stop flcikering for the same reason
                StopFlickering();
            }

            m_Animator.SetTrigger(m_HashRespawnPara);

            if (useCheckpoint && m_LastCheckpoint != null)
            {
                UpdateFacing(m_LastCheckpoint.respawnFacingLeft);
                GameObjectTeleporter.Teleport(gameObject, m_LastCheckpoint.transform.position);
            }
            else
            {
                UpdateFacing(m_StartingFacingLeft);
                GameObjectTeleporter.Teleport(gameObject, m_StartingPosition);
            }
        }
Exemple #2
0
        public void OnHurt(Damager damager, Damageable damageable)
        {
            //if the player don't have control, we shouldn't be able to be hurt as this wouldn't be fair
            if (!PlayerInput.Instance.HaveControl)
            {
                return;
            }

            UpdateFacing(damageable.GetDamageDirection().x > 0f);
            damageable.EnableInvulnerability();

            m_Animator.SetTrigger(m_HashHurtPara);

            //we only force respawn if helath > 0, otherwise both forceRespawn & Death trigger are set in the animator, messing with each other.
            if (damageable.CurrentHealth > 0 && damager.forceRespawn)
            {
                m_Animator.SetTrigger(m_HashForcedRespawnPara);
            }

            m_Animator.SetBool(m_HashGroundedPara, false);
            hurtAudioPlayer.PlayRandomSound();

            //if the health is < 0, mean die callback will take care of respawn
            if (damager.forceRespawn && damageable.CurrentHealth > 0)
            {
                StartCoroutine(DieRespawnCoroutine(false, true));
            }
            HealthUI.ChangeHitPointUI(damageable);
        }
Exemple #3
0
        void Start()
        {
            hurtJumpAngle      = Mathf.Clamp(hurtJumpAngle, k_MinHurtJumpAngle, k_MaxHurtJumpAngle);
            m_TanHurtJumpAngle = Mathf.Tan(Mathf.Deg2Rad * hurtJumpAngle);
            m_FlickeringWait   = new WaitForSeconds(flickeringDuration);

            meleeDamager.DisableDamage();

            //Ada Script
            ExperienceBar       = GameObject.Find("ExperienceBar");
            ExperienceBarSlider = GameObject.Find("ExperienceBarSlider");
            XpBarFill           = GameObject.Find("XpBarFill");
            staminaBarFill      = GameObject.Find("staminaBarFill");
            staminaBarSlider    = GameObject.Find("staminaBarSlider");
            manaBarFill         = GameObject.Find("manaBarFill");
            manaBarSlider       = GameObject.Find("manaBarSlider");
            levelUpText         = GameObject.Find("levelUpText");
            levelUpText.SetActive(false);
            theSound = gameObject.AddComponent <AudioSource>();

            HealthUI.ChangeHitPointUI(damageable);

            currentExperience = 0;
            characterLevel    = 1;
            ExperienceBar.GetComponent <Text>().text  = "" + characterLevel;
            XpBarFill.GetComponent <Text>().text      = currentExperience + " / " + levelUpAmount;
            staminaBarFill.GetComponent <Text>().text = stamina + " / 100";
            manaBarFill.GetComponent <Text>().text    = mana + " / 100";

            InvokeRepeating("RegenerationTick", 0.0f, 1.0f);
            //EndOf Ada Script


            m_ShotSpawnGap  = 1f / shotsPerSecond;
            m_NextShotTime  = Time.time;
            m_ShotSpawnWait = new WaitForSeconds(m_ShotSpawnGap);

            if (!Mathf.Approximately(maxHorizontalDeltaDampTime, 0f))
            {
                float maxHorizontalDelta = maxSpeed * cameraHorizontalSpeedOffset + cameraHorizontalFacingOffset;
                m_CamFollowHorizontalSpeed = maxHorizontalDelta / maxHorizontalDeltaDampTime;
            }

            if (!Mathf.Approximately(maxVerticalDeltaDampTime, 0f))
            {
                float maxVerticalDelta = cameraVerticalInputOffset;
                m_CamFollowVerticalSpeed = maxVerticalDelta / maxVerticalDeltaDampTime;
            }

            SceneLinkedSMB <PlayerCharacter> .Initialise(m_Animator, this);

            m_StartingPosition   = transform.position;
            m_StartingFacingLeft = GetFacing() < 0.0f;
        }
Exemple #4
0
        public void LevelUp()
        {
            ShowLevelUp();

            while ((currentExperience / levelUpAmount) > 0)
            {
                characterLevel++;
                currentExperience = currentExperience - levelUpAmount;
                levelUpAmount     = (int)(levelUpAmount * 1.5);
            }


            ExperienceBarSlider.GetComponent <Slider>().maxValue = levelUpAmount;

            damageable.SetHealth(damageable.startingHealth);
            HealthUI.ChangeHitPointUI(damageable);
            manaBarFill.GetComponent <Text>().text      = "100 / 100";
            manaBarSlider.GetComponent <Slider>().value = 100;
            mana = 100;
            staminaBarFill.GetComponent <Text>().text      = "100 / 100";
            staminaBarSlider.GetComponent <Slider>().value = 100;
            stamina = 100;
        }