コード例 #1
0
        /*public void DrawCharacter(Character characterData)
        {
            textCharacterName.text = characterData.CharacterName;
            if (characterData.CharacterFace == null)
                characterFace.enabled = false;
            else
                characterFace.enabled = true;
            characterFace.sprite = characterData.CharacterFace;
            characterFaceOutline.sprite = characterData.CharacterFace;

            int healthBarNumber = ((int)characterData.CharacterStat.HpMax / 1000);
            healthBarNumber = Mathf.Max(0, healthBarNumber);
            for (int i = 0; i < healthBarNumber; i++)
            {
                if (healthBarList.Count <= i)
                    healthBarList.Add(Instantiate(transformBar, transformBarNumber));
                healthBarList[i].gameObject.SetActive(true);
            }
            for (int i = healthBarNumber; i < healthBarList.Count; i++)
            {
                healthBarList[i].gameObject.SetActive(false);
            }
            if (healthBarList.Count == 0)
                transformBarNumber.gameObject.SetActive(false);
            DrawHealth((int)characterData.CharacterStat.Hp, (int)characterData.CharacterStat.HpMax);
        }*/

        public void DrawCharacter(PlayerData characterData, CharacterStatController characterStat)
        {
            textCharacterName.text = characterData.CharacterName;
            if (characterData.CharacterFace == null)
                characterFace.enabled = false;
            else
                characterFace.enabled = true;
            characterFace.sprite = characterData.CharacterFace;
            characterFaceOutline.sprite = characterData.CharacterFace;

            int healthBarNumber = (characterStat.GetHPMax() / healthBarAmount);
            healthBarNumber = Mathf.Max(0, healthBarNumber);
            for(int i = 0; i < healthBarNumber; i++)
            {
                if(healthBarList.Count <= i)
                    healthBarList.Add(Instantiate(transformBar, transformBarNumber));
                healthBarList[i].gameObject.SetActive(true);
            }
            for(int i = healthBarNumber; i < healthBarList.Count; i++)
            {
                healthBarList[i].gameObject.SetActive(false);
            }
            if (healthBarList.Count == 0)
                transformBarNumber.gameObject.SetActive(false);
            DrawHealth(characterStat.GetHP(), characterStat.GetHPMax());
        }
コード例 #2
0
 public void DrawCharacter(CharacterStatController stat, CharacterEquipementController characterEquipement)
 {
     textPlayerName.text = stat.CharacterData.CharacterName;
     hpGauge.DrawGauge(stat.Hp, stat.GetHPMax());
     DrawWeapon(characterEquipement.GetWeapon());
     //hpGauge.DrawHealthGauge(stat.Hp, stat.HpMax, stat.Scratch);
 }
コード例 #3
0
        public void Damage(Vector3 pos, AttackData attackData)
        {
            if (isDead == true)
                return;
            DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController);
            msg.SetDamagePosition(pos);

            if (OnHit != null) OnHit.Invoke(msg);

            shakeSprite.Shake(0.05f, 0.2f);
            if (characterStatController.Hp <= 0)
            {
                //Death(attackData);
                Destroy(this.gameObject);
                return;
            }
            float hpMax = characterStatController.GetHPMax();
            for (int i = 0; i < healthPercentage.Length; i++)
            {
                if ((characterStatController.Hp / hpMax) >= healthPercentage[i])
                {
                    objectAtHealth[i].gameObject.SetActive(true);
                    return;
                }
                else
                {
                    objectAtHealth[i].gameObject.SetActive(false);
                }
            }
        }
コード例 #4
0
        public override DamageMessage ProcessAttack(AttackDataStat attack, CharacterStatController target)
        {
            DamageMessage res;
            float finalDamage = target.GetHPMax() / 4f;
            res = new DamageMessage(attack.AttackType, 0, (int)finalDamage);
            target.Scratch += finalDamage;

            if (ProcessKnockback(attack, target) == true)
                res.knockback = true;
            if (ProcessLaunch(attack, target) == true)
                res.launch = true;
            return res;
        }
コード例 #5
0
        public void Knockback(AttackController attack)
        {
            if(noKnockback == true && state != CharacterState.Dead)
            {
                if (healthBar != null)
                    healthBar.DrawHealth(characterStat.GetHP(), characterStat.GetHPMax());
                OnHit.Invoke(attack.AttackBehavior);
                return;
            }
            if (state != CharacterState.Dead)
            {
                CancelAct();
                state = CharacterState.Hit;
            }
            if (attack.AttackBehavior.ThrowState == true)
            {
                state = CharacterState.Throw;
                return;
            }
            if(characterToThrow != null)
            {
                characterToThrow.CancelAction();
                characterToThrow.JumpDefault();
                characterToThrow = null;
            }
            if(inAir == true)
            {
                if (attack.Direction == 0)
                    speedX = attack.AttackBehavior.KnockbackAerialPowerX * characterStat.GetMass() * -direction;
                else
                    speedX = attack.AttackBehavior.KnockbackAerialPowerX * characterStat.GetMass() * attack.Direction;
                speedY = 0;
                if (attack.AttackBehavior.ResetGravity == true)
                {
                    speedZ = attack.AttackBehavior.KnockbackAerialPowerZ * characterStat.GetMass();
                    SetGroundBounce(0, 0);
                }
                else
                {
                    speedZ += attack.AttackBehavior.KnockbackAerialPowerZ * characterStat.GetMass();
                }
            }
            else
            {
                if (attack.Direction == 0)
                    speedX = attack.AttackBehavior.KnockbackPowerX * characterStat.GetMass() * -direction;
                else
                    speedX = attack.AttackBehavior.KnockbackPowerX * characterStat.GetMass() * attack.Direction;
                speedY = 0;
                speedZ = attack.AttackBehavior.KnockbackPowerZ * characterStat.GetMass();
                if (attack.AttackBehavior.KnockbackPowerZ > 0)
                {
                    inAir = true;
                }
            }
            if (attack.AttackBehavior.GroundBounce == true)
            {
                SetGroundBounce(attack.AttackBehavior.GroundBounceX * Mathf.Sign(speedX), attack.AttackBehavior.GroundBounceZ);
            }

            knockdownValue += attack.AttackBehavior.KnockdownValue;
            if (knockdownValue >= characterStat.GetKnockdownResistance() && state != CharacterState.Dead)
            {
                CharacterDown();
            }
            else
            {
                KnockbackAnimation();
            }
            PlayVoice(characterStat.CharacterData.HitVoice);
            if (healthBar != null)
                healthBar.DrawHealth(characterStat.GetHP(), characterStat.GetHPMax());
            OnHit.Invoke(attack.AttackBehavior);
        }