unity开发 游戏角色实体类设计

这篇博客展示了Unity3D游戏开发中的角色实体类设计,包括怪物更新状态、稀有度、死亡类型等枚举定义,以及角色属性如生命值、技能等级等数值结构体。还详细定义了Monster类,包含基础属性、技能、状态等成员,用于构建游戏中的怪物实例。
摘要由CSDN通过智能技术生成

下面展示 游戏角色实体类设计

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MR_LBS.Client.Unity3D
{
    public enum MonsterUpdateCode : int
    {
        Unknown = 0,
        Create,
        Hit,
        Recover,
        Revive,
        Level,
        Health
    }
    /// <summary>
    /// 稀有度
    /// </summary>
    public enum RareGrade : int
    {
        Unknown,
        D,
        C,
        B,
        A,
        S
    };
   
    public enum MonsterDeathType : int
    {
        Unknown,
        NormalDie,
        Ice,
        BlackHole,
        SelfDestruction
    }

    /// <summary>
    /// 怪物当前的类型,特指当前稀有度下受技能影响的类型
    /// </summary>
    public enum MonsterCurrentType
    {
        /// <summary>
        /// 近战
        /// </summary>
        Melee_,
    }

    public struct NumericValue
    {
        public int monsterLevel;
        public int baseDamage;
        public int maxHealth;

        public int skill1Level;
        public int skill1Damage;

        public int skill2Level;
        public int skill2Damage;

        public int skill3Level;
        public int skill3Damage;

        public int skill4Level;
        public int skill4Damage;
    }

    //    public struct SkillNumericValue
    //    {
    //        public int level;
    //        public int damage;
    //    }

    public class MonsterItem
    {
        Monster monster;
        int count;
        bool inBox;
        public Monster Monster_P
        {
            get
            {
                return monster;
            }
            set
            {
                monster = value;
            }
        }

        public int Count
        {
            get
            {
                return count;
            }
            set
            {
                count = value;
            }
        }
        //是否由随机盒子中出现
        public bool InBox
        {
            get
            {
                return inBox;
            }

            set
            {
                inBox = value;
            }
        }
    }

    [System.Serializable]
    public class Monster
    {
        public Monster()
        {

        }
        public Monster(Monster monster)
        {
            this.Name = monster.Name;
            this.RareGrade = monster.RareGrade;
            this.Health = monster.Health;
            this.MaxHealth = monster.MaxHealth;
            this.HolyWaterConsume = monster.HolyWaterConsume;
            this.MoveSpeed = monster.MoveSpeed;


            #region Properties
            this.Attack = monster.Attack;
            this.SkillB = monster.SkillB;
            this.SkillC = monster.SkillC;
            this.SkillA = monster.SkillA;
            this.SkillS = monster.SkillS;
            this.SkillList = monster.SkillList;
            #endregion


        }

        int level;
        int maxHealth;
        int damage;
        RareGrade rareGrade;
        int holyWaterConsume;//圣水消耗值
        float moveSpeed; //移动速度,该值不变.
        string petType;//宠物类型(宠物,建筑,雇佣兵)
        float vision;//射程
        int brothers;

        NumericValue numericValue;

        public NumericValue NumericValue
        {
            get
            {
                numericValue.monsterLevel = Level;
                numericValue.maxHealth = MaxHealth;
                numericValue.baseDamage = Damage;

                if (Attack == null)
                {
                    Attack = new Skill();
                }
                //                numericValue.skill1Level = Attack.Level;
                //                numericValue.skill1Damage = Attack.Damage;

                if (SkillC == null)
                {
                    SkillC = new Skill();
                }
                numericValue.skill1Level = SkillC.Level;
                numericValue.skill1Damage = SkillC.Damage;

                if (SkillB == null)
                {
                    SkillB = new Skill();
                }
                numericValue.skill2Level = SkillB.Level;
                numericValue.skill2Damage = SkillB.Damage;
                if (SkillA == null)
                {
                    SkillA = new Skill();
                }
                numericValue.skill3Level = SkillA.Level;
                numericValue.skill3Damage = SkillA.Damage;
                if (SkillS == null)
                {
                    SkillS = new Skill();
                }
                numericValue.skill4Level = SkillS.Level;
                numericValue.skill4Damage = SkillS.Damage;
                return numericValue;
            }
            set
            {
                Level = value.monsterLevel;
                MaxHealth = value.maxHealth;
                Damage = value.baseDamage;
                numericValue = value;

                if (Attack == null)
                {
                    Attack = new Skill();
                }

                Attack.Level = numericValue.monsterLevel;
                Attack.Damage = numericValue.baseDamage;


                if (SkillC == null)
                {
                    SkillC = new Skill();
                }

                SkillC.Level = numericValue.skill1Level;
                SkillC.Damage = numericValue.skill1Damage;

                if (SkillB == null)
                {
                    SkillB = new Skill();
                }
                SkillB.Level = numericValue.skill2Level;
                SkillB.Damage = numericValue.skill2Damage;

                if (SkillA == null)
                {
                    SkillA = new Skill();
                }
                SkillA.Level = numericValue.skill3Level;
                SkillA.Damage = numericValue.skill3Damage;

                if (SkillS == null)
                {
                    SkillS = new Skill();
                }
                SkillS.Level = numericValue.skill4Level;
                SkillS.Damage = numericValue.skill4Damage;

            }
        }

        //类型,对应inventoryCode
        string sort;
        string name;
        long id;
        long uid;
        //普通攻击无等级,或者可以认为跟怪的等级一样,伤害等同于怪的基础伤害
        // Skill attack;

        List<Skill> skillList;
        Skill D;
        Skill C;

        Skill B;
        Skill A;
        Skill S;
        MonsterState state;
        MonsterDeathType deathType;
        int health;
        string des;
        GameObject body;

        public MonsterDeathType DeathType
        {
            get
            {
                return deathType;
            }
            set
            {

                deathType = value;
            }
        }

        public int Damage
        {
            get
            {
                return damage;
            }
            set
            {
                damage = value;
            }
        }

        public GameObject Body
        {
            get
            {
                return body;
            }
            set
            {
                body = value;
            }
        }

        public string Sort
        {
            get
            {
                return sort;
            }
            set
            {
                sort = value;
            }
        }

        public string Des
        {
            get
            {
                return des;
            }
            set
            {
                des = value;
            }
        }

        public long Uid
        {
            get
            {
                return uid;
            }
            set
            {
                uid = value;
            }
        }

        public long Id
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }

        public int Health
        {
            get
            {
                return health;
            }
            set
            {
                health = value;
            }
        }


        public int MaxHealth
        {
            get
            {
                return maxHealth;
            }
            set
            {
                maxHealth = value;
            }
        }

        public MonsterState State
        {
            get
            {
                return state;
            }
            set
            {
                state = value;
            }
        }

        public Skill SkillS
        {
            get
            {
                if (S == null)
                    S = new Skill();
                return S;
            }
            set
            {
                S = value;
            }
        }

        public Skill SkillA
        {
            get
            {
                if (A == null)
                    A = new Skill();
                return A;
            }
            set
            {
                A = value;
            }
        }


        public Skill SkillB
        {
            get
            {
                if (B == null)
                    B = new Skill();
                return B;
            }
            set
            {
                B = value;
            }
        }

        public Skill SkillC
        {
            get
            {
                if (C == null)
                    C = new Skill();
                return C;
            }
            set
            {
                C = value;
            }
        }

        public Skill Attack
        {
            get
            {
                return D;
            }
            set
            {
                D = value;
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }

        public int Level
        {
            get
            {
                return level;
            }
            set
            {
                level = value;
            }
        }
        public RareGrade RareGrade
        {
            get
            {
                return rareGrade;
            }
            set
            {
                rareGrade = value;
            }
        }
        public int HolyWaterConsume
        {
            get
            {
                return holyWaterConsume;
            }
            set
            {
                holyWaterConsume = value;
            }
        }
        public float MoveSpeed
        {
            get
            {
                return moveSpeed;
            }
            set
            {
                moveSpeed = value;
            }
        }

        public float Vision { get => vision; set => vision = value; }
        public List<Skill> SkillList { get => skillList; set => skillList = value; }
        public string PetType { get => petType; set => petType = value; }
        public int Brothers { get => brothers; set => brothers = value; }
    }
}

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小程小程,永不消沉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值