void FixedUpdate()
    {
        for (int i = 0; i < pawnTrapped.Count; i++)
        {
            PawnController item = pawnTrapped[i];
            if (item.GetHealth() < 1)
            {
                pawnTrapped.Remove(item);
            }
        }
        waitTimeBeforeNextDamage -= Time.deltaTime;

        if (waitTimeBeforeNextDamage < 0 && !isActivated && !shutDown)
        {
            waitTimeBeforeNextDamage = puzzleData.timeCheckingDamageEletricPlate;
            foreach (PawnController item in pawnTrapped)
            {
                if (item.GetComponent <EnemyBehaviour>())
                {
                    item.Damage(puzzleData.DamageEletricPlateEnnemies);
                }
                else
                {
                    item.Damage(puzzleData.DamageEletricPlate);
                }
                Analytics.CustomEvent("ElectricalPlateDamage", new Dictionary <string, object> {
                    { "Zone", GameManager.GetCurrentZoneName() },
                });
                item.AddSpeedModifier(new SpeedCoef(speedModifier, puzzleData.timeCheckingDamageEletricPlate, SpeedMultiplierReason.Freeze, false));

                FeedbackManager.SendFeedback("event.PuzzleElectricPlateDamage", item);
            }
        }
    }
Esempio n. 2
0
    private void UpdateHealth()
    {
        currentHealth = (float)pawnController.GetHealth() / (float)pawnController.GetMaxHealth();
        float i_healthLerpSpeed = healthLossLerpSpeed;

        if (currentHealth > displayedHealth)
        {
            i_healthLerpSpeed = healthGainLerpSpeed;
        }
        displayedHealth = Mathf.Lerp(displayedHealth, currentHealth, Time.deltaTime * i_healthLerpSpeed);
        displayedHealth = Mathf.Clamp(displayedHealth, 0f, Mathf.Infinity);
        healthText.text = "" + Mathf.RoundToInt((displayedHealth * 100f)).ToString() + "%";

        float i_evaluateTime = 1f - Mathf.Clamp(displayedHealth - (displayedHealth % healthGradientInterpolationRate), 0f, 1f);

        if (currentHealth > 1)
        {
            healthText.color = overHealColor;
        }
        else
        {
            healthText.color = healthColorGradient.Evaluate(i_evaluateTime);
        }

        float i_HealthNormalized = (float)pawnController.GetHealth() / (float)pawnController.GetMaxHealth();

        if (i_HealthNormalized < healthAlwaysDisplayedTreshold && i_HealthNormalized > 0)
        {
            if (!panelShowedPermanently.Contains(healthPanel))
            {
                panelShowedPermanently.Add(healthPanel);
            }
        }
        else
        {
            panelShowedPermanently.Remove(healthPanel);
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (target != null)
        {
            if (!customHealthBar)
            {
                fillRect.sizeDelta = new Vector2(((float)target.GetHealth() / target.GetMaxHealth()) * _initialWidth, _rect.height);
            }
            else
            {
                fillRect.sizeDelta = new Vector2((customValueToCheck) * _initialWidth, _rect.height);
            }

            Color newColor = healthBarGradient.Evaluate(fillRect.sizeDelta.magnitude / _initialWidth);
            newColor.a    = barFill.color.a;
            barFill.color = newColor;

            _self.position = _mainCamera.WorldToScreenPoint(target.GetHeadPosition() + new Vector3(0f, heightOffset + customDeltaPosition, 0f));
            if (target.GetHealth() <= 0)
            {
                ToggleHealthBar(false);
            }
        }
    }
Esempio n. 4
0
    public void ChangeState()
    {
        if (isPhase1)
        {
            if (Health1Bar_CurrentValue <= 0)
            {
                bossState = BossState.ChangingPhase;
                animator.SetTrigger("ChangingPhaseTrigger");
                waitingBeforeNextState = Stagger_TimeLasting;
            }
            else
            {
                float temproll           = Random.Range(0, 100);
                bool  WantToInvokeShield = false;
                if (temproll > ShieldInvocation_Rate)
                {
                    if (ShieldIsActivated == false) //Health1Bar_CurrentValue / Health1Bar_Value_Max < ShieldInvaction_MinHeath &&
                    {
                        WantToInvokeShield = true;
                    }
                }

                // If players are too far -> range attack
                if (distanceWithPlayerTwo > missileRange && distanceWithPlayerOne > missileRange)
                {
                    navMeshAgent.enabled = false;
                    if (WantToInvokeShield)
                    {
                        InvokingShieldAttack(); //Shield Invocation is prioritary to firing missile
                    }
                    else
                    {
                        bossState = BossState.RangeAttack;
                        waitingBeforeNextState = RangeAttack_Anticipation + RangeAttack_AttackDuration + RangeAttack_RecoverTime;
                        ChangeAimingCubeState(AimingRedDotState.Following);
                    }
                }
                else
                {
                    //If player are closer but not enough -> walk towards them if alive
                    if (distanceWithPlayerOne < distanceWithPlayerTwo && distanceWithPlayerOne > meleeRange && playerOnePawnController.GetHealth() > 0)
                    {
                        if (WantToInvokeShield)
                        {
                            InvokingShieldAttack(); //Shield Invocation is prioritary to moving
                        }
                        else
                        {
                            bossState = BossState.Moving;
                            waitingBeforeNextState = 1 + Random.Range(-0.5f, 0.5f);
                            navMeshAgent.enabled   = true;
                            navMeshAgent.SetDestination(playerOneTransform.position);
                        }
                    }


                    //If player are closer but not enough -> walk towards them if alive
                    if (distanceWithPlayerOne > distanceWithPlayerTwo && distanceWithPlayerTwo > meleeRange && playerTwoPawnController.GetHealth() > 0)
                    {
                        if (WantToInvokeShield)
                        {
                            InvokingShieldAttack(); //Shield Invocation is prioritary to moving
                        }
                        else
                        {
                            bossState = BossState.Moving;
                            waitingBeforeNextState = 1 + Random.Range(-0.5f, 0.5f);
                            navMeshAgent.enabled   = true;
                            navMeshAgent.SetDestination(playerTwoTransform.position);
                        }
                    }


                    if (true)
                    {
                    }

                    //If a player is very close -> punch attack
                    if ((distanceWithPlayerTwo < meleeRange && playerTwoPawnController.GetHealth() > 0) | (distanceWithPlayerOne < meleeRange && playerOnePawnController.GetHealth() > 0))
                    {
                        bossState = BossState.PunchAttack;
                        waitingBeforeNextState = PunchAttack_Anticipation + PunchAttack_AttackingTime + PunchAttack_RecoverTime;
                        navMeshAgent.enabled   = false;
                        animator.SetTrigger("PunchAttackAnticipationTrigger");

                        foreach (var renderer in renderers)
                        {
                            renderer.material.SetColor("_Color", Color.Lerp(attackingColor, normalColor, PunchAttack_Anticipation));
                        }
                    }
                }
            }
        }
        else
        {
            //PHASE 2


            float temproll        = Random.Range(0, 100);
            bool  GroundAttacking = false;
            if (temproll < GroundAttackInvocation_Rate)
            {
                GroundAttacking = true;
            }
            temproll = Random.Range(0, 100);
            bool LaserAttacking = false;
            if (temproll < laserAttackInvocation_Rate)
            {
                LaserAttacking = true;
            }

            if (GroundAttacking)
            {
                bossState = BossState.GroundAttack;
                waitingBeforeNextState = GroundAttack_AnticipationTime + GroundAttack_AttackTime;
                navMeshAgent.enabled   = false;
                foreach (var item in ListEletricPlates)
                {
                    item.gameObject.SetActive(true);
                }
                GroundAttack_Attacking = false;
                animator.SetTrigger("GroundAttackAnticipationTrigger");
            }
            else if (LaserAttacking)
            {
                bossState = BossState.Laser;
                waitingBeforeNextState = 10f;
                SequenceLaserAttack    = 0;
            }
            else
            {
                //If player are closer but not enough -> walk towards them if alive
                if (distanceWithPlayerOne < distanceWithPlayerTwo && distanceWithPlayerOne > meleeRange && playerOnePawnController.GetHealth() > 0)
                {
                    bossState = BossState.Moving;
                    waitingBeforeNextState = 1 + Random.Range(-0.5f, 0.5f);
                    navMeshAgent.enabled   = true;
                    navMeshAgent.SetDestination(playerOneTransform.position);
                }


                //If player are closer but not enough -> walk towards them if alive
                if (distanceWithPlayerOne > distanceWithPlayerTwo && distanceWithPlayerTwo > meleeRange && playerTwoPawnController.GetHealth() > 0)
                {
                    bossState = BossState.Moving;
                    waitingBeforeNextState = 1 + Random.Range(-0.5f, 0.5f);
                    navMeshAgent.enabled   = true;
                    navMeshAgent.SetDestination(playerTwoTransform.position);
                }



                //If a player is very close -> hammer attack
                if ((distanceWithPlayerTwo < meleeRange && playerTwoPawnController.GetHealth() > 0) | (distanceWithPlayerOne < meleeRange && playerOnePawnController.GetHealth() > 0))
                {
                    if (NumberHammerLeft > 0)
                    {
                        NumberHammerLeft--;
                        bossState = BossState.HammerPunchAttack;
                        waitingBeforeNextState = HammerAttack_Anticipation + HammerAttack_AttackingTime + HammerAttack_RecoverTime;
                        navMeshAgent.enabled   = false;
                        animator.SetTrigger("HammerAttackAnticipationTrigger");
                    }
                    else
                    {
                        bossState = BossState.PunchAttack;
                        waitingBeforeNextState = PunchAttack_Anticipation + PunchAttack_AttackingTime + PunchAttack_RecoverTime;
                        navMeshAgent.enabled   = false;
                        animator.SetTrigger("PunchAttackAnticipationTrigger");

                        foreach (var renderer in renderers)
                        {
                            renderer.material.SetColor("_Color", Color.Lerp(attackingColor, normalColor, PunchAttack_Anticipation));
                        }
                    }
                }
            }
        }
    }