Beispiel #1
0
        public override IEnumerator OnLoad(Request request)
        {
            HideSkillDetail();
            int characterId = request.Get <int>("character_id");

            if (Global.SUser.self.equipments == null)
            {
                yield return(StartCoroutine(sEquipment.RequestList()));

                Global.SUser.self.equipments = sEquipment.equipments;
            }
            character = System.Array.Find(Global.SUser.self.characters, _ => _.CharacterId == characterId);
            character.StatusInit();
            characterDetail.BindingContext = character.ViewModel;
            characterDetail.UpdateView();
            vCard.BindingContext = character.ViewModel;
            vCard.UpdateView();
            characterGrade.BindingContext = character.ViewModel;
            characterGrade.UpdateView();
            vCharacter.BindingContext = character.ViewModel;
            vCharacter.UpdateView();
            vCharacterStatus.BindingContext = character.ViewModel;
            vCharacterStatus.UpdateView();
            vEquipment.BindingContext = character.ViewModel;
            vEquipment.UpdateView();
            vCharacterSkill.BindingContext = character.ViewModel;
            vCharacterSkill.UpdateView();
            contents = new VBase[] { vCharacterStatus, vEquipment, vCharacterSkill };
            ShowContentFromIndex(0);
            yield return(StartCoroutine(base.OnLoad(request)));
        }
Beispiel #2
0
        public static MCharacterAbility Create(MCharacter mCharacter)
        {
            MCharacterAbility ability = new MCharacterAbility();

            ability.Update(mCharacter);
            return(ability);
        }
Beispiel #3
0
        public static MCharacter Create(App.Model.Master.MNpc npc)
        {
            MCharacter mCharacter = new MCharacter();

            mCharacter.Id          = npc.id;
            mCharacter.CharacterId = npc.character_id;
            mCharacter.Horse       = npc.horse;
            mCharacter.Clothes     = npc.clothes;
            mCharacter.Weapon      = npc.weapon;
            mCharacter.Star        = npc.star;
            //mCharacter.MoveType = (MoveType)System.Enum.Parse(typeof(MoveType), npc.move_type, true);
            //mCharacter.WeaponType = (WeaponType)System.Enum.Parse(typeof(WeaponType), npc.weapon_type, true);
            return(mCharacter);
        }
Beispiel #4
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)));
        }
Beispiel #5
0
 private void ToSelectCharacter(int characterId, bool isSelected)
 {
     if (isSelected)
     {
         App.Model.MCharacter character = System.Array.Find(App.Util.Global.SUser.self.characters, _ => _.CharacterId == characterId);
         GameObject           shadowObj = Instantiate(selectShadow);
         shadowObj.SetActive(true);
         shadowObj.transform.SetParent(selectCharacterContent);
         shadowObj.transform.localScale = Vector3.one;
         GameObject obj = Instantiate(characterIcon);
         obj.transform.SetParent(shadowObj.transform);
         //obj.transform.localScale = Vector3.one * 0.65f;
         obj.transform.localScale = Vector3.one;
         VCharacterIcon vCharacterIcon = obj.GetComponent <VCharacterIcon>();
         vCharacterIcon.BindingContext = character.ViewModel;
         vCharacterIcon.UpdateView();
     }
     else
     {
         VCharacterIcon[] icons = selectCharacterContent.GetComponentsInChildren <VCharacterIcon>();
         VCharacterIcon   icon  = System.Array.Find(icons, _ => _.ViewModel.CharacterId.Value == characterId);
         GameObject.Destroy(icon.transform.parent.gameObject);
     }
 }
Beispiel #6
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;
        }