Пример #1
0
    void Awake()
    {
        this.model = new CharacterModel ();

        // view => model
        view.MovementIntentionObservable.Subscribe ((CharacterModel.MovementIntention intention) => {
            this.MovementIntentionHandler(intention);
            this.model.moveIntention.Value = intention;
        });

        view.IsOnTheGroundAsObservalbe ().Subscribe ((bool isOnTheGround) => {
            this.model.isOnTheGround.Value = isOnTheGround;
            this.model.jumpStateMachine.LandedTransition();
        });

        view.JumpIntentionAsObservable ().Subscribe ((CharacterModel.JumpIntention intention) => {
            this.model.jumpIntention.Value = intention;
        });

        // model => view
        model.isNotOnTheGround.Subscribe ((bool isOnTheGround) => {
            this.view.IsNotOnTheGroundChanged(isOnTheGround);
        });

        model.jumpStateMachine.onDoJump.Subscribe ((Unit _) => {
            view.OnDoJump();
        });

        model.jumpStateMachine.jumpState.Subscribe (this.JumpStateChanged);
    }
Пример #2
0
	public void UpdateInfo( CharacterModel model ) {
		Debug.Log( "coins = " + model.coins );
		Debug.Log( "crystals = " + model.crystals );
		Debug.Log( "death = " + model.death );
		Debug.Log( "runDistance = " + model.runDistance );
		coins += model.coins;
		crystals += model.crystals;
		death += model.death;
		runDistance += model.runDistance;
		Save();
	}
Пример #3
0
    /// <summary>
    /// Updates the character position.
    /// </summary>
    /// <param name="intention">Intention.</param>
    public void MovementIntentionHandler(CharacterModel.MovementIntention intention)
    {
        if (intention == CharacterModel.MovementIntention.Right)
        {
            this.view.OnMoveLeft (- this.model.speed.Value);
            return;
        }

        if (intention == CharacterModel.MovementIntention.Left)
        {
            this.view.OnMoveRight (this.model.speed.Value);
            return;
        }

        this.view.OnIdle (this.model.speed.Value);
    }
Пример #4
0
        private void UserLoggedInCommand(IDictionary<string, object> command)
        {
            var character = command.Get(Constants.Arguments.Identity);

            var temp = new CharacterModel
            {
                Name = character,
                Gender = command.Get(Constants.Arguments.Gender).ParseGender(),
                Status = command.Get(Constants.Arguments.Status).ToEnum<StatusType>()
            };

            lock (chatStateLocker)
                CharacterManager.SignOn(temp);

            Events.NewUpdate(new CharacterUpdateModel(temp, new LoginStateChangedEventArgs {IsLogIn = true}));
        }
Пример #5
0
    //////////////////////////////////////////
    /// GetBonusAmount()
    /// Returns the bonus amount, depending
    /// on all its criteria. May return 0.
    //////////////////////////////////////////
    public int GetBonusAmount( CharacterModel i_modelSelf, CharacterModel i_modelTarget ) {
        // start out pessimistic
        int nBonus = 0;

        // decide which character we will be looking at for the bonus based on the bonus' target
        CharacterModel model = Target == CombatTargets.Self ? i_modelSelf : i_modelTarget;

        // do a different kind of check depending on the bonus type
        if ( BonusType == BonusTypes.ForEvery ) {
            // this type of bonus awards its Bonus Amount for every CheckAmount for the given Stat
            int nCheckValue = model.GetTotalModification( Stat );
            if ( nCheckValue > 0 ) {
                int nApplications = nCheckValue / nCheckValue;
                nBonus = BonusAmount * nApplications;
            }
        }
        else
            Debug.LogError( "Unhandled bonus type: " + BonusType.ToString() );

        return nBonus;
    }
Пример #6
0
    public override bool IsValid()
    {
        characterMono = BlackBorad.CharacterMono;
        if (!BlackBorad.GetBool("isPrePareUseSkill") || characterMono.prepareSkill == null)
        {
            return(false);
        }

        characterModel = characterMono.characterModel;


        // 获得当前要释放的技能
        // 判断该技能是否是原地释放技能,
        // 即判断该主动技能的施法距离是否为0,为0时,
        // 为原地释放技能
        if (characterMono.IsImmediatelySpell())
        {
            // 原地释放技能,直接进入Spell状态
            BlackBorad.SetVector3("EnemryPosition", characterMono.transform.position);
            BlackBorad.SetBool("isPrePareUseSkill", false);

            return(true);
        }
        else
        {
            // 指向型技能
            BlackBorad.SetBool("isImmediatelySpell", false);

            Debug.Log("当前准备施放的是指向型技能");

            // 当为指向型技能时,更改主角的鼠标Icon,
            // 判断主角是否点击敌人,当点击敌人时,进入Spell状态
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    if (characterMono.prepareSkill.IsMustDesignation && hit.collider.CompareTag("Enermy"))
                    {
                        // 为黑板设置变量
                        BlackBorad.SetTransform("EnemryTransform", hit.collider.transform);
                        BlackBorad.SetComponent("Enemry", hit.collider.gameObject.GetComponent <CharacterMono>());
                        return(true);
                    }
                    else if (!characterMono.prepareSkill.IsMustDesignation)
                    {
                        // 为黑板设置变量
                        BlackBorad.SetVector3("EnemryPosition", hit.point);
                        return(true);
                    }
                }
            }

            // 如果此时玩家按下ESC键,结束这个准备施法的Transition
            if (Input.GetKeyDown(KeyCode.Escape) || Input.GetMouseButtonDown(1))
            {
                BlackBorad.SetBool("isPrePareUseSkill", false);
                characterMono.isPrepareUseSkill = false;
                return(false);
            }
        }

        return(false);
    }
        /// <summary>
        /// Creates an instance of <see cref="CharacterListItemViewModel"/>
        /// </summary>
        /// <param name="characterModel"></param>
        public CharacterListItemViewModel(CharacterModel characterModel)
        {
            _characterModel = characterModel;

            Initialize();
        }
Пример #8
0
 public Character(CharacterModel _model)
 {
     model = _model;
 }
Пример #9
0
        /// <summary>
        /// Adds a Character/"band member" to the battle
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool AddBandMember(CharacterModel member)
        {
            CharacterList.Add(new CharacterModel(member));

            return(true);
        }
 static public void UnlockCharacter(CharacterModel character)
 {
     Instance.unlockedCharacters.Add(character.identifierName);
     Instance.SetUnlockedCharacters();
     Instance.SaveUnlocks();
 }
Пример #11
0
 public virtual void Awake()
 {
     _characterModel = FindObjectOfType <CharacterModel>();
     _animator       = GetComponent <Animator>();
     take            = false;
 }
Пример #12
0
        /// <inheritdoc />
        public IEnumerable <EncounterModel> GetEncounters(byte[] encounterBytes, IEnumerable <CharacterModel> characters, IEnumerable <ConditionModel> conditions, IEnumerable <MonsterModel> monsters)
        {
            List <EncounterModel> encounters = new List <EncounterModel>();

            using (MemoryStream memoryStream = new MemoryStream(encounterBytes))
            {
                using (BinaryReader reader = new BinaryReader(memoryStream))
                {
                    int version = BitConverter.ToInt16(reader.ReadBytes(4), 0);
                    if (version == _version)
                    {
                        int encounterCount = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                        for (int i = 0; i < encounterCount; ++i)
                        {
                            EncounterModel encounter = new EncounterModel();

                            encounter.Id   = new Guid(reader.ReadBytes(16));
                            encounter.Name = ReadNextString(reader);

                            encounter.Creatures = new List <EncounterCreatureModel>();
                            int creatureCount = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            for (int j = 0; j < creatureCount; ++j)
                            {
                                bool isCharacter = BitConverter.ToBoolean(reader.ReadBytes(1), 0);

                                EncounterCreatureModel encounterCreature = isCharacter ? new EncounterCharacterModel() : new EncounterMonsterModel() as EncounterCreatureModel;
                                encounterCreature.ID                = new Guid(reader.ReadBytes(16));
                                encounterCreature.Name              = ReadNextString(reader);
                                encounterCreature.CurrentHP         = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                encounterCreature.MaxHP             = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                encounterCreature.AC                = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                encounterCreature.SpellSaveDC       = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                encounterCreature.PassivePerception = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                encounterCreature.InitiativeBonus   = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                bool initiativeSet = BitConverter.ToBoolean(reader.ReadBytes(1), 0);
                                int? initiative    = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                encounterCreature.Initiative = initiativeSet ? initiative : null;
                                encounterCreature.Selected   = BitConverter.ToBoolean(reader.ReadBytes(1), 0);

                                encounterCreature.Conditions = new List <AppliedConditionModel>();
                                int conditionCount = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                for (int k = 0; k < conditionCount; ++k)
                                {
                                    AppliedConditionModel appliedCondition = new AppliedConditionModel();
                                    appliedCondition.ID = new Guid(reader.ReadBytes(16));

                                    Guid           conditionID    = new Guid(reader.ReadBytes(16));
                                    string         conditionName  = ReadNextString(reader);
                                    ConditionModel conditionModel = conditions.FirstOrDefault(x => x.Id == conditionID);
                                    if (conditionModel == null)
                                    {
                                        conditionModel = conditions.FirstOrDefault(x => x.Name.Equals(conditionName, StringComparison.CurrentCultureIgnoreCase));
                                    }
                                    appliedCondition.ConditionModel = conditionModel;

                                    appliedCondition.Name = ReadNextString(reader);
                                    bool hasLevel = BitConverter.ToBoolean(reader.ReadBytes(1), 0);
                                    int? level    = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                    appliedCondition.Level = hasLevel ? level : null;
                                    appliedCondition.Notes = ReadNextString(reader);

                                    encounterCreature.Conditions.Add(appliedCondition);
                                }

                                if (isCharacter)
                                {
                                    Guid           characterID   = new Guid(reader.ReadBytes(16));
                                    string         characterName = ReadNextString(reader);
                                    CharacterModel character     = characters.FirstOrDefault(x => x.Id == characterID);
                                    if (character == null)
                                    {
                                        character = characters.FirstOrDefault(x => x.Name.Equals(characterName, StringComparison.CurrentCultureIgnoreCase));
                                    }
                                    ((EncounterCharacterModel)encounterCreature).CharacterModel       = character;
                                    ((EncounterCharacterModel)encounterCreature).Level                = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                    ((EncounterCharacterModel)encounterCreature).PassiveInvestigation = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                }
                                else
                                {
                                    Guid         monsterID   = new Guid(reader.ReadBytes(16));
                                    string       monsterName = ReadNextString(reader);
                                    MonsterModel monster     = monsters.FirstOrDefault(x => x.Id == monsterID);
                                    if (monster == null)
                                    {
                                        monster = monsters.FirstOrDefault(x => x.Name.Equals(monsterName, StringComparison.CurrentCultureIgnoreCase));
                                    }
                                    ((EncounterMonsterModel)encounterCreature).MonsterModel      = monster;
                                    ((EncounterMonsterModel)encounterCreature).Quantity          = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                    ((EncounterMonsterModel)encounterCreature).AverageDamageTurn = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                                    ((EncounterMonsterModel)encounterCreature).CR = ReadNextString(reader);
                                    ((EncounterMonsterModel)encounterCreature).DamageVulnerabilities = ReadNextString(reader);
                                    ((EncounterMonsterModel)encounterCreature).DamageResistances     = ReadNextString(reader);
                                    ((EncounterMonsterModel)encounterCreature).DamageImmunities      = ReadNextString(reader);
                                    ((EncounterMonsterModel)encounterCreature).ConditionImmunities   = ReadNextString(reader);
                                }

                                encounter.Creatures.Add(encounterCreature);
                            }

                            encounter.Round = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.EncounterChallenge = (EncounterChallenge)BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.TotalCharacterHP   = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.TotalMonsterHP     = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.TimeElapsed        = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.CurrentTurn        = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.EncounterState     = (EncounterState)BitConverter.ToInt32(reader.ReadBytes(4), 0);
                            encounter.Notes = ReadNextString(reader);

                            encounters.Add(encounter);
                        }
                    }
                }
            }

            return(encounters);
        }
Пример #13
0
 public IActionResult Edit(CharacterModel model)
 {
     _repo.ModifyCharacter(model);
     return(RedirectToAction("Index"));
 }
Пример #14
0
 public void ShowCharacterModel(CharacterModel model)
 {
     _characterModelDetailController.ShowCharacterModel(model, Rendering);
 }
Пример #15
0
        /// <summary>
        /// Add the charcter to the character list
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool PopulateCharacterList(CharacterModel data)
        {
            CharacterList.Add(new PlayerInfoModel(data));

            return(true);
        }
 //set the skill in the UI
 private static void SetCharacterUI(int characterIndex, CharacterModel character)
 {
     currentCharacterInEquip [characterIndex] = character;
     ScreenBattleController.Instance.partCharacter.SetCharacterUI(characterIndex, character);
 }
Пример #17
0
        /// <summary>
        /// Character experience a critical miss.
        /// After rolling a critical miss. Roll a 10 sided dice. The following things can happen.
        /// Roll Value
        ///     1, Primary Hand Item breaks, and is lost forever
        ///     2-4, Character Drops the Primary Hand Item back into the item pool
        ///     5-6, Character drops a random equipped item back into the item pool
        ///     7-10, Nothing bad happens, luck was with the attacker
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public bool CharacterCriticalMiss(CharacterModel character)
        {
            // roll dice to determine event
            var d10 = DiceHelper.RollDice(1, 10);

            // Primary Hand Item breaks
            if (d10 == 1)
            {
                character.RemoveItem(ItemLocationEnum.PrimaryHand);
                BattleMessages.CriticalMissMessage = "Critical miss! Item in primary hand broke!";
                return(true);
            }

            // Character Drops the Primary Hand Item back into the item pool
            if (d10 >= 2 && d10 <= 4)
            {
                var item = character.RemoveItem(ItemLocationEnum.PrimaryHand);
                if (item != null)
                {
                    BattleMessages.CriticalMissMessage = "Critical miss! " + character.Name
                                                         + " dropped " + item.Name + " in item pool!";
                    ItemPool.Add(item);
                    return(true);
                }
            }

            // Character drops a random equipped item back into the item pool
            if (d10 >= 5 && d10 <= 6)
            {
                // check where character has items equipped
                var equipped = new List <ItemLocationEnum>();

                var item = character.GetItemByLocation(ItemLocationEnum.Head);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.Head);
                }

                item = character.GetItemByLocation(ItemLocationEnum.Necklass);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.Necklass);
                }

                item = character.GetItemByLocation(ItemLocationEnum.Feet);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.Feet);
                }

                item = character.GetItemByLocation(ItemLocationEnum.PrimaryHand);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.PrimaryHand);
                }

                item = character.GetItemByLocation(ItemLocationEnum.OffHand);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.OffHand);
                }

                item = character.GetItemByLocation(ItemLocationEnum.RightFinger);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.RightFinger);
                }

                item = character.GetItemByLocation(ItemLocationEnum.LeftFinger);
                if (item != null)
                {
                    equipped.Add(ItemLocationEnum.LeftFinger);
                }

                // no items equipped
                if (equipped.Count() <= 0)
                {
                    return(true);
                }

                var unequip = DiceHelper.RollDice(1, equipped.Count()) - 1;

                // check that dice roll was valid (in case forced rolls are being used)
                if (unequip < 0 || unequip >= equipped.Count())
                {
                    return(false);   // did not remove an item
                }

                item = character.RemoveItem(equipped.ElementAt(unequip));
                ItemPool.Add(item);
                BattleMessages.CriticalMissMessage = "Critical miss! " + character.Name
                                                     + " dropped " + item.Name + " in item pool!";
            }

            return(true);
        }
Пример #18
0
 public CharacterSpawn(CharacterModel m_model, Vector3Int m_position)
 {
     this.m_model    = m_model;
     this.m_position = m_position;
 }
Пример #19
0
 public void ExitLunchroom(CharacterModel c)
 {
     characters.Remove (c);
 }
 void Awake()
 {
     _playerModel = GetComponent<CharacterModel>();
     _animator = GetComponentInChildren<Animator>();
 }
Пример #21
0
 public void SetModel(CharacterModel characterModel)
 {
     Model = characterModel;
 }
Пример #22
0
        public bool HandleMessage(IMessage message, IServerPeer peer)
        {
            var serverPeer = peer as PhotonServerPeer;
            var operation  = new RegisterOperation(serverPeer.protocol, message);

            if (!operation.IsValid)
            {
                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, operation.GetErrorMessage(), (int)ReturnCode.OperationInvalid));

                return(true);
            }

            if (operation.Login.Length < 6 || operation.Password.Length < 6)
            {
                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, "Login and password can't be less than 6 symbols.", (int)ReturnCode.OperationInvalid));

                return(true);
            }
            else if (operation.Login.Length > 16 || operation.Password.Length > 16)
            {
                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, "Login and password can't be more than 16 symbols.", (int)ReturnCode.OperationInvalid));

                return(true);
            }

            var checkMail = new EmailAddressAttribute();

            if (!checkMail.IsValid(operation.Email))
            {
                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, "Email address incorrect.", (int)ReturnCode.OperationInvalid));

                return(true);
            }

            var characterData = MessageSerializerService.DeserializeObjectOfType <RegisterCharacterData>(
                operation.CharacterRegisterData);

            characterData.CharacterType = 1;             // delete this if we add more types

            if (characterData.CharacterName.Length < 6)
            {
                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, "Name of your character can't be less than 6 symbols.", (int)ReturnCode.OperationInvalid));

                return(true);
            }
            else if (characterData.CharacterName.Length > 16)
            {
                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, "Name of your can't be more than 16 symbols.", (int)ReturnCode.OperationInvalid));

                return(true);
            }
            else if (characterData.Sex != "Male" && characterData.Sex != "Female")
            {
                return(true);
            }
            else if (characterData.CharacterType != 1)             // add more types
            {
                return(true);
            }
            else if (characterData.Class != "Warrior" && characterData.Class != "Rogue" && characterData.Class != "Mage")
            {
                return(true);
            }
            else if (characterData.SubClass != "Warlock" && characterData.SubClass != "Cleric")
            {
                return(true);
            }

            try
            {
                using (var session = NHibernateHelper.OpenSession())
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        var accounts        = session.QueryOver <AccountModel>().Where(a => a.Login == operation.Login).List();
                        var accountsByEmail = session.QueryOver <AccountModel>().Where(a => a.Email == operation.Email).List();
                        var characters      = session.QueryOver <CharacterModel>().Where(c => c.Name == characterData.CharacterName).List();

                        if (accounts.Count > 0)
                        {
                            transaction.Commit();

                            peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                            {
                                { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                                { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                            }, "Login already taken.", (int)ReturnCode.AlreadyExist));

                            return(true);
                        }
                        else if (accountsByEmail.Count > 0)
                        {
                            transaction.Commit();

                            peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                            {
                                { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                                { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                            }, "Email already taken.", (int)ReturnCode.AlreadyExist));

                            return(true);
                        }
                        else if (characters.Count > 0)
                        {
                            transaction.Commit();

                            peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                            {
                                { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                                { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                            }, "Name already taken.", (int)ReturnCode.AlreadyExist));

                            return(true);
                        }

                        string salt = Guid.NewGuid().ToString().Replace("-", "");

                        AccountModel newAccount = new AccountModel()
                        {
                            Login    = operation.Login,
                            Password = BitConverter.ToString(SHA512.Create().ComputeHash(
                                                                 Encoding.UTF8.GetBytes(salt + operation.Password))).Replace("-", ""),
                            Salt  = salt,
                            Email = operation.Email,

                            AdminLevel = 0,
                            BanLevel   = 0,

                            Created = DateTime.Now,
                            Updated = DateTime.Now
                        };

                        session.Save(newAccount);
                        transaction.Commit();

                        Log.DebugFormat("Create new Account. Login - {0}.", operation.Login);
                    }

                    using (var transaction = session.BeginTransaction())
                    {
                        var accounts = session.QueryOver <AccountModel>().Where(a => a.Login == operation.Login).SingleOrDefault();

                        CharacterModel newCharacter = new CharacterModel()
                        {
                            AccountId = accounts,

                            Name          = characterData.CharacterName,
                            Sex           = characterData.Sex,
                            CharacterType = characterData.CharacterType,
                            Class         = characterData.Class,
                            SubClass      = characterData.SubClass,

                            Level     = 1,
                            Exp       = 0,
                            Strength  = 1,
                            Intellect = 1,

                            RangLevel = 0,

                            Gold       = 10000,
                            Donate     = 0,
                            SkillPoint = 1000,
                            StatPoint  = 0,

                            InventorySize = 32,

                            GuildId = 0,

                            Created = DateTime.Now,
                            Updated = DateTime.Now
                        };

                        session.Save(newCharacter);
                        transaction.Commit();

                        Log.DebugFormat("Create new Character. Name - {0}.", characterData.CharacterName);
                    }

                    peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                    {
                        { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                        { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                    }, "Register success.", (int)ReturnCode.OK));
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Error register handler: {0}", ex);

                peer.SendMessage(new Response(Code, SubCode, new Dictionary <byte, object>()
                {
                    { (byte)MessageParameterCode.SubCodeParameterCode, SubCode },
                    { (byte)MessageParameterCode.PeerIdParameterCode, message.Parameters[(byte)MessageParameterCode.PeerIdParameterCode] },
                }, ex.ToString(), (int)ReturnCode.OperationDenied));

                return(true);
            }
        }
 public void SetCharacterUI(int characterNumber, CharacterModel charCard)
 {
     charCards [characterNumber].SetCharacter(charCard);
 }
 public override void OnEnter()
 {
     // 初始化
     characterMono  = BlackBorad.CharacterMono;
     characterModel = characterMono.characterModel;
 }
Пример #25
0
 public void InitInventory(CharacterModel character)
 {
     Inventory = character.Inventory.ToArray();
     ItemDatas = character.ItemDatas.ToArray();
     UpdateInventory();
 }
Пример #26
0
        private async Task <MemoryStream> CreateCharacterCard(CharacterModel character, FreeCompanyModel freeCompany)
        {
            string cardFilePath = Path.Combine(Environment.CurrentDirectory, "Images/character_card.png");

            if (!File.Exists(cardFilePath))
            {
                Logger.Error($"Unabled to located card file. Looked for it at {cardFilePath}");
                return(null);
            }

            XIVTitleModel title = await _db.XIVTitles.FirstOrDefaultAsync(t => t.ID == character.Title);

            ClassJobIndex activeJob = (ClassJobIndex)character.ActiveClassJob.JobID;

            using (var card = Bitmap.FromFile(cardFilePath))
            {
                using (var g = Graphics.FromImage(card))
                {
                    Font nameFont = new Font("Russo One", 40, GraphicsUnit.Pixel);
                    Font jobFont  = new Font("Russo One", 30, GraphicsUnit.Pixel);
                    Font baseFont = new Font("Russo One", 20, GraphicsUnit.Pixel);


                    SolidBrush whiteBrush = new SolidBrush(System.Drawing.Color.White);
                    SolidBrush goldBrush  = new SolidBrush(System.Drawing.Color.FromArgb(148, 134, 90));

                    StringFormat centerCenterFormat = new StringFormat();
                    centerCenterFormat.Alignment     = StringAlignment.Center;
                    centerCenterFormat.LineAlignment = StringAlignment.Center;

                    StringFormat leftCenterFormat = new StringFormat();
                    leftCenterFormat.Alignment     = StringAlignment.Near;
                    leftCenterFormat.LineAlignment = StringAlignment.Center;

                    StringFormat leftTopFormat = new StringFormat();
                    leftTopFormat.Alignment     = StringAlignment.Near;
                    leftTopFormat.LineAlignment = StringAlignment.Near;

                    StringFormat leftBottomFormat = new StringFormat();
                    leftBottomFormat.Alignment     = StringAlignment.Near;
                    leftBottomFormat.LineAlignment = StringAlignment.Far;

                    using (var client = new HttpClient())
                    {
                        var response = await client.GetAsync(character.Portrait);

                        if (response != null && response.StatusCode == HttpStatusCode.OK)
                        {
                            using (var stream = await response.Content.ReadAsStreamAsync())
                            {
                                MemoryStream tempStream = new MemoryStream();
                                await stream.CopyToAsync(tempStream);

                                tempStream.Position = 0;

                                using (var portrait = Bitmap.FromStream(tempStream))
                                {
                                    g.DrawImage(portrait, new Rectangle(14, 14, 640, 873));
                                }
                            }
                        }
                    }

                    string portraitBorderFilePath = Path.Combine(Environment.CurrentDirectory, "Images/portrait_border.png");

                    if (File.Exists(portraitBorderFilePath))
                    {
                        using (var jobIcon = Bitmap.FromFile(portraitBorderFilePath))
                        {
                            g.DrawImage(jobIcon, 14, 14, 640, 640);
                        }
                    }

                    //  Title
                    if (title != null)
                    {
                        g.DrawString(title.Name, baseFont, whiteBrush, new Rectangle(714, 32, 542, 63), leftTopFormat);
                    }

                    //  Name
                    g.DrawString(character.Name, nameFont, goldBrush, new Rectangle(709, 50, 542, 45), leftTopFormat);

                    //  Server
                    g.DrawString(character.Server, baseFont, whiteBrush, new Rectangle(714, 132, 542, 34), leftCenterFormat);

                    //  Free Company
                    if (freeCompany != null)
                    {
                        g.DrawString($"{freeCompany.Name} <{freeCompany.Tag}>", baseFont, whiteBrush, new Rectangle(714, 201, 542, 34), leftCenterFormat);
                    }
                    else
                    {
                        g.DrawString("-", baseFont, whiteBrush, new Rectangle(714, 201, 542, 34), leftCenterFormat);
                    }

                    string jobIconFilePath = ClassJobUtilities.ClassJobToAbbr(activeJob);

                    if (!string.IsNullOrEmpty(jobIconFilePath))
                    {
                        jobIconFilePath = Path.Combine(Environment.CurrentDirectory, $"Images/Icons/{jobIconFilePath}.png");

                        if (File.Exists(jobIconFilePath))
                        {
                            using (var jobIcon = Bitmap.FromFile(jobIconFilePath))
                            {
                                g.DrawImage(jobIcon, 713, 275, 24, 24);
                            }
                        }
                    }

                    //  Active Job Level
                    g.DrawString($"Level {character.ActiveClassJob.Level}", baseFont, whiteBrush, new Rectangle(739, 270, 120, 34), leftCenterFormat);

                    //  Active Job
                    g.DrawString(ClassJobUtilities.ClassJobToName(activeJob), baseFont, goldBrush, new Rectangle(835, 270, 169, 34), leftCenterFormat);

                    //  Paladin
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Paladin).Level}", jobFont, whiteBrush, new Rectangle(710, 388, 55, 55), centerCenterFormat);

                    //  Warrior
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Warrior).Level}", jobFont, whiteBrush, new Rectangle(780, 388, 55, 55), centerCenterFormat);

                    //  Dark Knight
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.DarkKnight).Level}", jobFont, whiteBrush, new Rectangle(850, 388, 55, 55), centerCenterFormat);

                    //  Gunbreaker
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Gunbreaker).Level}", jobFont, whiteBrush, new Rectangle(920, 388, 55, 55), centerCenterFormat);

                    //  Whitemage
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.WhiteMage).Level}", jobFont, whiteBrush, new Rectangle(1060, 388, 55, 55), centerCenterFormat);

                    //  Scholar
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Scholar).Level}", jobFont, whiteBrush, new Rectangle(1130, 388, 55, 55), centerCenterFormat);

                    //  Astro
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Astrologian).Level}", jobFont, whiteBrush, new Rectangle(1200, 388, 55, 55), centerCenterFormat);

                    //  Monk
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Monk).Level}", jobFont, whiteBrush, new Rectangle(710, 498, 55, 55), centerCenterFormat);

                    //  Dragoon
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Dragoon).Level}", jobFont, whiteBrush, new Rectangle(780, 498, 55, 55), centerCenterFormat);

                    //  Ninja
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Ninja).Level}", jobFont, whiteBrush, new Rectangle(850, 498, 55, 55), centerCenterFormat);
                    //  Samurai
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Samurai).Level}", jobFont, whiteBrush, new Rectangle(920, 498, 55, 55), centerCenterFormat);

                    //  Bard
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Bard).Level}", jobFont, whiteBrush, new Rectangle(1060, 498, 55, 55), centerCenterFormat);

                    //  Machinist
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Machinist).Level}", jobFont, whiteBrush, new Rectangle(1130, 498, 55, 55), centerCenterFormat);

                    //  Dancer
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Dancer).Level}", jobFont, whiteBrush, new Rectangle(1200, 498, 55, 55), centerCenterFormat);

                    //  Black Mage
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.BlackMage).Level}", jobFont, whiteBrush, new Rectangle(710, 608, 55, 55), centerCenterFormat);

                    //  Summoner
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Summoner).Level}", jobFont, whiteBrush, new Rectangle(780, 608, 55, 55), centerCenterFormat);

                    //  Red Mage
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.RedMage).Level}", jobFont, whiteBrush, new Rectangle(850, 608, 55, 55), centerCenterFormat);

                    //  Blue Mage
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.BlueMage).Level}", jobFont, whiteBrush, new Rectangle(1060, 608, 55, 55), centerCenterFormat);

                    //  Carpenter
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Carpenter).Level}", jobFont, whiteBrush, new Rectangle(710, 718, 55, 55), centerCenterFormat);

                    //  Blacksmith
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Blacksmith).Level}", jobFont, whiteBrush, new Rectangle(780, 718, 55, 55), centerCenterFormat);

                    //  Armorer
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Armorer).Level}", jobFont, whiteBrush, new Rectangle(850, 718, 55, 55), centerCenterFormat);

                    //  Goldsmith
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Goldsmith).Level}", jobFont, whiteBrush, new Rectangle(920, 718, 55, 55), centerCenterFormat);

                    //  Leatherworker
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Leatherworker).Level}", jobFont, whiteBrush, new Rectangle(990, 718, 55, 55), centerCenterFormat);

                    //  Weaver
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Weaver).Level}", jobFont, whiteBrush, new Rectangle(1060, 718, 55, 55), centerCenterFormat);

                    //  Alchemist
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Alchemist).Level}", jobFont, whiteBrush, new Rectangle(1130, 718, 55, 55), centerCenterFormat);

                    //  Culinarian
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Culinarian).Level}", jobFont, whiteBrush, new Rectangle(1200, 718, 55, 55), centerCenterFormat);

                    //  Miner
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Miner).Level}", jobFont, whiteBrush, new Rectangle(710, 828, 55, 55), centerCenterFormat);

                    //  Botanist
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Botanist).Level}", jobFont, whiteBrush, new Rectangle(780, 828, 55, 55), centerCenterFormat);

                    //  Fisher
                    g.DrawString($"{character.ClassJobs.First(x => x.JobID == (int)ClassJobIndex.Fisher).Level}", jobFont, whiteBrush, new Rectangle(850, 828, 55, 55), centerCenterFormat);
                }

                MemoryStream memoryStream = new MemoryStream();

                card.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);

                //card.Save(@"C:\Users\Dart\Desktop\saved_card.png");
                return(memoryStream);
            }
        }
 public void GetItemList(string slot, string characterRace, string characterClass, CharacterModel character)
 {
     this.character      = character;
     this.slot           = slot;
     this.characterRace  = characterRace;
     this.characterClass = characterClass;
     rotation            = 0;
     searchTextBox.Text  = "";
     ClassType();
 }
Пример #28
0
 public CharacterModelAndHealth(CharacterModel model, CharacterModel.Health health)
 {
     this.model  = model;
     this.health = health;
 }
 private void Apply(CharacterModel target)
 {
     target.HealthPoints -= Power;
 }
Пример #30
0
        private void CharacterModelOnInstanceUpdate(On.RoR2.CharacterModel.orig_InstanceUpdate orig, CharacterModel self)
        {
            orig(self);
            if (self.GetFieldValue <EliteIndex>("myEliteIndex") == _eliteIndex)
            {
                int replaced = 0;
                for (var i = 0; i < self.baseRendererInfos.Length; i++)
                {
                    var mat = self.baseRendererInfos[i].defaultMaterial;
                    if (!_darkMats.TryGetValue(mat.name, out var darkMat))
                    {
                        //We have a special case for Wisp-related textures
                        //This will also impact any other cloud-based textures, which should be okay
                        const string remapTexName = "_RemapTex";
                        if (mat.GetTexturePropertyNames().Contains(remapTexName))
                        {
                            darkMat = new Material(mat);
                            darkMat.SetColor("_TintColor", new Color(6f, 0.1f, 7f, 1.3f));
                            darkMat.SetColor("_EmissionColor", new Color(0.12f, 0f, 0.1f, 0.1f));
                            var cloudTex = darkMat.GetTexture(remapTexName) as Texture2D;
                            if (cloudTex != null)
                            {
                                //Make clouds purple
                                var darkCloudTex = ReplaceWithRamp(cloudTex, new Vector3(0.3f, 0, 0.51f), 0.5f);
                                darkMat.SetTexture(remapTexName, darkCloudTex);
                            }
                        }
                        else
                        {
                            ////darkMat.color = new Color(0.1f, 0.1f, 0.1f);
                            //var texture = darkMat.mainTexture as Texture2D;
                            //if (texture != null)
                            //{
                            //    //Make base textures just darker overall
                            //    var darkTex = DarkifyTexture(texture, 0.05f, 0.05f, 0.05f);
                            //    darkMat.mainTexture = darkTex;
                            //}
                            if (self.name.ToLower().Contains("wisp"))
                            {
                                darkMat = HailstormAssets.PureBlack;
                            }
                            else
                            {
                                darkMat = HailstormAssets.PurpleCracks;
                            }
                        }
                        _darkMats[mat.name] = darkMat;
                        replaced++;
                    }
                    self.baseRendererInfos[i].defaultMaterial = darkMat;
                }

                if (replaced > 0)
                {
                    Debug.Log($"Dark Elite: {replaced} materials replaced");
                }
            }
        }
 /// <summary>
 /// Updates the model
 /// </summary>
 public void UpdateModel(CharacterModel characterModel)
 {
     _characterModel = characterModel;
     Initialize();
     OnPropertyChanged(String.Empty);
 }
Пример #32
0
        public async Task CharacterModel_GetDamageRollValue_With_Item_And_Pokedex_Should_Pass()
        {
            // Arrange
            // Add each model here to warm up and load it.
            Game.Helpers.DataSetsHelper.WarmUp();

            // Create items
            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 1, Id = "Head" });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 20, Id = "Necklass" });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 300, Id = "PrimaryHand", Damage = 1 });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 4000, Id = "OffHand" });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 50000, Id = "RightFinger" });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 600000, Id = "LeftFinger" });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 7000000, Id = "Feet" });

            await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 80000000, Id = "Pokeball", Damage = 1 });

            // Create CharacterModel
            var data = new CharacterModel();

            data.Level = 1;

            // Add items
            data.AddItem(ItemLocationEnum.Head, (await ItemIndexViewModel.Instance.ReadAsync("Head")).Id);
            data.AddItem(ItemLocationEnum.Necklass, (await ItemIndexViewModel.Instance.ReadAsync("Necklass")).Id);
            data.AddItem(ItemLocationEnum.PrimaryHand, (await ItemIndexViewModel.Instance.ReadAsync("PrimaryHand")).Id);
            data.AddItem(ItemLocationEnum.OffHand, (await ItemIndexViewModel.Instance.ReadAsync("OffHand")).Id);
            data.AddItem(ItemLocationEnum.RightFinger, (await ItemIndexViewModel.Instance.ReadAsync("RightFinger")).Id);
            data.AddItem(ItemLocationEnum.LeftFinger, (await ItemIndexViewModel.Instance.ReadAsync("LeftFinger")).Id);
            data.AddItem(ItemLocationEnum.Feet, (await ItemIndexViewModel.Instance.ReadAsync("Feet")).Id);
            data.AddItem(ItemLocationEnum.Pokeball, (await ItemIndexViewModel.Instance.ReadAsync("Pokeball")).Id);

            // Add Pokedex
            data.Pokedex.Add(new MonsterModel {
                Attack = 5
            });
            data.Pokedex.Add(new MonsterModel {
                Attack = 15
            });

            // Set forced rolls
            Game.Helpers.DiceHelper.EnableForcedRolls();
            Game.Helpers.DiceHelper.SetForcedRollValue(1);

            // Act

            // Add the second item, this will return the first item as the one replaced
            var result = data.GetDamageRollValue();

            // Reset
            Game.Helpers.DiceHelper.DisableForcedRolls();

            // Assert
            Assert.AreEqual(3, result);
        }
Пример #33
0
 public Character(uint AcctId, string charName, int charModel)
 {
     AccountId = AcctId;
     Name = charName;
     Model = (CharacterModel)charModel;
     Equipment = new ItemList(27);
     Inventory = new ItemList(63);
     Storage = new ItemList(70);
     Quests = new QuestList();
     ArchivedDigimon = new uint[40];
     DigimonList = new Digimon[3];
 }
Пример #34
0
        private void UserLoggedInCommand(IDictionary<string, object> command)
        {
            var character = command.Get(Constants.Arguments.Identity);

            var temp = new CharacterModel
                {
                    Name = character,
                    Gender = ParseGender(command.Get("gender")),
                    Status = command.Get("status").ToEnum<StatusType>()
                };

            CharacterManager.SignOn(temp);

            Events.GetEvent<NewUpdateEvent>()
                .Publish(
                    new CharacterUpdateModel(
                        temp, new CharacterUpdateModel.LoginStateChangedEventArgs {IsLogIn = true}));
        }
Пример #35
0
 public void EnterLunchroom(CharacterModel c)
 {
     characters.Add (c);
 }
Пример #36
0
	public void Initialize( string name, int speed, Vector3 startPos, System.Action OnChangeResources ) {
		model = new CharacterModel( name, speed, startPos, OnChangeResources, this );
		model.moving = true;
	}
Пример #37
0
        /// <summary>
        /// Creates a character archive from the character model
        /// </summary>
        public byte[] CreateCharacterArchive(CharacterModel characterModel)
        {
            byte[] bytes = null;

            using (MemoryStream stream = new MemoryStream())
            {
                using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create))
                {
                    ZipArchiveEntry entry = archive.CreateEntry("character.ccc");
                    using (BinaryWriter writer = new BinaryWriter(entry.Open()))
                    {
                        byte[] characterBytes = GetCharacterBytes(characterModel);
                        writer.Write(characterBytes);
                    }

                    archive.CreateEntry("resources/");

                    ZipArchiveEntry backgrounds = archive.CreateEntry("resources/backgrounds.xml");
                    using (StreamWriter writer = new StreamWriter(backgrounds.Open(), Encoding.UTF8))
                    {
                        string xml = _xmlExporter.GetXML(characterModel.Background);
                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);
                        writer.Write(xml);
                    }

                    ZipArchiveEntry classes = archive.CreateEntry("resources/classes.xml");
                    using (StreamWriter writer = new StreamWriter(classes.Open(), Encoding.UTF8))
                    {
                        string xml = String.Empty;

                        List <Guid> ids = new List <Guid>();
                        foreach (LevelModel levelModel in characterModel.Levels)
                        {
                            if (levelModel.Class != null && !ids.Any(x => x == levelModel.Class.Id))
                            {
                                ids.Add(levelModel.Class.Id);

                                xml += _xmlExporter.GetXML(levelModel.Class);
                            }
                        }

                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);

                        writer.Write(xml);
                    }

                    ZipArchiveEntry conditions = archive.CreateEntry("resources/conditions.xml");
                    using (StreamWriter writer = new StreamWriter(conditions.Open(), Encoding.UTF8))
                    {
                        string xml = String.Empty;

                        List <Guid> ids = new List <Guid>();
                        foreach (AppliedConditionModel appliedCondition in characterModel.Conditions)
                        {
                            if (appliedCondition.ConditionModel != null && !ids.Any(x => x == appliedCondition.ConditionModel.Id))
                            {
                                ids.Add(appliedCondition.ConditionModel.Id);

                                xml += _xmlExporter.GetXML(appliedCondition.ConditionModel);
                            }
                        }

                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);

                        writer.Write(xml);
                    }

                    ZipArchiveEntry feats = archive.CreateEntry("resources/feats.xml");
                    using (StreamWriter writer = new StreamWriter(feats.Open(), Encoding.UTF8))
                    {
                        string xml = String.Empty;

                        List <Guid> ids = new List <Guid>();
                        foreach (LevelModel levelModel in characterModel.Levels)
                        {
                            foreach (FeatModel feat in levelModel.Feats)
                            {
                                if (!ids.Any(x => x == feat.Id))
                                {
                                    ids.Add(feat.Id);

                                    xml += _xmlExporter.GetXML(feat);
                                }
                            }
                        }

                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);

                        writer.Write(xml);
                    }

                    ZipArchiveEntry items = archive.CreateEntry("resources/items.xml");
                    using (StreamWriter writer = new StreamWriter(items.Open(), Encoding.UTF8))
                    {
                        string xml = String.Empty;

                        List <Guid> ids = new List <Guid>();
                        foreach (BagModel bagModel in characterModel.Bags)
                        {
                            foreach (EquipmentModel equipmentModel in bagModel.Equipment)
                            {
                                if (equipmentModel.Item != null && !ids.Any(x => x == equipmentModel.Item.Id))
                                {
                                    ids.Add(equipmentModel.Item.Id);

                                    xml += _xmlExporter.GetXML(equipmentModel.Item);
                                }
                            }
                        }

                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);

                        writer.Write(xml);
                    }

                    ZipArchiveEntry languages = archive.CreateEntry("resources/languages.csv");
                    using (StreamWriter writer = new StreamWriter(languages.Open(), Encoding.UTF8))
                    {
                        foreach (LanguageModel language in characterModel.Languages)
                        {
                            writer.WriteLine($"{language.Id},{language.Name}");
                        }
                    }

                    ZipArchiveEntry monsters = archive.CreateEntry("resources/monsters.xml");
                    using (StreamWriter writer = new StreamWriter(monsters.Open(), Encoding.UTF8))
                    {
                        string xml = String.Empty;

                        List <Guid> ids = new List <Guid>();
                        foreach (CompanionModel companionModel in characterModel.Companions)
                        {
                            if (companionModel.MonsterModel != null && !ids.Any(x => x == companionModel.MonsterModel.Id))
                            {
                                ids.Add(companionModel.MonsterModel.Id);

                                xml += _xmlExporter.GetXML(companionModel.MonsterModel);
                            }
                        }

                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);

                        writer.Write(xml);
                    }

                    ZipArchiveEntry races = archive.CreateEntry("resources/races.xml");
                    using (StreamWriter writer = new StreamWriter(races.Open(), Encoding.UTF8))
                    {
                        string xml = _xmlExporter.GetXML(characterModel.Race);
                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);
                        writer.Write(xml);
                    }

                    ZipArchiveEntry spells = archive.CreateEntry("resources/spells.xml");
                    using (StreamWriter writer = new StreamWriter(spells.Open(), Encoding.UTF8))
                    {
                        string xml = String.Empty;

                        List <Guid> ids = new List <Guid>();
                        foreach (SpellbookModel spellbookModel in characterModel.Spellbooks)
                        {
                            foreach (SpellbookEntryModel spellbookEntryModel in spellbookModel.Spells)
                            {
                                if (spellbookEntryModel.Spell != null && !ids.Any(x => x == spellbookEntryModel.Spell.Id))
                                {
                                    ids.Add(spellbookEntryModel.Spell.Id);

                                    xml += _xmlExporter.GetXML(spellbookEntryModel.Spell);
                                }
                            }
                        }

                        xml = _xmlExporter.WrapAndFormatXMLWithHeader(xml);

                        writer.Write(xml);
                    }
                }

                bytes = stream.ToArray();
            }

            return(bytes);
        }
Пример #38
0
        public static int CreateCharacter(Client player, CharacterModel characterModel, SkinModel skin, List <ClothesModel> clothesModels)
        {
            int playerId = 0;

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                try
                {
                    connection.Open();
                    MySqlCommand command = connection.CreateCommand();
                    command.CommandText = "INSERT INTO characterlist (characterName, age, sex, login) VALUES (@characterName, @playerAge, @playerSex, @login)";
                    command.Parameters.AddWithValue("@characterName", characterModel.characterName);
                    command.Parameters.AddWithValue("@playerAge", characterModel.age);
                    command.Parameters.AddWithValue("@playerSex", characterModel.sex);
                    command.Parameters.AddWithValue("@login", player.Name);
                    command.ExecuteNonQuery();

                    // Получаем ID созданного персонажа
                    playerId = (int)command.LastInsertedId;

                    // Store player's skin
                    command.CommandText  = "INSERT INTO skins VALUES (@playerId, @firstHeadShape, @secondHeadShape, @firstSkinTone, @secondSkinTone, @headMix, @skinMix, ";
                    command.CommandText += "@hairModel, @firstHairColor, @secondHairColor, @beardModel, @beardColor, @chestModel, @chestColor, @blemishesModel, @ageingModel, ";
                    command.CommandText += "@complexionModel, @sundamageModel, @frecklesModel, @noseWidth, @noseHeight, @noseLength, @noseBridge, @noseTip, @noseShift, @browHeight, ";
                    command.CommandText += "@browWidth, @cheekboneHeight, @cheekboneWidth, @cheeksWidth, @eyes, @lips, @jawWidth, @jawHeight, @chinLength, @chinPosition, @chinWidth, ";
                    command.CommandText += "@chinShape, @neckWidth, @eyesColor, @eyebrowsModel, @eyebrowsColor, @makeupModel, @blushModel, @blushColor, @lipstickModel, @lipstickColor)";
                    command.Parameters.AddWithValue("@playerId", playerId);
                    command.Parameters.AddWithValue("@firstHeadShape", skin.firstHeadShape);
                    command.Parameters.AddWithValue("@secondHeadShape", skin.secondHeadShape);
                    command.Parameters.AddWithValue("@firstSkinTone", skin.firstSkinTone);
                    command.Parameters.AddWithValue("@secondSkinTone", skin.secondSkinTone);
                    command.Parameters.AddWithValue("@headMix", skin.headMix);
                    command.Parameters.AddWithValue("@skinMix", skin.skinMix);
                    command.Parameters.AddWithValue("@hairModel", skin.hairModel);
                    command.Parameters.AddWithValue("@firstHairColor", skin.firstHairColor);
                    command.Parameters.AddWithValue("@secondHairColor", skin.secondHairColor);
                    command.Parameters.AddWithValue("@beardModel", skin.beardModel);
                    command.Parameters.AddWithValue("@beardColor", skin.beardColor);
                    command.Parameters.AddWithValue("@chestModel", skin.chestModel);
                    command.Parameters.AddWithValue("@chestColor", skin.chestColor);
                    command.Parameters.AddWithValue("@blemishesModel", skin.blemishesModel);
                    command.Parameters.AddWithValue("@ageingModel", skin.ageingModel);
                    command.Parameters.AddWithValue("@complexionModel", skin.complexionModel);
                    command.Parameters.AddWithValue("@sundamageModel", skin.sundamageModel);
                    command.Parameters.AddWithValue("@frecklesModel", skin.frecklesModel);
                    command.Parameters.AddWithValue("@noseWidth", skin.noseWidth);
                    command.Parameters.AddWithValue("@noseHeight", skin.noseHeight);
                    command.Parameters.AddWithValue("@noseLength", skin.noseLength);
                    command.Parameters.AddWithValue("@noseBridge", skin.noseBridge);
                    command.Parameters.AddWithValue("@noseTip", skin.noseTip);
                    command.Parameters.AddWithValue("@noseShift", skin.noseShift);
                    command.Parameters.AddWithValue("@browHeight", skin.browHeight);
                    command.Parameters.AddWithValue("@browWidth", skin.browWidth);
                    command.Parameters.AddWithValue("@cheekboneHeight", skin.cheekboneHeight);
                    command.Parameters.AddWithValue("@cheekboneWidth", skin.cheekboneWidth);
                    command.Parameters.AddWithValue("@cheeksWidth", skin.cheeksWidth);
                    command.Parameters.AddWithValue("@eyes", skin.eyes);
                    command.Parameters.AddWithValue("@lips", skin.lips);
                    command.Parameters.AddWithValue("@jawWidth", skin.jawWidth);
                    command.Parameters.AddWithValue("@jawHeight", skin.jawHeight);
                    command.Parameters.AddWithValue("@chinLength", skin.chinLength);
                    command.Parameters.AddWithValue("@chinPosition", skin.chinPosition);
                    command.Parameters.AddWithValue("@chinWidth", skin.chinWidth);
                    command.Parameters.AddWithValue("@chinShape", skin.chinShape);
                    command.Parameters.AddWithValue("@neckWidth", skin.neckWidth);
                    command.Parameters.AddWithValue("@eyesColor", skin.eyesColor);
                    command.Parameters.AddWithValue("@eyebrowsModel", skin.eyebrowsModel);
                    command.Parameters.AddWithValue("@eyebrowsColor", skin.eyebrowsColor);
                    command.Parameters.AddWithValue("@makeupModel", skin.makeupModel);
                    command.Parameters.AddWithValue("@blushModel", skin.blushModel);
                    command.Parameters.AddWithValue("@blushColor", skin.blushColor);
                    command.Parameters.AddWithValue("@lipstickModel", skin.lipstickModel);
                    command.Parameters.AddWithValue("@lipstickColor", skin.lipstickColor);
                    command.ExecuteNonQuery();

                    // Получаем модели одежды из листа моделей.
                    foreach (ClothesModel cloth in clothesModels)
                    {
                        // Очищаем параметры команды.
                        command.Parameters.Clear();
                        command.CommandText = "INSERT INTO clothes (characterid, slot, drawable, texture) VALUES (@characterid, @slot, @drawable, @texture)";
                        command.Parameters.AddWithValue("@characterid", playerId);
                        command.Parameters.AddWithValue("@slot", cloth.slot);
                        command.Parameters.AddWithValue("@drawable", cloth.drawable);
                        command.Parameters.AddWithValue("@texture", cloth.texture);
                        command.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    NAPI.Util.ConsoleOutput("[EXCEPTION CreateCharacter] " + ex.Message);
                    NAPI.Util.ConsoleOutput("[EXCEPTION CreateCharacter] " + ex.StackTrace);
                    player.TriggerEvent("characterNameDuplicated", characterModel.characterName);
                }
            }

            return(playerId);
        }
Пример #39
0
        private void InitialCharacterListCommand(IDictionary<string, object> command)
        {
            dynamic arr = command[Constants.Arguments.MultipleCharacters]; // dynamic for ease-of-use
            foreach (JsonArray character in arr)
            {
                ICharacter temp = new CharacterModel();

                temp.Name = (string) character[0]; // Character's name

                temp.Gender = ParseGender((string) character[1]); // character's gender

                temp.Status = character[2].ToEnum<StatusType>();

                // Character's status
                temp.StatusMessage = (string) character[3]; // Character's status message

                CharacterManager.SignOn(temp);
            }
        }
Пример #40
0
        internal override void InitializeSkins()
        {
            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;

            List <SkinDef> skins = new List <SkinDef>();

            #region DefaultSkin
            SkinDef defaultSkin = Modules.Skins.CreateSkinDef(HenryPlugin.developerPrefix + "_HENRY_BODY_DEFAULT_SKIN_NAME",
                                                              Assets.mainAssetBundle.LoadAsset <Sprite>("texMainSkin"),
                                                              defaultRenderers,
                                                              mainRenderer,
                                                              model);

            defaultSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenrySword"),
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenryGun"),
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenry"),
                    renderer = defaultRenderers[instance.mainRendererIndex].renderer
                }
            };

            skins.Add(defaultSkin);
            #endregion

            #region MasterySkin
            Material masteryMat = Modules.Assets.CreateMaterial("matHenryAlt");
            CharacterModel.RendererInfo[] masteryRendererInfos = SkinRendererInfos(defaultRenderers, new Material[]
            {
                masteryMat,
                masteryMat
            });

            SkinDef masterySkin = Modules.Skins.CreateSkinDef(HenryPlugin.developerPrefix + "_HENRY_BODY_MASTERY_SKIN_NAME",
                                                              Assets.mainAssetBundle.LoadAsset <Sprite>("texMasteryAchievement"),
                                                              masteryRendererInfos,
                                                              mainRenderer,
                                                              model,
                                                              masterySkinUnlockableDef);

            masterySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenrySwordAlt"),
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenryAlt"),
                    renderer = defaultRenderers[instance.mainRendererIndex].renderer
                }
            };

            skins.Add(masterySkin);
            #endregion

            skinController.skins = skins.ToArray();
        }
Пример #41
0
    //////////////////////////////////////////
    /// CheckForBonuses()
    /// Checks for bonuses and alters the
    /// incoming damage based on them, if
    /// necessary.
    //////////////////////////////////////////
    private int CheckForBonuses( AbilityData i_dataAbility, int i_nDamage, CharacterModel i_charTarget, CharacterModel i_charAggressor ) {
        // get the list of bonuses on this ability
        List<BonusData> listBonuses = i_dataAbility.Bonuses;

        // go through each bonus data and add its bonus to the total damage
        foreach ( BonusData dataBonus in listBonuses ) {
            i_nDamage += dataBonus.GetBonusAmount( i_charAggressor, i_charTarget );
        }

        return i_nDamage;
    }
Пример #42
0
        public void HackathonScenario_Scenario_30_First_Battle_Character_Is_Buffed()
        {
            /*
             * Scenario Number:
             *  30
             *
             * Description:
             *      The first character in the player list gets their base Attack, Speed, Defense values
             *      buffed by 2x for the time they are the first in the list.
             *
             * Changes Required (Classes, Methods etc.)  List Files, Methods, and Describe Changes:
             *     PickCharactersPage
             *     CreateEngineCharacterList()
             *
             * Test Algrorithm:
             *  Create list of Picked Characters with some Attack, Defense, Speed Attribute values
             *  Call method CreateEngineCharacterList() to copy Picked characters to Engine.CharacterList
             *
             *
             * Test Conditions:
             *  Test Attack attribute of first character from Engine.CharacterList
             *  Test Defense attribute of first character from Engine.CharacterList
             *  Test Speed attribute of first character from Engine.CharacterList
             *
             *
             * Validation:
             *      Verify the Attack attribute of the first charater to be doubled from Engine.CharacterList
             *      Verify the Defense attribute of the first charater to be doubled from Engine.CharacterList
             *      Verify the Speed attribute of the first charater to be doubled from Engine.CharacterList
             *
             *
             *
             */

            //Arrange
            // Set Character Conditions

            var CharacterModel1 =
                new CharacterModel
            {
                Level         = 10,
                CurrentHealth = 200,
                MaxHealth     = 200,
                Experience    = 100,
                Name          = "Rabbit",
                Attack        = 100,
                Speed         = 100,
                Defense       = 100
            };

            var CharacterModel2 =
                new CharacterModel
            {
                Level         = 8,
                CurrentHealth = 300,
                MaxHealth     = 300,
                Experience    = 100,
                Name          = "Pig",
                Attack        = 50,
                Speed         = 50,
                Defense       = 50
            };

            PickCharactersPage.EngineViewModel = BattleEngineViewModel.Instance;
            PickCharactersPage.EngineViewModel.PartyCharacterList = new ObservableCollection <CharacterModel>();
            PickCharactersPage.EngineViewModel.PartyCharacterList.Add(CharacterModel1);
            PickCharactersPage.EngineViewModel.PartyCharacterList.Add(CharacterModel2);

            // Create CharacterList
            PickCharactersPage.CreateEngineCharacterList();

            //Assert
            Assert.AreEqual(200, PickCharactersPage.EngineViewModel.Engine.CharacterList.First().Attack);
            Assert.AreEqual(200, PickCharactersPage.EngineViewModel.Engine.CharacterList.First().Defense);
            Assert.GreaterOrEqual(PickCharactersPage.EngineViewModel.Engine.CharacterList.First().Speed, 200);
        }