Ejemplo n.º 1
0
        protected override void InitMap()
        {
            MUser mUser = App.Util.Global.SUser.self;

            //地图需要判断是否变化,所以另准备一个Model
            mBaseMap       = new MTopMap();
            mBaseMap.MapId = mUser.MapId;
            mBaseMap.Tiles = mUser.TopMap.Clone() as App.Model.MTile[];
            base.InitMap();
            System.Array.Sort(mUser.characters, (a, b) => {
                App.Model.Master.MCharacter aMaster = a.Master;
                App.Model.Master.MCharacter bMaster = b.Master;
                if (bMaster.qualification != aMaster.qualification)
                {
                    return(bMaster.qualification - aMaster.qualification);
                }
                if (b.Star != a.Star)
                {
                    return(b.Star - a.Star);
                }
                return(b.Level - a.Level);
            });

            App.Model.Master.MBaseMap topMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId);
            int x = Mathf.FloorToInt(topMapMaster.width * 0.5f);
            int y = Mathf.FloorToInt(topMapMaster.height * 0.5f);

            int[][] vecs = new int[][] {
                new int[] { 0, 0 },
                new int[] { -1, 3 },
                new int[] { 1, 2 },
                new int[] { -1, -2 },
                new int[] { 1, -3 }
            };
            //MCharacter[] characters = new MCharacter[5];
            //System.Array.Copy(mUser.characters, characters, 5);
            //int i = 0;
            List <MCharacter> characters = new List <MCharacter>();

            foreach (MCharacter character in mUser.characters)
            {
                int[] vec = vecs[characters.Count];
                character.CoordinateX = x + vec[0];
                character.CoordinateY = y + vec[1];
                character.StatusInit();
                characters.Add(character);
                if (characters.Count >= vecs.Length)
                {
                    break;
                }
            }
            mBaseMap.Characters     = characters.ToArray();
            vBaseMap.BindingContext = mBaseMap.ViewModel;
            vBaseMap.UpdateView();
            vBaseMap.transform.parent.localScale = Vector3.one;
            vBaseMap.MoveToPosition();
            charactersContent.UpdateView(mUser.characters);
        }
Ejemplo n.º 2
0
        public override IEnumerator OnLoad(Request request)
        {
            int    faceId = 0;
            string name   = string.Empty;

            if (request.Has("userId"))
            {
                int             userId = request.Get <int>("userId");
                App.Model.MUser user   = App.Util.Cacher.UserCacher.Instance.Get(userId);
                faceId = user.Face;
                name   = user.name;
            }
            else if (request.Has("npcId"))
            {
                int                  npcId      = request.Get <int>("npcId");
                CBaseMap             cBaseMap   = App.Util.SceneManager.CurrentScene as CBaseMap;
                App.Model.MCharacter mCharacter = cBaseMap.GetCharacterFromNpc(npcId);
                faceId = mCharacter.CharacterId;
                name   = mCharacter.Master.name;
            }
            else if (request.Has("characterId"))
            {
                faceId = request.Get <int>("characterId");
                App.Model.Master.MCharacter mCharacter = CharacterCacher.Instance.Get(faceId);
                name = mCharacter.name;
            }
            message = request.Get <string>("message");
            if (name != string.Empty && faceId > 0)
            {
                face.CharacterId = faceId;
                bool isLeft = request.Get <bool>("isLeft");
                if (isLeft)
                {
                    characterNameLeft.text  = name;
                    characterNameRight.text = string.Empty;
                }
                else
                {
                    characterNameRight.text = name;
                    characterNameLeft.text  = string.Empty;
                }
            }
            characterTalk.text = string.Empty;
            StartCoroutine(UpdateMessage());
            yield return(StartCoroutine(base.OnLoad(request)));
        }
Ejemplo n.º 3
0
        public void Update(MCharacter mCharacter)
        {
            App.Model.Master.MCharacter master = mCharacter.Master;
            if (master == null)
            {
                return;
            }
            App.Model.MSkill[] skills = mCharacter.Skills;
            this.Power            = master.power;
            this.Knowledge        = master.knowledge;
            this.Speed            = master.speed;
            this.Trick            = master.trick;
            this.Endurance        = master.endurance;
            this.MovingPower      = master.moving_power;
            this.Riding           = master.riding;
            this.Walker           = master.walker;
            this.Pike             = master.pike;
            this.Sword            = master.sword;
            this.LongKnife        = master.long_knife;
            this.Knife            = master.knife;
            this.LongAx           = master.long_ax;
            this.Ax               = master.ax;
            this.LongSticks       = master.long_sticks;
            this.Sticks           = master.sticks;
            this.Archery          = master.archery;
            this.HiddenWeapons    = master.hidden_weapons;
            this.DualWield        = master.dual_wield;
            this.ResistanceMetal += master.resistance_metal;
            this.ResistanceWood  += master.resistance_wood;
            this.ResistanceWater += master.resistance_water;
            this.ResistanceFire  += master.resistance_fire;
            this.ResistanceEarth += master.resistance_earth;
            int hp = master.hp;
            int mp = master.mp;

            if (skills != null)
            {
                foreach (App.Model.MSkill skill in skills)
                {
                    App.Model.Master.MSkill skillMaster = skill.Master;
                    if (skillMaster == null)
                    {
                        Debug.LogError("master.name=" + master.name + ", " + skill.SkillId + "," + skill.Level);
                        return;
                    }
                    if (!System.Array.Exists(skillMaster.types, s => s == SkillType.ability))
                    {
                        continue;
                    }
                    hp                   += skillMaster.hp;
                    mp                   += skillMaster.mp;
                    this.Power           += skillMaster.power;
                    this.Knowledge       += skillMaster.knowledge;
                    this.Speed           += skillMaster.speed;
                    this.Trick           += skillMaster.trick;
                    this.Endurance       += skillMaster.endurance;
                    this.MovingPower     += skillMaster.moving_power;
                    this.Riding          += skillMaster.riding;
                    this.Walker          += skillMaster.walker;
                    this.Pike            += skillMaster.pike;
                    this.Sword           += skillMaster.sword;
                    this.LongKnife       += skillMaster.long_knife;
                    this.Knife           += skillMaster.knife;
                    this.LongAx          += skillMaster.long_ax;
                    this.Ax              += skillMaster.ax;
                    this.LongSticks      += skillMaster.long_sticks;
                    this.Sticks          += skillMaster.sticks;
                    this.Archery         += skillMaster.archery;
                    this.HiddenWeapons   += skillMaster.hidden_weapons;
                    this.DualWield       += skillMaster.dual_wield;
                    this.Magic           += skillMaster.magic;
                    this.ResistanceMetal += skillMaster.resistance_metal;
                    this.ResistanceWood  += skillMaster.resistance_wood;
                    this.ResistanceWater += skillMaster.resistance_water;
                    this.ResistanceFire  += skillMaster.resistance_fire;
                    this.ResistanceEarth += skillMaster.resistance_earth;
                }
            }
            List <App.Model.Master.MEquipment> equipments = new List <App.Model.Master.MEquipment>();

            if (mCharacter.Weapon > 0)
            {
                equipments.Add(EquipmentCacher.Instance.GetEquipment(mCharacter.Weapon, App.Model.Master.MEquipment.EquipmentType.weapon));
            }
            if (mCharacter.Clothes > 0)
            {
                equipments.Add(EquipmentCacher.Instance.GetEquipment(mCharacter.Clothes, App.Model.Master.MEquipment.EquipmentType.clothes));
            }
            if (mCharacter.Horse > 0)
            {
                equipments.Add(EquipmentCacher.Instance.GetEquipment(mCharacter.Horse, App.Model.Master.MEquipment.EquipmentType.horse));
            }
            int physicalAttack  = 0;
            int physicalDefense = 0;
            int magicAttack     = 0;
            int magicDefense    = 0;

            foreach (App.Model.Master.MEquipment equipment in equipments)
            {
                hp                   += equipment.hp;
                mp                   += equipment.mp;
                this.Power           += equipment.power;
                this.Knowledge       += equipment.knowledge;
                this.Speed           += equipment.speed;
                this.Trick           += equipment.trick;
                this.Endurance       += equipment.endurance;
                this.MovingPower     += equipment.moving_power;
                this.Riding          += equipment.riding;
                this.Walker          += equipment.walker;
                this.Pike            += equipment.pike;
                this.Sword           += equipment.sword;
                this.LongKnife       += equipment.long_knife;
                this.Knife           += equipment.knife;
                this.LongAx          += equipment.long_ax;
                this.Ax              += equipment.ax;
                this.LongSticks      += equipment.long_sticks;
                this.Sticks          += equipment.sticks;
                this.Archery         += equipment.archery;
                this.HiddenWeapons   += equipment.hidden_weapons;
                this.DualWield       += equipment.dual_wield;
                this.Magic           += equipment.magic;
                this.ResistanceMetal += equipment.resistance_metal;
                this.ResistanceWood  += equipment.resistance_wood;
                this.ResistanceWater += equipment.resistance_water;
                this.ResistanceFire  += equipment.resistance_fire;
                this.ResistanceEarth += equipment.resistance_earth;
                physicalAttack       += equipment.physical_attack;
                physicalDefense      += equipment.physical_defense;
                magicAttack          += equipment.magic_attack;
                magicDefense         += equipment.magic_defense;
            }

            this.HpMax = Mathf.FloorToInt(mCharacter.Level * (10 + this.Endurance * 0.2f) + hp);
            this.MpMax = Mathf.FloorToInt(mCharacter.Level * (5 + this.Knowledge * 0.1f) + mp);
            float moveTypeValue = (mCharacter.MoveType == MoveType.cavalry ? this.Riding : this.Walker);

            switch (mCharacter.WeaponType)
            {
            case WeaponType.archery:
                moveTypeValue += this.Archery;
                break;

            case WeaponType.pike:
                moveTypeValue += this.Pike;
                break;

            case WeaponType.sword:
                moveTypeValue += this.Sword;
                break;

            case WeaponType.longAx:
                moveTypeValue += this.LongAx;
                break;

            case WeaponType.ax:
                moveTypeValue += this.Ax;
                break;

            case WeaponType.longKnife:
                moveTypeValue += this.LongKnife;
                break;

            case WeaponType.shortKnife:
                moveTypeValue += this.Knife;
                break;

            case WeaponType.longSticks:
                moveTypeValue += this.LongSticks;
                break;

            case WeaponType.sticks:
                moveTypeValue += this.Sticks;
                break;

            case WeaponType.dualWield:
                moveTypeValue += this.DualWield;
                break;

            case WeaponType.magic:
                moveTypeValue += this.Magic;
                break;
            }
            float starPower = 0.7f + mCharacter.Star * 0.06f;

            this.PhysicalAttack   = Mathf.FloorToInt((this.Power + this.Knowledge) * 0.3f + (this.Power * 2f + this.Knowledge) * (0.4f + (moveTypeValue * 0.5f) * 0.006f) * (1f + mCharacter.Level * starPower * 0.5f) * 0.1f);
            this.PhysicalAttack  += physicalAttack;
            this.MagicAttack      = Mathf.FloorToInt((this.Trick + this.Knowledge) * 0.3f + (this.Trick * 2f + this.Knowledge) * (0.4f + (moveTypeValue * 0.5f) * 0.006f) * (1f + mCharacter.Level * starPower * 0.5f) * 0.1f);
            this.MagicAttack     += magicAttack;
            this.PhysicalDefense  = Mathf.FloorToInt((this.Power * 0.5f + this.Knowledge) * 0.3f + (this.Power + this.Knowledge) * (1f + mCharacter.Level * starPower * 0.5f) * 0.04f);
            this.PhysicalDefense += physicalDefense;
            this.MagicDefense     = Mathf.FloorToInt((this.Trick * 0.5f + this.Knowledge) * 0.3f + (this.Trick + this.Knowledge) * (1f + mCharacter.Level * starPower * 0.5f) * 0.04f);
            this.MagicDefense    += magicDefense;
        }