using UnityEngine;
using System.Collections.Generic;
public enum EquipmentType
{
Helmet,
Chest,
Gloves,
Boots,
Weapon1,
Weapon2,
Accessory1,
Accessory2,
Shoulder,
Belt,
Trinket1,
Trinket2,
}
namespace Armor
{
[System.Serializable]
public class ArmorSystem : MonoBehaviour
{
[Header("Stats")]
public int strength;
public int intellect;
public int vitality;
public int agility;
Item item;
[Header("Damage")]
public float fireDamage;
public float frostDamage;
public float shadowDamage;
public string itemName;
[Header("ItemStats")]
public float curDurability;
public float maxDurability;
public float durabilityDecay;
public float moveSpeedDecay;
public float movespeed;
public float decay;
public float movsped;
[SerializeField]
EquipmentType EquipmentType;
[Header("Resistance")]
public float fireResistance;
public float frostResistance;
public float shadowResistance;
[Header("DamageReduction")]
public float resistance;
public float damage;
public float damageReduction;
public float armor;
public int ItemLevel;
public int ItemRarity;
[Header("Currency")]
public float money;
public float repairCost;
[Header("Bools")]
bool moveDecay;
public bool inDestructible;
public string ItemQualityname;
public float RepairCost
{
get { return repairCost; }
set { repairCost = value; }
}
public float Decay
{
get { return decay; }
set { decay = value; }
}
public void Awake()
{
ChooseItemType();
inDestructible = (Random.value < 0.1);
ItemRarity = Random.Range(0, 4);
ItemLevel = Random.Range(0, 300);
ArmorQuality();
SetDurability();
Decay = maxDurability / 10000;
curDurability -= Decay;
curDurability -= moveSpeedDecay;
repairCost = curDurability - maxDurability;
ItemLevelStats();
money = 4000;
}
public void inDestructibled()
{
moveSpeedDecay = 0;
decay = 0;
}
void ArmorQuality()
{
if(ItemRarity == 0)
{
ItemQualityname = "Trash";
}
if(ItemRarity == 1)
{
ItemQualityname = "Epic";
}
if (ItemRarity == 2)
{
ItemQualityname = "Rare";
}
if (ItemRarity == 3)
{
ItemQualityname = "Uncommon";
}
if (ItemRarity == 4)
{
ItemQualityname = "Common";
}
}
public void ChooseItemType()
{
int randomTemp = Random.Range(1, 4);
if(randomTemp == 1)
{
EquipmentType = EquipmentType.Helmet;
}
if (randomTemp == 2)
{
EquipmentType = EquipmentType.Chest;
}
if (randomTemp == 3)
{
EquipmentType = EquipmentType.Gloves;
}
if (randomTemp == 4)
{
EquipmentType = EquipmentType.Boots;
}
}
public void CreateArmor()
{
}
public void SetDurability()
{
maxDurability = 100;
curDurability = 100;
}
public void Reduction()
{
damageReduction = armor - damage;
}
public void Update()
{
Repair();
repairCost = repairCost + decay;
if (inDestructible == true)
{
inDestructibled();
}
if(inDestructible == false)
{
ArmorDecay();
}
}
public void ArmorDecay()
{
decay = maxDurability / 10000;
curDurability -= decay;
curDurability -= moveSpeedDecay;
if (movespeed > 0)
{
moveDecay = true;
moveSpeedDecay = 1;
}
else
{
moveDecay = false;
moveSpeedDecay = 0;
}
}
public void ItemLevelStats()
{
strength = 1;
intellect = 1;
vitality = 1;
agility = 1;
strength = (ItemLevel * strength) / 5;
agility = (ItemLevel * agility) / 5;
intellect = (ItemLevel * intellect) / 5;
vitality = (ItemLevel * vitality) / 5;
}
public void ClassStatBonus()
{
}
public void Resistance()
{
fireResistance -= fireDamage;
frostResistance -= frostDamage;
shadowResistance -= shadowDamage;
}
public void Broken()
{
if (curDurability <= 0)
{
Debug.Log(itemName + " is broken!");
}
}
public void Repair()
{
if (Input.GetKeyDown(KeyCode.R))
{
curDurability = maxDurability;
money -= repairCost;
repairCost = 0;
}
}
}
}
如何使另一个脚本继承当前脚本中的变量。我无法将非monoBehaviour不能继承的脚本附加到GameObject上,例如武器...
答案 0 :(得分:1)
只需使脚本继承正常的 ArmorSystem ,它便会继承 Monobehavior 。最好将 ArmorSystem 中的所有功能都写入虚拟。
例如:
namespace Armor
{
[System.Serializable]
public class HeavyAmor : ArmorSystem
{
}