Ejemplo n.º 1
0
 public MsgFlushExp(WeaponSkill aSkill)
     : base(12)
 {
     Exp     = aSkill.Exp;
     Type    = aSkill.Type;
     _Action = Action.WeaponSkill;
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Applies Effect on that is not accounted for
    /// </summary>
    /// <returns> If it suceeded </returns>
    public override bool ApplyEffects(Skill effect)
    {
        if (base.ApplyEffects(effect))
        {
            return(true);
        }

        WeaponSkill skill = effect as WeaponSkill;

        if (skill == null)
        {
            return(false);
        }


        switch (skill.applyTo)
        {
        case WeaponSkill.ApplyTo.BulletSpeed:
            bulletSpeed += effect.Effect();
            return(true);

        default:
            break;
        }
        return(false);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new message for the specified skill.
 /// </summary>
 /// <param name="aSkill">The weapon skill.</param>
 public MsgWeaponSkill(WeaponSkill aSkill)
     : base(16)
 {
     Type  = aSkill.Type;
     Level = aSkill.Level;
     Exp   = aSkill.Exp;
 }
 public bool IsWeakAgainst(WeaponSkill weapon)
 {
     if (weapon == null)
     {
         return(false);
     }
     return(weapon.advantageType == charClass.classType);
 }
Ejemplo n.º 5
0
    public static Skill AddWeaponSkill(string name, string icon, Weapon.WeaponTypes weapon)
    {
        WeaponSkill w = new WeaponSkill();

        w.WeaponType = weapon;

        return(AddSkill(name, icon, w));
    }
Ejemplo n.º 6
0
        private static ISkill LightMissileQuickShot()
        {
            ISkill result = new WeaponSkill {
                ImageFile = "Quick_Shot", ChanceToHit = 0, Energy = 20, ChanceToHitPerUnitOfDistance = 4
            };

            return(result);
        }
Ejemplo n.º 7
0
        public static ISkill LightMissileAimedShot()
        {
            ISkill result = new WeaponSkill {
                ImageFile = "Aimed_Shot", ChanceToHit = 20, Energy = 40, ChanceToHitPerUnitOfDistance = 2
            };

            return(result);
        }
Ejemplo n.º 8
0
        public OnSkill(Unit unit, IEnumerable <HitResult> hits, WeaponSkill skill, IEnumerable <Vector3> dashVectors)
        {
            _unit        = unit;
            _hits        = hits;
            _skill       = skill;
            _dashVectors = dashVectors;

            HighPriority = true;
        }
Ejemplo n.º 9
0
 public Weapon(WeaponSkill skill, decimal weight)
     : base(skill.FullName, weight)
 {
     ExceptionUtils.CheckArgumentNotNull(skill);
     ExceptionUtils.CheckArgumentNotNull(weight);
     this.Skill = skill;
     this.BaseChance = skill.BaseChance;
     // TODO BaseChance and DamageModifier can be modified from base
     // TODO introduce factory to construct these
 }
Ejemplo n.º 10
0
        public Warrior(Race race, Level level) : base(race, level)
        {
            Rage = new Rage(100);
            PrimaryAttributes   = CalculatePrimaryAttributes(level);
            SecondaryAttributes = CalculateSecondaryAttributes(PrimaryAttributes);

            // 5 point Defense cap increase per level, we are assuming maximum is achieved.
            SecondaryAttributes.Defense.Add(Level.Value * 5);
            // Get all weapon skills, capped at the maximum for the players level.
            var maxWeaponSkillsForLevel = WeaponSkill.GetWeaponSkills(Level);

            SecondaryAttributes.WeaponSkills.Add(maxWeaponSkillsForLevel);
        }
Ejemplo n.º 11
0
    public int GetAdvantage(WeaponSkill otherWeapon)
    {
        if (otherWeapon == null)
        {
            return(0);
        }
        switch (weaponType)
        {
        case WeaponType.SWORD:
        case WeaponType.RED:
            if (otherWeapon.weaponType == WeaponType.AXE || otherWeapon.weaponType == WeaponType.GREEN)
            {
                return(1);
            }
            else if (otherWeapon.weaponType == WeaponType.LANCE || otherWeapon.weaponType == WeaponType.BLUE)
            {
                return(-1);
            }
            break;

        case WeaponType.LANCE:
        case WeaponType.BLUE:
            if (otherWeapon.weaponType == WeaponType.SWORD || otherWeapon.weaponType == WeaponType.RED)
            {
                return(1);
            }
            else if (otherWeapon.weaponType == WeaponType.AXE || otherWeapon.weaponType == WeaponType.GREEN)
            {
                return(-1);
            }
            break;

        case WeaponType.AXE:
        case WeaponType.GREEN:
            if (otherWeapon.weaponType == WeaponType.LANCE || otherWeapon.weaponType == WeaponType.BLUE)
            {
                return(1);
            }
            else if (otherWeapon.weaponType == WeaponType.SWORD || otherWeapon.weaponType == WeaponType.RED)
            {
                return(-1);
            }
            break;

        default:
            return(0);
        }

        return(0);
    }
Ejemplo n.º 12
0
    public void SetWeaponSkill(WeaponSkill skill)
    {
        if (skills.Contains(skill))
        {
            if (TwoHandsMagic)
            {
                TwoHandsMagic          = false;
                SecondActiveMagicSkill = null;
            }

            WeaponActiveSkill = skill;
            UIEventHandler.PlayerSkillsChanged(this);
        }
    }
Ejemplo n.º 13
0
 public void ShowAttackTiles(MapTile startTile, WeaponSkill weapon, Faction faction, bool isDanger)
 {
     for (int i = 0; i < tiles.Length; i++)
     {
         int tempDist = DistanceTo(startTile, tiles[i]);
         if (weapon.InRange(tempDist))
         {
             if (isDanger)
             {
                 tiles[i].reachable = true;
             }
             else if (tiles[i].currentCharacter == null || tiles[i].currentCharacter.faction != faction)
             {
                 tiles[i].attackable = true;
             }
         }
     }
 }
Ejemplo n.º 14
0
    public bool CanAttack()
    {
        WeaponSkill weapon = GetWeapon();

        if (weapon == null)
        {
            return(false);
        }
        for (int i = 0; i < enemyList.values.Count; i++)
        {
            int distance = MapCreator.DistanceTo(this, enemyList.values[i]);
            if (weapon.InRange(distance))
            {
                return(true);
            }
        }
        return(false);
    }
Ejemplo n.º 15
0
 public bool CheckRange(TacticsMove player, bool isAttack)
 {
     if (isAttack)
     {
         WeaponSkill weapon = player.GetWeapon();
         if (weapon == null)
         {
             return(false);
         }
         for (int i = 0; i < enemyList.values.Count; i++)
         {
             int distance = MapCreator.DistanceTo(player, enemyList.values[i]);
             if (weapon.InRange(distance))
             {
                 return(true);
             }
         }
     }
     else
     {
         SupportSkill support = player.GetSupport();
         if (support == null)
         {
             return(false);
         }
         for (int i = 0; i < playerList.values.Count; i++)
         {
             if (!playerList.values[i].IsInjured())
             {
                 continue;
             }
             int distance = MapCreator.DistanceTo(player, playerList.values[i]);
             if (support.InRange(distance))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 16
0
    public void Attack(int skillnum)
    {
        skillnum = skillnum - 1;         // for indexing
        WeaponSkill skill = skills[skillnum];

        Collider[] colliders = Physics.OverlapSphere(transform.position, skill.getCurrent().getRange() * 5);
        foreach (Collider c in colliders)
        {
            Debug.Log(c.gameObject.name);
            if (c.gameObject.tag == "Enemy")
            {
                Vector3 enemypos = c.transform.position - transform.position;
                if (Vector3.Dot(transform.forward, enemypos) > 0)
                {
                    //c.gameObject.SetActive(false);
                    Enemy e = c.GetComponent <Enemy>();
                    Debug.Log("power is " + skill.getCurrent().getPower());
                    e.isAttacked(skill.getCurrent().getPower());
                }
            }
        }
    }
Ejemplo n.º 17
0
    public void updateWeapon(WeaponInfo newWeapon)
    {
        Dictionary <string, int[]> prevWeaponLevels = weaponManager.GetUpgrades();

        weaponName = newWeapon.name;
        bool alreadyUpgraded = weaponManager.alreadyUpgraded(weaponName);

        weaponDescription = newWeapon.description;
        imagePath         = newWeapon.imgpath;
        updateImage();
        skills = new List <WeaponSkill>();

        // construct the weapon object
        for (int i = 0; i < 3; i++)
        {
            SkillInfo         skillInfo   = newWeapon.skills[i];
            List <SkillLevel> levels      = new List <SkillLevel>();
            int[]             savedLevels = new int[3];
            if (alreadyUpgraded)
            {
                savedLevels = prevWeaponLevels[weaponName];
            }

            foreach (LevelInfo levelInfo in skillInfo.levels)
            {
                levels.Add(new SkillLevel(levelInfo.power, levelInfo.speed, levelInfo.range));
            }

            WeaponSkill newSkill = new WeaponSkill(skillInfo.name, skillInfo.description, skillInfo.imgpath, levels);
            if (alreadyUpgraded)
            {
                Debug.Log("setting skill " + i + "'s level to " + savedLevels[i]);
                newSkill.setLevel(savedLevels[i]);
            }
            skills.Add(newSkill);
        }
    }
Ejemplo n.º 18
0
    void updateSkill(GameObject skillDisplay, WeaponSkill weaponSkill)
    {
        Text name = skillDisplay.transform.Find("Name").GetComponent <Text>();

        name.text = weaponSkill.getName();

        Text description = skillDisplay.transform.Find("Description").GetComponent <Text>();

        description.text = weaponSkill.getDescription();
        // Current stats
        updateStats(skillDisplay, "Current", weaponSkill.getCurrent());

        Button upgradeButton = skillDisplay.transform.Find("Button").GetComponent <Button>();

        if (weaponSkill.isMaxed())
        {
            skillDisplay.transform.Find("Next").GetComponent <Canvas>().enabled = false;
            skillDisplay.transform.Find("Max").GetComponent <Canvas>().enabled  = true;
            upgradeButton.interactable = false;
            upgradeButton.transform.Find("Text").GetComponent <Text>().text = "Upgrade";
        }
        else
        {
            // make sure everything is displaying even if you change weapons
            skillDisplay.transform.Find("Next").GetComponent <Canvas>().enabled = true;
            skillDisplay.transform.Find("Max").GetComponent <Canvas>().enabled  = false;

            int pointsNeeded = weaponSkill.getLevel() * 100;
            upgradeButton.GetComponent <UpgradeButton>().setPointsNeeded(pointsNeeded);
            upgradeButton.transform.Find("Text").GetComponent <Text>().text = "Upgrade (" + pointsNeeded.ToString() + " pts)";

            upgradeButton.interactable = player.getPoints() >= pointsNeeded ? true : false;
            // update the next skill values
            updateStats(skillDisplay, "Next", weaponSkill.getNext());
        }
    }
Ejemplo n.º 19
0
    public void PopulateSkillList()
    {
        ClearList();
        int            id    = 0;
        StatsContainer cont  = clickCharacter.value;
        CharacterStats stats = characters[clickCharacter.value.statsID];

        spText.text = cont.currentSp.ToString();

        //Weapons
        for (int i = 0; i < stats.weapons.Length; i++)
        {
            WeaponSkill weapon = stats.weapons[i];
            Transform   skill  = Instantiate(skillTemplate);
            skill.SetParent(skillListParent);

            SkillRepresentation rep = skill.GetComponent <SkillRepresentation>();
            rep.skillID           = id++;
            rep.type              = SkillRepType.WEAPON;
            rep.typeIcon.color    = Color.red;
            rep.skillName.text    = weapon.skillName;
            rep.description.text  = weapon.description;
            rep.cost              = weapon.cost;
            rep.costText.text     = (i <= cont.weaponLevel) ? "Unlocked" : "SP: " + weapon.cost;
            rep.costText.color    = (cont.currentSp < weapon.cost && i == cont.weaponLevel + 1) ? Color.red : Color.black;
            rep.buttonImage.color = (i <= cont.weaponLevel) ? new Color(0.4f, 0.8f, 0.4f) :
                                    (i == cont.weaponLevel + 1) ? Color.white : Color.gray;
            rep.clickButton.interactable = (i == cont.weaponLevel + 1 && cont.currentSp >= weapon.cost);
            buttonList.Add(rep);
            skill.gameObject.SetActive(true);
        }

        //Supports
        for (int i = 0; i < stats.supports.Length; i++)
        {
            SupportSkill support = stats.supports[i];
            Transform    skill   = Instantiate(skillTemplate);
            skill.SetParent(skillListParent);

            SkillRepresentation rep = skill.GetComponent <SkillRepresentation>();
            rep.skillID           = id++;
            rep.type              = SkillRepType.SUPPORT;
            rep.typeIcon.color    = Color.cyan;
            rep.skillName.text    = support.skillName;
            rep.description.text  = support.description;
            rep.cost              = support.cost;
            rep.costText.text     = (i <= cont.supportLevel) ? "Unlocked" : "SP: " + support.cost;
            rep.costText.color    = (cont.currentSp < support.cost && i == cont.supportLevel + 1) ? Color.red : Color.black;
            rep.buttonImage.color = (i <= cont.supportLevel) ? new Color(0.4f, 0.8f, 0.4f) :
                                    (i == cont.supportLevel + 1) ? Color.white : Color.gray;
            rep.clickButton.interactable = (i == cont.supportLevel + 1 && cont.currentSp >= support.cost);
            buttonList.Add(rep);
            skill.gameObject.SetActive(true);
        }

        //Skills
        for (int i = 0; i < stats.skills.Length; i++)
        {
            SkillSkill skill          = stats.skills[i];
            Transform  skillTransform = Instantiate(skillTemplate);
            skillTransform.SetParent(skillListParent);

            SkillRepresentation rep = skillTransform.GetComponent <SkillRepresentation>();
            rep.skillID           = id++;
            rep.type              = SkillRepType.SKILL;
            rep.typeIcon.color    = Color.magenta;
            rep.skillName.text    = skill.skillName;
            rep.description.text  = skill.description;
            rep.cost              = skill.cost;
            rep.costText.text     = (i <= cont.skillLevel) ? "Unlocked" : "SP: " + skill.cost;
            rep.costText.color    = (cont.currentSp < skill.cost && i == cont.skillLevel + 1) ? Color.red : Color.black;
            rep.buttonImage.color = (i <= cont.skillLevel) ? new Color(0.4f, 0.8f, 0.4f) :
                                    (i == cont.skillLevel + 1) ? Color.white : Color.gray;
            rep.clickButton.interactable = (i == cont.skillLevel + 1 && cont.currentSp >= skill.cost);
            buttonList.Add(rep);
            skillTransform.gameObject.SetActive(true);
        }

        //Skill A
        for (int i = 0; i < stats.skillsA.Length; i++)
        {
            PassiveSkill passive        = stats.skillsA[i];
            Transform    skillTransform = Instantiate(skillTemplate);
            skillTransform.SetParent(skillListParent);

            SkillRepresentation rep = skillTransform.GetComponent <SkillRepresentation>();
            rep.skillID            = id++;
            rep.type               = SkillRepType.SKILLA;
            rep.typeIcon.color     = new Color(1f, 0.5f, 0);
            rep.typeCharacter.text = "A";
            rep.skillName.text     = passive.baseSkill.skillName;
            rep.description.text   = passive.baseSkill.description;
            rep.cost               = passive.baseSkill.cost;
            rep.costText.text      = (i <= cont.skillALevel) ? "Unlocked" : "SP: " + passive.baseSkill.cost;
            rep.costText.color     = (cont.currentSp < passive.baseSkill.cost && i == cont.skillALevel + 1) ? Color.red : Color.black;
            rep.buttonImage.color  = (i <= cont.skillALevel) ? new Color(0.4f, 0.8f, 0.4f) :
                                     (i == cont.skillALevel + 1) ? Color.white : Color.gray;
            rep.clickButton.interactable = (i == cont.skillALevel + 1 && cont.currentSp >= passive.baseSkill.cost);
            buttonList.Add(rep);
            skillTransform.gameObject.SetActive(true);
        }

        //Skill B
        for (int i = 0; i < stats.skillsB.Length; i++)
        {
            PassiveSkill passive        = stats.skillsB[i];
            Transform    skillTransform = Instantiate(skillTemplate);
            skillTransform.SetParent(skillListParent);

            SkillRepresentation rep = skillTransform.GetComponent <SkillRepresentation>();
            rep.skillID            = id++;
            rep.type               = SkillRepType.SKILLB;
            rep.typeIcon.color     = new Color(1f, 0.5f, 0);
            rep.typeCharacter.text = "B";
            rep.skillName.text     = passive.baseSkill.skillName;
            rep.description.text   = passive.baseSkill.description;
            rep.cost               = passive.baseSkill.cost;
            rep.costText.text      = (i <= cont.skillBLevel) ? "Unlocked" : "SP: " + passive.baseSkill.cost;
            rep.costText.color     = (cont.currentSp < passive.baseSkill.cost && i == cont.skillBLevel + 1) ? Color.red : Color.black;
            rep.buttonImage.color  = (i <= cont.skillBLevel) ? new Color(0.4f, 0.8f, 0.4f) :
                                     (i == cont.skillBLevel + 1) ? Color.white : Color.gray;
            rep.clickButton.interactable = (i == cont.skillBLevel + 1 && cont.currentSp >= passive.baseSkill.cost);
            buttonList.Add(rep);
            skillTransform.gameObject.SetActive(true);
        }

        //Skill C
        for (int i = 0; i < stats.skillsC.Length; i++)
        {
            PassiveSkill passive        = stats.skillsC[i];
            Transform    skillTransform = Instantiate(skillTemplate);
            skillTransform.SetParent(skillListParent);

            SkillRepresentation rep = skillTransform.GetComponent <SkillRepresentation>();
            rep.skillID            = id++;
            rep.type               = SkillRepType.SKILLC;
            rep.typeIcon.color     = new Color(1f, 0.5f, 0);
            rep.typeCharacter.text = "C";
            rep.skillName.text     = passive.baseSkill.skillName;
            rep.description.text   = passive.baseSkill.description;
            rep.cost               = passive.baseSkill.cost;
            rep.costText.text      = (i <= cont.skillCLevel) ? "Unlocked" : "SP: " + passive.baseSkill.cost;
            rep.costText.color     = (cont.currentSp < passive.baseSkill.cost && i == cont.skillCLevel + 1) ? Color.red : Color.black;
            rep.buttonImage.color  = (i <= cont.skillCLevel) ? new Color(0.4f, 0.8f, 0.4f) :
                                     (i == cont.skillCLevel + 1) ? Color.white : Color.gray;
            rep.clickButton.interactable = (i == cont.skillCLevel + 1 && cont.currentSp >= passive.baseSkill.cost);
            buttonList.Add(rep);
            skillTransform.gameObject.SetActive(true);
        }

        Debug.Log("Finished populating");
    }
Ejemplo n.º 20
0
    public static Skill AddWeaponSkill(string name, string icon, Weapon.WeaponTypes weapon)
    {
        WeaponSkill w = new WeaponSkill();
        w.WeaponType = weapon;

        return AddSkill(name, icon, w);
    }
Ejemplo n.º 21
0
 /// <summary>
 /// Get the value of the current property of this model
 /// </summary>
 public int GetProperty(WeaponSkill skill, WeaponProperty property)
 {
     return(MtaShared.GetWeaponProperty(ID, skill.ToString().ToLower(), property.ToString().ToLower()));
 }
Ejemplo n.º 22
0
    /// <summary>
    /// 条件过滤 (单过滤)
    /// </summary>
    /// <returns>The filter.</returns>
    /// <param name="_actors">Actors.</param>
    /// <param name="_actor">Actor.</param>
    /// <param name="_ws">Ws.</param>
    public static BattleStageActor SimpleFilter(List <BattleStageActor> _actors, BattleStageActor _actor, WeaponSkill _ws)
    {
        BattleStageActor result = null;

        for (int i = 0; i < _actors.Count; i++)
        {
            if (_ws.weaponSkill.skillCondition == Tags.Condition_Dis)
            {
                switch (_ws.weaponSkill.compareValue)
                {
                case CompareValue.enGreaterEquals:
                case CompareValue.enGreater:
                    if (zTools.DistanceZeroY(_actor.transform.position, _actors [i].transform.position) >= _ws.weaponSkill.value)
                    {
                        result = _actors [i];
                    }
                    break;

                case CompareValue.enEquals:
                    if (zTools.DistanceZeroY(_actor.transform.position, _actors [i].transform.position) == _ws.weaponSkill.value)
                    {
                        result = _actors [i];
                    }
                    break;

                case CompareValue.enLess:
                case CompareValue.enLessEquals:
                    if (zTools.DistanceZeroY(_actor.transform.position, _actors [i].transform.position) <= _ws.weaponSkill.value)
                    {
                        result = _actors [i];
                    }
                    break;
                }
            }
        }

        return(result);
    }
Ejemplo n.º 23
0
 /// <summary>
 /// Notifies users when a weapon skill is used
 /// </summary>
 /// <param name="attacker"></param>
 /// <param name="hits"></param>
 /// <param name="skill"></param>
 public void NotifyUnitWeaponSkillUsed(Unit attacker, List <HitResult> hits, WeaponSkill skill, IEnumerable <Vector3> dashVectors)
 {
     RoomInstance.MulticastPacket(new OnSkill(attacker, hits, skill, dashVectors));
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Sets the value of a property of this mode
 /// </summary>
 /// <param name="skill"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool SetProperty(WeaponSkill skill, WeaponProperty property, int value)
 {
     return(MtaShared.SetWeaponProperty(ID, skill.ToString().ToLower(), property.ToString().ToLower(), value));
 }
Ejemplo n.º 25
0
        /// <summary>
        /// 读取Excel表格并向内存中写入技能数据
        /// </summary>
        /// RowCount,ColumnCount : 读取的行数和列数 维护时请删除Excel内的空白行 以提高性能
        /// <returns></returns>
        ObjectResult <WeaponSkill> LoadFromLocalSkill()
        {
            var ObjResult = new ObjectResult <WeaponSkill>();
            List <WeaponSkill> skillList = new List <WeaponSkill>();

            try
            {
                var asm          = System.Reflection.Assembly.GetExecutingAssembly();
                var resourceName = asm.GetName().Name + ".Resources.Excel.WeaponSkill.xls";

                Aspose.Cells.Workbook wk;
                using (Stream stream = asm.GetManifestResourceStream(resourceName))
                {
                    wk = new Aspose.Cells.Workbook(stream);
                }
                var sheet = wk.Worksheets["WeaponSkill"];

                //读取的行数和列数 维护时请根据Excel内的行数列数设置  以提高性能
                int RowCount    = sheet.Cells.Rows.Count;
                int ColumnCount = 50;

                DataTable dt = sheet.Cells.ExportDataTable(0, 0, RowCount, ColumnCount);
                for (var i = 2; i < dt.Rows.Count; i++)
                {
                    WeaponSkill skill = new WeaponSkill
                    {
                        Skill_ID  = Convert.ToInt32(dt.Rows[i][0]),
                        Main_Name = (WeaponSkill.SkillTypeEnum)Enum.Parse(typeof(WeaponSkill.SkillTypeEnum),
                                                                          dt.Rows[i][1].ToString()),
                        Extra_Name           = dt.Rows[i][2].ToString() == string.Empty ? "" : dt.Rows[i][2].ToString(),
                        Main_Description     = dt.Rows[i][3].ToString() == string.Empty ? "" : dt.Rows[i][3].ToString(),
                        Extra_Description    = dt.Rows[i][4].ToString() == string.Empty ? "" : dt.Rows[i][4].ToString(),
                        Main_Tag             = dt.Rows[i][5].ToString() == string.Empty ? "" : dt.Rows[i][5].ToString(),
                        Extra_Tag            = dt.Rows[i][6].ToString() == string.Empty ? "" : dt.Rows[i][6].ToString(),
                        IsCalculation        = dt.Rows[i][7].ToString() == "1",
                        IsSpecialCalculation = dt.Rows[i][8].ToString() == "1",
                        IsSpecial            = dt.Rows[i][9].ToString() == "1",
                        TheReason            = dt.Rows[i][10].ToString() == string.Empty ? "" : dt.Rows[i][10].ToString(),
                        Extra_Comment        = dt.Rows[i][13].ToString() == string.Empty ? "" : dt.Rows[i][13].ToString(),
                        DurationType         = dt.Rows[i][14].ToString() == string.Empty
                            ? WeaponSkill.DurationEnum.NoHave
                            : (WeaponSkill.DurationEnum)Enum.Parse(typeof(WeaponSkill.DurationEnum),
                                                                   dt.Rows[i][14].ToString()),
                        DurationValue = dt.Rows[i][15].ToString() == string.Empty
                            ? (short)-1
                            : Convert.ToInt16(dt.Rows[i][15].ToString()),
                        SummonType = dt.Rows[i][16].ToString() == string.Empty
                            ? WeaponSkill.SummonEnum.Normal
                            : (WeaponSkill.SummonEnum)Enum.Parse(typeof(WeaponSkill.SummonEnum),
                                                                 dt.Rows[i][16].ToString())
                    };
                    //设置持续时间类型
                    //设置技能生效条件
                    skill.SetConditionType(dt.Rows[i][17].ToString());
                    skill.MaxValue  = dt.Rows[i][18].ToString() == string.Empty ? 0 : Convert.ToDouble(dt.Rows[i][18].ToString());
                    skill.BaseLimit = dt.Rows[i][19].ToString() == string.Empty ? -1.0 : Convert.ToDouble(dt.Rows[i][19].ToString());


                    //设置技能目标
                    if (dt.Rows[i][11].ToString() != string.Empty)
                    {
                        skill.SetSkillTarget(dt.Rows[i][11].ToString());
                    }
                    //设置计算方式
                    if (dt.Rows[i][12].ToString() != string.Empty)
                    {
                        skill.SetFormulaModeEnum(dt.Rows[i][12].ToString());
                    }

                    //设置技能数值
                    var StrList = new List <string>();
                    for (var index = 19; index < 40; index++)
                    {
                        StrList.Add(dt.Rows[i][index].ToString() == string.Empty ? "" : dt.Rows[i][index].ToString());
                    }
                    skill.SetSkillValue(StrList);

                    skillList.Add(skill);
                }
                skillList.Insert(0, new WeaponSkill()
                {
                    Main_Name        = WeaponSkill.SkillTypeEnum.allSkill,
                    Main_Description = "全部技能",
                    Skill_ID         = -1,
                    TheReason        = "该技能仅作为一个筛选技能的词缀存在,无计算,无其他作用",
                    IsCalculation    = false
                });
                skillList.Add(new WeaponSkill()
                {
                    Main_Name        = WeaponSkill.SkillTypeEnum.errorSkill,
                    Main_Description = "错误技能",
                    Skill_ID         = -999,
                    TheReason        = "技能字典集中无此技能,请维护技能字典集",
                    IsCalculation    = false
                });
                ObjResult.ObjList = skillList;
                ObjResult         = new WeaponSkill().GetWeaponSkillList(ObjResult);
            }
            catch (Exception ex)
            {
                return(ObjResult.SetError("从Excel读取技能数据失败:" + ex.Message));
            }
            return(ObjResult);
        }
Ejemplo n.º 26
0
    public bool CheckTile(MapTile checkTile, int currentDistance, int moveSpeed, Faction faction, ClassType classType, WeaponSkill weapon, SupportSkill support, bool showAttack, bool isDanger)
    {
        if (checkTile == null)
        {
            return(false);
        }

        if (checkTile.currentCharacter != null)
        {
            if (checkTile.currentCharacter.faction != faction)
            {
                return(false);
            }
        }

        if (checkTile.GetRoughness(classType) == -1)
        {
            return(false);
        }
        currentDistance += checkTile.GetRoughness(classType);
        if (currentDistance >= checkTile.distance)
        {
            return(false);
        }

        checkTile.distance = currentDistance;
        if (isDanger)
        {
            checkTile.reachable = true;
        }
        else if (currentDistance <= moveSpeed && checkTile.currentCharacter == null)
        {
            checkTile.selectable = (checkTile.currentCharacter == null);
        }

        if (weapon != null && showAttack)
        {
            mapCreator.ShowAttackTiles(checkTile, weapon, faction, isDanger);
        }

        if (support != null && showAttack)
        {
            mapCreator.ShowSupportTiles(checkTile, support, faction, isDanger);
        }

        checkTile.parent = this;
        return(true);
    }
Ejemplo n.º 27
0
        /// <summary>
        /// 设置武器技能
        /// </summary>
        /// <param name="SkillStr">Excel中的技能短字符串</param>
        /// <param name="Weapon">被设置技能的武器</param>
        void SetSkillNew(String SkillStr, Weapon Weapon)
        {
            if (SkillStr == "")
            {
                return;
            }
            //不确定的技能名单
            var ineptitude = ToolsAndHelper.GetSpecialSkillList();

            try
            {
                //先用英文逗号分割技能字符串 ,提取其中的多个技能
                var SkillArray = SplitString(SkillStr, 2, IsHaveEmpty: StringSplitOptions.RemoveEmptyEntries);
                //遍历技能列表获取技能名称
                foreach (var item in SkillArray)
                {
                    //技能实体
                    WeaponSkill Skill;
                    //技能后缀
                    var SkillSuffix = "";
                    //后缀索引
                    short SkillSuffixIndex;
                    var   element = WeaponSkill.GBFElementCHSEnum.未知;

                    //判断是否为特殊技能 如果是则直接设置特殊技能
                    if (ineptitude.Exists(x => x == item))
                    {
                        Skill = SkillList.ObjStrDic[item].FirstOrDefault()?.Clone() as WeaponSkill;
                        //设置是否启用技能警告
                        Weapon.SkillWarning = true;
                        if (Skill == null)
                        {
                            throw new Exception("未知的特殊技能,请添加信息");
                        }
                        Weapon.WeaponSkill.Add(Skill);
                        continue;
                    }

                    var TempStr = SplitString(item, 3);
                    //取出技能主名称
                    var SkillMainName = TempStr.FirstOrDefault();

                    //当索引为1的字符串 不为数字(属性)时 ,寻找技能副名称,且索引为2的字符串为元素
                    if (!ToolsAndHelper.StringContentType(TempStr[1], 2))
                    {
                        var ExtraNameResult = ToolsAndHelper.FoundSkillExtraName(SkillMainName, TempStr[1], SkillList.ObjStrDic);

                        //如果返回值为空则说明字典集中不存在副名称为SkillExtraName的技能
                        if (ExtraNameResult == "")
                        {
                            Skill = SkillList.ObjStrDic["errorSkill"].FirstOrDefault();
                            Skill = Copier <WeaponSkill, WeaponSkill> .Copy(Skill);

                            Weapon.WeaponSkill.Add(Skill);
                            Weapon.SkillWarning = true;
                            continue;
                        }
                        //将返回值(主名称+副名称) 赋值给主名称
                        SkillMainName = ExtraNameResult;
                        //技能后缀的索引
                        SkillSuffixIndex = 3;
                    }
                    else
                    {
                        //否则索引为1的字符串为元素
                        //赋值元素,设置技能后缀索引
                        element = (WeaponSkill.GBFElementCHSEnum)Enum.Parse(
                            typeof(WeaponSkill.GBFElementCHSEnum), TempStr[1]);
                        SkillSuffixIndex = 2;
                    }
                    //赋值后缀
                    if (TempStr.Count >= 1 + SkillSuffixIndex)
                    {
                        SkillSuffix = TempStr[SkillSuffixIndex];
                        if (TempStr.Count > 1 + SkillSuffixIndex)
                        {
                            SkillSuffix += TempStr[1 + SkillSuffixIndex];
                        }
                        else
                        {
                            if (element == WeaponSkill.GBFElementCHSEnum.未知)
                            {
                                element = (WeaponSkill.GBFElementCHSEnum)Enum.Parse(
                                    typeof(WeaponSkill.GBFElementCHSEnum), TempStr[SkillSuffixIndex]);
                            }
                        }
                    }
                    //验证后缀
                    SkillSuffix = ToolsAndHelper.FoundSkillSuffix(SkillMainName, SkillSuffix, SkillList.ObjStrDic);

                    //如果技能字典集中有此技能
                    if (SkillList.ObjStrDic.Keys.ToList().Exists(x => x == SkillMainName))
                    {
                        //搜索并设置武器的技能
                        // ReSharper disable once AssignNullToNotNullAttribute
                        Skill = SkillList.ObjStrDic[SkillMainName].FirstOrDefault(x => x.Extra_Name == SkillSuffix);
                        Skill = Copier <WeaponSkill, WeaponSkill> .Copy(Skill);

                        if (Skill == null)
                        {
                            Skill = new WeaponSkill()
                            {
                                Main_Name        = (WeaponSkill.SkillTypeEnum)Enum.Parse(typeof(WeaponSkill.SkillTypeEnum), SkillMainName),
                                Extra_Name       = SkillSuffix,
                                Main_Description = "Excel中未读取到此后缀的技能,请添加",
                                IsCalculation    = false,
                                TheReason        = "Excel中未读取到此后缀的技能,请添加"
                            };
                            SkillList.ObjStrDic[SkillMainName].Add(Skill);
                            Weapon.SkillWarning = true;
                        }

                        Skill.SkillElement = element;
                        Weapon.WeaponSkill.Add(Skill);
                    }
                    else
                    {
                        throw new Exception("特殊技能 请添加信息");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("设置武器\"" + (string.IsNullOrEmpty(Weapon.FsName_CHS) ? Weapon.FnWeapon_ID.ToString() : Weapon.FsName_CHS) + "\"的武器技能时时发生错误:" + ex.Message);
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 ///     Gets the weaponSkill value of a specified <see cref="WeaponSkill" /> of this <see cref="ICharacter" />.
 /// </summary>
 /// <param name="weaponSkill">The weapon skill type.</param>
 /// <returns>The weapons skill value.</returns>
 public int GetSkillWeapon(WeaponSkill weaponSkill)
 {
     return(this.orgCharacter.GetSkillWeapon(weaponSkill));
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Process the message for the specified client.
        /// </summary>
        /// <param name="aClient">The client who sent the message.</param>
        public override void Process(Client aClient)
        {
            try
            {
                Player player = aClient.Player;

                if (Words.StartsWith("/"))
                {
                    String[] Parts = Words.Split(' ');

                    switch (Parts[0]) // tmp
                    {
                    case "/mm":       //Teleport the player to the specified location
                    {
                        const string USAGE = "USAGE: /mm ${mapid} ${x} ${y}";

                        if (Parts.Length != 4)
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        UInt32 mapId = 0;
                        UInt16 x = 0, y = 0;

                        if (!UInt32.TryParse(Parts[1], out mapId) || !UInt16.TryParse(Parts[2], out x) || !UInt16.TryParse(Parts[3], out y))
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        player.Move(UInt32.Parse(Parts[1]), UInt16.Parse(Parts[2]), UInt16.Parse(Parts[3]));
                        return;
                    }

                    case "/scroll":     //Teleport the player to the specified map
                    {
                        const string USAGE = "USAGE: /scroll {tc,am,dc,mc,bi,pc,ma,arena}";

                        if (Parts.Length != 2)
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        switch (Parts[1])
                        {
                        case "tc":
                            player.Move(1002, 431, 379);
                            break;

                        case "am":
                            player.Move(1020, 567, 576);
                            break;

                        case "dc":
                            player.Move(1000, 500, 650);
                            break;

                        case "mc":
                            player.Move(1001, 316, 642);
                            break;

                        case "bi":
                            player.Move(1015, 723, 573);
                            break;

                        case "pc":
                            player.Move(1011, 190, 271);
                            break;

                        case "ma":
                            player.Move(1036, 292, 236);
                            break;

                        case "arena":
                            player.Move(1005, 52, 69);
                            break;
                        }
                        return;
                    }

                    case "/lvl":
                    {
                        const string USAGE = "USAGE: /level ${level}";

                        if (Parts.Length != 2)
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        Byte level = 0;
                        if (!Byte.TryParse(Parts[1], out level))
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        if (level == 0 || level > (Database.AllLevExp.Count + 1))
                        {
                            return;
                        }

                        player.Level = level;
                        player.Exp   = 0;
                        MyMath.GetLevelStats(player);

                        player.Send(new MsgUserAttrib(player, player.Level, MsgUserAttrib.AttributeType.Level));
                        player.Send(new MsgUserAttrib(player, player.Strength, MsgUserAttrib.AttributeType.Strength));
                        player.Send(new MsgUserAttrib(player, player.Agility, MsgUserAttrib.AttributeType.Agility));
                        player.Send(new MsgUserAttrib(player, player.Vitality, MsgUserAttrib.AttributeType.Vitality));
                        player.Send(new MsgUserAttrib(player, player.Spirit, MsgUserAttrib.AttributeType.Spirit));
                        player.Send(new MsgUserAttrib(player, player.AddPoints, MsgUserAttrib.AttributeType.AddPoints));
                        player.Send(new MsgAction(player, 0, MsgAction.Action.UpLev));
                        return;
                    }

                    case "/job":
                    {
                        const string USAGE = "USAGE: /job ${jobid}";

                        if (Parts.Length != 2)
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        Byte jobid = 0;
                        if (!Byte.TryParse(Parts[1], out jobid))
                        {
                            player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                            return;
                        }

                        if (jobid == 0 || jobid % 10 > 5)
                        {
                            return;
                        }

                        player.Profession = jobid;
                        MyMath.GetLevelStats(player);

                        player.Send(new MsgUserAttrib(player, player.Profession, MsgUserAttrib.AttributeType.Profession));
                        player.Send(new MsgUserAttrib(player, player.Strength, MsgUserAttrib.AttributeType.Strength));
                        player.Send(new MsgUserAttrib(player, player.Agility, MsgUserAttrib.AttributeType.Agility));
                        player.Send(new MsgUserAttrib(player, player.Vitality, MsgUserAttrib.AttributeType.Vitality));
                        player.Send(new MsgUserAttrib(player, player.Spirit, MsgUserAttrib.AttributeType.Spirit));
                        player.Send(new MsgUserAttrib(player, player.AddPoints, MsgUserAttrib.AttributeType.AddPoints));
                        return;
                    }

                    case "/reallot":
                    {
                        MyMath.GetLevelStats(player);
                        player.Send(new MsgUserAttrib(player, player.Strength, MsgUserAttrib.AttributeType.Strength));
                        player.Send(new MsgUserAttrib(player, player.Agility, MsgUserAttrib.AttributeType.Agility));
                        player.Send(new MsgUserAttrib(player, player.Vitality, MsgUserAttrib.AttributeType.Vitality));
                        player.Send(new MsgUserAttrib(player, player.Spirit, MsgUserAttrib.AttributeType.Spirit));
                        player.Send(new MsgUserAttrib(player, player.AddPoints, MsgUserAttrib.AttributeType.AddPoints));
                        return;
                    }

                    case "/money":
                    {
                        UInt32 money = UInt32.Parse(Parts[1]);
                        if (money < 0)
                        {
                            money = 0;
                        }

                        if (money > Player._MAX_MONEYLIMIT)
                        {
                            money = Player._MAX_MONEYLIMIT;
                        }

                        player.Money = money;
                        player.Send(new MsgUserAttrib(player, player.Money, MsgUserAttrib.AttributeType.Money));
                        return;
                    }

                    case "/item":
                    {
                        if (player.ItemInInventory() > 39)
                        {
                            return;
                        }

                        Int32  itemId = -1;
                        String name   = Parts[1].Replace("'", "`");

                        foreach (Item.Info info in Database.AllItems.Values)
                        {
                            if (info.Name.ToLower() == name.ToLower())
                            {
                                itemId = info.ID;
                                break;
                            }
                        }

                        if (itemId < 0)
                        {
                            return;
                        }

                        itemId = (itemId - (itemId % 10)) + Byte.Parse(Parts[2]);

                        Item item = Item.Create(player.UniqId, 0, itemId, Byte.Parse(Parts[3]), Byte.Parse(Parts[4]), Byte.Parse(Parts[5]), Byte.Parse(Parts[6]), Byte.Parse(Parts[7]), 2, 0, ItemHandler.GetMaxDura(itemId), ItemHandler.GetMaxDura(itemId));
                        player.AddItem(item, true);
                        return;
                    }

                    case "/prof":
                    {
                        UInt16      Type        = UInt16.Parse(Parts[1]);
                        SByte       Level       = SByte.Parse(Parts[2]);
                        UInt32      Exp         = 0;
                        WeaponSkill WeaponSkill = null;

                        if (Level > Database.AllWeaponSkillExp.Count)
                        {
                            Level = (SByte)Database.AllWeaponSkillExp.Count;
                        }

                        if (Level < -1)
                        {
                            Level = -1;
                        }

                        if (Level == -1)
                        {
                            WeaponSkill = player.GetWeaponSkillByType(Type);
                            if (WeaponSkill != null)
                            {
                                player.DropSkill(WeaponSkill, true);
                            }
                        }
                        else
                        {
                            WeaponSkill = player.GetWeaponSkillByType(Type);
                            if (WeaponSkill != null)
                            {
                                player.DropSkill(WeaponSkill, true);
                            }

                            WeaponSkill = WeaponSkill.Create(player, Type, (Byte)Level);
                            if (WeaponSkill != null)
                            {
                                player.AwardSkill(WeaponSkill, true);
                            }
                        }
                        return;
                    }

                    case "/skill":
                    {
                        UInt16 Type  = UInt16.Parse(Parts[1]);
                        SByte  Level = SByte.Parse(Parts[2]);
                        Magic  Magic = null;

                        if (Level > 9)
                        {
                            Level = 9;
                        }

                        if (Level < -1)
                        {
                            Level = -1;
                        }

                        if (Level == -1)
                        {
                            Magic = player.GetMagicByType(Type);
                            if (Magic != null)
                            {
                                player.DropMagic(Magic, true);
                            }
                        }
                        else
                        {
                            if (!Database.AllMagics.ContainsKey((Type * 10) + Level))
                            {
                                return;
                            }

                            Magic = player.GetMagicByType(Type);
                            if (Magic != null)
                            {
                                player.DropMagic(Magic, true);
                            }

                            Magic = Magic.Create(player, Type, (Byte)Level);
                            if (Magic != null)
                            {
                                player.AwardMagic(Magic, true);
                            }
                        }
                        return;
                    }
                    }


                    #region Game Master
                    if (player.IsGM || player.IsPM)
                    {
                        switch (Parts[0])
                        {
                        case "/ban":     //Ban the specified character
                        {
                            const string USAGE = "USAGE: /ban ${name}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            if (Database.Ban(Parts[1]))
                            {
                                Program.Log("[CRIME] " + Parts[1] + " has been banned by " + player.Name + "!");
                                World.BroadcastMsg(new MsgTalk("SYSTEM", "ALLUSERS", Parts[1] + " has been banned!", Channel.GM, Color.White));

                                String name   = Parts[1];
                                Player target = null;

                                if (World.AllPlayerNames.TryGetValue(name, out target))
                                {
                                    target.Disconnect();
                                }
                            }
                            return;
                        }

                        case "/jail":     // Jail the specified character
                        {
                            const string USAGE = "USAGE: /jail ${name}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            String name = Parts[1];
                            if (Database.SendPlayerToJail(name))
                            {
                                Program.Log("[CRIME] {0} has been sent to jail by {1}!", name, player.Name);
                            }

                            return;
                        }

                        case "/clearinv":     //Delete all items in inventory
                        {
                            Item[] items = null;

                            lock (player.Items)
                            {
                                items = new Item[player.Items.Count];
                                player.Items.Values.CopyTo(items, 0);
                            }

                            foreach (Item item in items)
                            {
                                if (item.Position != 0)
                                {
                                    continue;
                                }

                                player.DelItem(item.Id, true);
                            }
                            return;
                        }

                        case "/rez":     //Help someone to reborn...
                        {
                            const string USAGE = "USAGE: /rez $[name]";

                            if (Parts.Length < 1 || Parts.Length > 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            if (Parts.Length == 1)
                            {
                                if (!player.IsAlive())
                                {
                                    player.Reborn(false);
                                }
                                return;
                            }

                            String name   = Parts[1];
                            Player target = null;

                            if (World.AllPlayerNames.TryGetValue(name, out target))
                            {
                                if (!target.IsAlive())
                                {
                                    target.Reborn(false);
                                }

                                break;
                            }
                            return;
                        }

                        case "/recall":     //Move someone...
                        {
                            const string USAGE = "USAGE: /recall ${name}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            String name   = Parts[1];
                            Player target = null;

                            if (World.AllPlayerNames.TryGetValue(name, out target))
                            {
                                target.Move(player.Map.Id, (UInt16)(player.X + 1), (UInt16)(player.Y + 1));
                            }

                            return;
                        }

                        case "/goto":     //Go to someone...
                        {
                            const string USAGE = "USAGE: /goto ${name}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            String name   = Parts[1];
                            Player target = null;

                            if (World.AllPlayerNames.TryGetValue(name, out target))
                            {
                                player.Move(target.Map.Id, (UInt16)(target.X + 1), (UInt16)(target.Y + 1));
                            }

                            return;
                        }

                        case "/hp":     //Refill the HP to maximum
                        {
                            player.CurHP = player.MaxHP;
                            player.Send(new MsgUserAttrib(player, player.CurHP, MsgUserAttrib.AttributeType.Life));
                            return;
                        }

                        case "/mp":     //Refill the MP to maximum
                        {
                            player.CurMP = player.MaxMP;
                            player.Send(new MsgUserAttrib(player, player.CurMP, MsgUserAttrib.AttributeType.Mana));
                            return;
                        }

                        case "/mm":     //Teleport the player to the specified location
                        {
                            const string USAGE = "USAGE: /mm ${mapid} ${x} ${y}";

                            if (Parts.Length != 4)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            UInt32 mapId = 0;
                            UInt16 x = 0, y = 0;

                            if (!UInt32.TryParse(Parts[1], out mapId) || !UInt16.TryParse(Parts[2], out x) || !UInt16.TryParse(Parts[3], out y))
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            player.Move(UInt32.Parse(Parts[1]), UInt16.Parse(Parts[2]), UInt16.Parse(Parts[3]));
                            return;
                        }

                        case "/gm":     //Talk in the GM channel...
                        {
                            World.BroadcastMsg(player, new MsgTalk(Speaker, "ALLUSERS", Words.Remove(0, 4), Channel.GM, Color.Lime), true);
                            return;
                        }

                        case "/scroll":     //Teleport the player to the specified map
                        {
                            const string USAGE = "USAGE: /scroll {tc,am,dc,mc,bi,pc,ma,arena}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            switch (Parts[1])
                            {
                            case "tc":
                                player.Move(1002, 431, 379);
                                break;

                            case "am":
                                player.Move(1020, 567, 576);
                                break;

                            case "dc":
                                player.Move(1000, 500, 650);
                                break;

                            case "mc":
                                player.Move(1001, 316, 642);
                                break;

                            case "bi":
                                player.Move(1015, 723, 573);
                                break;

                            case "pc":
                                player.Move(1011, 190, 271);
                                break;

                            case "ma":
                                player.Move(1036, 292, 236);
                                break;

                            case "arena":
                                player.Move(1005, 52, 69);
                                break;
                            }
                            return;
                        }
                        }
                    }
                    #endregion
                    #region Project Master
                    if (player.IsPM)
                    {
                        switch (Parts[0])
                        {
                        case "/restart":     //Restart the emulator...
                        {
                            Server.Restart();
                            return;
                        }

                        case "/kill":
                        {
                            const string USAGE = "USAGE: /kill ${name}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            String name   = Parts[1];
                            Player target = null;

                            if (World.AllPlayerNames.TryGetValue(name, out target))
                            {
                                if (target.IsAlive())
                                {
                                    target.Die(null);
                                }
                            }
                            return;
                        }

                        case "/lvl":
                        {
                            const string USAGE = "USAGE: /level ${level}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            Byte level = 0;
                            if (!Byte.TryParse(Parts[1], out level))
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            if (level == 0 || level > (Database.AllLevExp.Count + 1))
                            {
                                return;
                            }

                            player.Level = level;
                            player.Exp   = 0;
                            MyMath.GetLevelStats(player);

                            player.Send(new MsgUserAttrib(player, player.Level, MsgUserAttrib.AttributeType.Level));
                            player.Send(new MsgUserAttrib(player, player.Strength, MsgUserAttrib.AttributeType.Strength));
                            player.Send(new MsgUserAttrib(player, player.Agility, MsgUserAttrib.AttributeType.Agility));
                            player.Send(new MsgUserAttrib(player, player.Vitality, MsgUserAttrib.AttributeType.Vitality));
                            player.Send(new MsgUserAttrib(player, player.Spirit, MsgUserAttrib.AttributeType.Spirit));
                            player.Send(new MsgUserAttrib(player, player.AddPoints, MsgUserAttrib.AttributeType.AddPoints));
                            player.Send(new MsgAction(player, 0, MsgAction.Action.UpLev));
                            return;
                        }

                        case "/job":
                        {
                            const string USAGE = "USAGE: /job ${jobid}";

                            if (Parts.Length != 2)
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            Byte jobid = 0;
                            if (!Byte.TryParse(Parts[1], out jobid))
                            {
                                player.Send(new MsgTalk("SYSTEM", "ALLUSERS", USAGE, Channel.Talk, Color.Red));
                                return;
                            }

                            if (jobid == 0 || jobid % 10 > 5)
                            {
                                return;
                            }

                            player.Profession = jobid;
                            MyMath.GetLevelStats(player);

                            player.Send(new MsgUserAttrib(player, player.Profession, MsgUserAttrib.AttributeType.Profession));
                            player.Send(new MsgUserAttrib(player, player.Strength, MsgUserAttrib.AttributeType.Strength));
                            player.Send(new MsgUserAttrib(player, player.Agility, MsgUserAttrib.AttributeType.Agility));
                            player.Send(new MsgUserAttrib(player, player.Vitality, MsgUserAttrib.AttributeType.Vitality));
                            player.Send(new MsgUserAttrib(player, player.Spirit, MsgUserAttrib.AttributeType.Spirit));
                            player.Send(new MsgUserAttrib(player, player.AddPoints, MsgUserAttrib.AttributeType.AddPoints));
                            return;
                        }

                        case "/reallot":
                        {
                            MyMath.GetLevelStats(player);
                            player.Send(new MsgUserAttrib(player, player.Strength, MsgUserAttrib.AttributeType.Strength));
                            player.Send(new MsgUserAttrib(player, player.Agility, MsgUserAttrib.AttributeType.Agility));
                            player.Send(new MsgUserAttrib(player, player.Vitality, MsgUserAttrib.AttributeType.Vitality));
                            player.Send(new MsgUserAttrib(player, player.Spirit, MsgUserAttrib.AttributeType.Spirit));
                            player.Send(new MsgUserAttrib(player, player.AddPoints, MsgUserAttrib.AttributeType.AddPoints));
                            return;
                        }

                        case "/xp":
                        {
                            player.XP = 99;
                            return;
                        }

                        case "/money":
                        {
                            UInt32 money = UInt32.Parse(Parts[1]);
                            if (money < 0)
                            {
                                money = 0;
                            }

                            if (money > Player._MAX_MONEYLIMIT)
                            {
                                money = Player._MAX_MONEYLIMIT;
                            }

                            player.Money = money;
                            player.Send(new MsgUserAttrib(player, player.Money, MsgUserAttrib.AttributeType.Money));
                            return;
                        }

                        case "/item":
                        {
                            if (player.ItemInInventory() > 39)
                            {
                                return;
                            }

                            Int32  itemId = -1;
                            String name   = Parts[1].Replace("'", "`");

                            foreach (Item.Info info in Database.AllItems.Values)
                            {
                                if (info.Name.ToLower() == name.ToLower())
                                {
                                    itemId = info.ID;
                                    break;
                                }
                            }

                            if (itemId < 0)
                            {
                                return;
                            }

                            itemId = (itemId - (itemId % 10)) + Byte.Parse(Parts[2]);

                            Item item = Item.Create(player.UniqId, 0, itemId, Byte.Parse(Parts[3]), Byte.Parse(Parts[4]), Byte.Parse(Parts[5]), Byte.Parse(Parts[6]), Byte.Parse(Parts[7]), 2, 0, ItemHandler.GetMaxDura(itemId), ItemHandler.GetMaxDura(itemId));
                            player.AddItem(item, true);
                            return;
                        }

                        case "/prof":
                        {
                            UInt16      Type        = UInt16.Parse(Parts[1]);
                            SByte       Level       = SByte.Parse(Parts[2]);
                            UInt32      Exp         = 0;
                            WeaponSkill WeaponSkill = null;

                            if (Level > Database.AllWeaponSkillExp.Count)
                            {
                                Level = (SByte)Database.AllWeaponSkillExp.Count;
                            }

                            if (Level < -1)
                            {
                                Level = -1;
                            }

                            if (Level == -1)
                            {
                                WeaponSkill = player.GetWeaponSkillByType(Type);
                                if (WeaponSkill != null)
                                {
                                    player.DropSkill(WeaponSkill, true);
                                }
                            }
                            else
                            {
                                WeaponSkill = player.GetWeaponSkillByType(Type);
                                if (WeaponSkill != null)
                                {
                                    player.DropSkill(WeaponSkill, true);
                                }

                                WeaponSkill = WeaponSkill.Create(player, Type, (Byte)Level);
                                if (WeaponSkill != null)
                                {
                                    player.AwardSkill(WeaponSkill, true);
                                }
                            }
                            return;
                        }

                        case "/skill":
                        {
                            UInt16 Type  = UInt16.Parse(Parts[1]);
                            SByte  Level = SByte.Parse(Parts[2]);
                            Magic  Magic = null;

                            if (Level > 9)
                            {
                                Level = 9;
                            }

                            if (Level < -1)
                            {
                                Level = -1;
                            }

                            if (Level == -1)
                            {
                                Magic = player.GetMagicByType(Type);
                                if (Magic != null)
                                {
                                    player.DropMagic(Magic, true);
                                }
                            }
                            else
                            {
                                if (!Database.AllMagics.ContainsKey((Type * 10) + Level))
                                {
                                    return;
                                }

                                Magic = player.GetMagicByType(Type);
                                if (Magic != null)
                                {
                                    player.DropMagic(Magic, true);
                                }

                                Magic = Magic.Create(player, Type, (Byte)Level);
                                if (Magic != null)
                                {
                                    player.AwardMagic(Magic, true);
                                }
                            }
                            return;
                        }
                        }
                    }
                    #endregion
                    player.SendSysMsg(StrRes.STR_COMMAND_NOT_FOUND);
                    return;
                }

                switch (Channel)
                {
                case Channel.Normal:
                {
                    World.BroadcastRoomMsg(player, this, false);
                    break;
                }

                case Channel.Private:
                {
                    if (World.AllPlayerNames.ContainsKey(Hearer))
                    {
                        World.AllPlayerNames[Hearer].Send(new MsgTalk(player, Hearer, Words, Channel.Private, Color.White));
                    }
                    else
                    {
                        player.SendSysMsg(StrRes.STR_NOT_ONLINE);
                    }
                    break;
                }

                case Channel.Team:
                {
                    if (player.Team == null)
                    {
                        break;
                    }

                    World.BroadcastTeamMsg(player, this, false);
                    break;
                }

                case Channel.Syndicate:
                {
                    if (player.Syndicate == null)
                    {
                        break;
                    }

                    World.BroadcastSynMsg(player, this, false);
                    break;
                }

                case Channel.Friend:
                {
                    World.BroadcastFriendMsg(player, this);
                    break;
                }

                case Channel.Ghost:
                {
                    if (player.Screen == null)
                    {
                        return;
                    }

                    var players = from entity in player.Screen.mEntities.Values where entity.IsPlayer() select(Player) entity;
                    foreach (Player target in players)
                    {
                        if (!target.IsAlive() || (target.Profession >= 132 && target.Profession <= 135))
                        {
                            target.Send(this);
                        }
                    }
                    break;
                }

                case Channel.Serve:
                {
                    var players = from entity in World.AllPlayers.Values where (entity.IsGM || entity.IsPM) select entity;
                    foreach (Player target in players)
                    {
                        target.Send(this);
                    }
                    break;
                }

                case Channel.CryOut:
                {
                    if (player.Booth == null)
                    {
                        break;
                    }

                    player.Booth.SetCryOut(Words);
                    break;
                }

                case Channel.SynAnnounce:
                {
                    if (player.Syndicate == null)
                    {
                        break;
                    }

                    if (player.Syndicate.Leader.Id != player.UniqId)
                    {
                        break;
                    }

                    player.Syndicate.Announce = Words;
                    World.BroadcastSynMsg(player.Syndicate, this);
                    break;
                }

                case Channel.MsgTrade:
                {
                    MessageBoard.MessageInfo message =
                        World.TradeBoard.GetMsgInfoByAuthor(player.Name);

                    World.TradeBoard.Delete(message);
                    World.TradeBoard.Add(player.Name, Words);
                    break;
                }

                case Channel.MsgFriend:
                {
                    MessageBoard.MessageInfo message =
                        World.FriendBoard.GetMsgInfoByAuthor(player.Name);

                    World.FriendBoard.Delete(message);
                    World.FriendBoard.Add(player.Name, Words);
                    break;
                }

                case Channel.MsgTeam:
                {
                    MessageBoard.MessageInfo message =
                        World.TeamBoard.GetMsgInfoByAuthor(player.Name);

                    World.TeamBoard.Delete(message);
                    World.TeamBoard.Add(player.Name, Words);
                    break;
                }

                case Channel.MsgSyn:
                {
                    MessageBoard.MessageInfo message =
                        World.SynBoard.GetMsgInfoByAuthor(player.Name);

                    World.SynBoard.Delete(message);
                    World.SynBoard.Add(player.Name, Words);
                    break;
                }

                case Channel.MsgOther:
                {
                    MessageBoard.MessageInfo message =
                        World.OtherBoard.GetMsgInfoByAuthor(player.Name);

                    World.OtherBoard.Delete(message);
                    World.OtherBoard.Add(player.Name, Words);
                    break;
                }

                case Channel.MsgSystem:
                {
                    MessageBoard.MessageInfo message =
                        World.SystemBoard.GetMsgInfoByAuthor(player.Name);

                    World.SystemBoard.Delete(message);
                    World.SystemBoard.Add(player.Name, Words);
                    break;
                }

                default:
                {
                    sLogger.Error("Channel {0} is not implemented for MsgTalk.", (UInt16)Channel);
                    break;
                }
                }
            }
            catch (Exception exc) { sLogger.Error(exc); }
        }
Ejemplo n.º 30
0
 /// <summary>
 ///     Sets the skill value for a weapon skill of this <see cref="ICharacter" />.
 /// </summary>
 /// <param name="weaponSkill">The weapon skill type.</param>
 /// <param name="value">The new weapon skill value.</param>
 public void SetSkillWeapon(WeaponSkill weaponSkill, int value)
 {
     this.orgCharacter.SetSkillWeapon(weaponSkill, value);
     this.OnSetSkillWeapon?.Invoke(this, new NotifyAboutCallEventArgs <WeaponSkill, int>(weaponSkill, value));
 }