Esempio n. 1
0
        /// <summary>
        /// 右手に装備する
        /// </summary>
        /// <param name="bagIndex">バッグ内のIndex</param>
        public bool EquipRightHand(int bagIndex)
        {
            Item item = bag[bagIndex];

            if (!(item is WeaponItem))             //エラー対策
            {
                return(false);
            }

            WeaponItem.WeaponType type = ((WeaponItem)item).GetWeaponType();
            if (type == WeaponItem.WeaponType.Bow) //右手は弓を装備できない
            {
                return(false);
            }


            if (leftHand != null && leftHand.GetWeaponType() == WeaponItem.WeaponType.Bow) //弓は同時装備できない
            {
                bag.Add(leftHand);                                                         //バッグに戻す
                leftHand = null;
            }

            if (rightHand != null)                 //装備している状態
            {
                bag.Add(rightHand);                //バッグに戻す
            }

            rightHand = (WeaponItem)item;          //装備する
            bag.RemoveAt(bagIndex);
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// ステータスを加算して返す
        /// </summary>
        /// <param name="power">攻撃力</param>
        /// <param name="defence">防御力</param>
        /// <param name="weight">重量</param>
        public void GetStatus(ref int power, ref int defence, ref float weight)
        {
            power   = 0;
            defence = 0;
            weight  = 0;

            foreach (Item i in bag)               //ItemListの重量計算
            {
                if (i != null)
                {
                    if (i is ConsumptionItem)
                    {
                        weight += i.GetItemWeight() * ((ConsumptionItem)i).GetStack();
                    }
                    else
                    {
                        weight += i.GetItemWeight();
                    }
                }
            }

            foreach (ProtectionItem p in armor)   //防具の計算
            {
                if (p == null)
                {
                    continue;
                }
                power   += p.GetPower();
                defence += p.GetDefense();
                weight  += p.GetItemWeight() * 1.2f;
            }

            if (leftHand != null)                 //左手のものを計算
            {
                float increaseRate = 1.2f;
                if (leftHand.GetWeaponType() == WeaponItem.WeaponType.Dagger)
                {
                    increaseRate = -1.2f;
                }

                power   += leftHand.GetPower();
                defence += leftHand.GetDefense();
                weight  += leftHand.GetItemWeight() * increaseRate;
            }

            if (rightHand != null)
            {
                                                 //右手のものを計算
                {
                    float increaseRate = 1.2f;

                    if (rightHand.GetWeaponType() == WeaponItem.WeaponType.Dagger)
                    {
                        increaseRate = -1.2f;
                    }

                    power   += rightHand.GetPower();
                    defence += rightHand.GetDefense();
                    weight  += rightHand.GetItemWeight() * increaseRate;
                }
            }

            if (arrow != null)
            {
                ArrowEffect effect = (ArrowEffect)arrow.GetItemEffect();
                power  += effect.GetPower();
                weight += arrow.GetItemWeight() * arrow.GetStack();
            }

            if (accessary != null)
            {
                weight += accessary.GetItemWeight();
            }

            if (weight < 0)                        //ダガーのスピード増加に対応
            {
                weight = 0;
            }
        }