public static int GetValue(Mobile m, ArmorAttribute attribute) { int value = 0; foreach (var item in m.GetEquippedItems()) { if (item is IArmor) { ArmorAttributes attrs = ((IArmor)item).ArmorAttributes; if (attrs != null) { value += attrs[attribute]; } } else if (item is ICloth) { ArmorAttributes attrs = ((ICloth)item).ClothingAttributes; if (attrs != null) { value += attrs[attribute]; } } } return(value); }
void OnCollisionEnter(Collision collision) { var name = collision.collider.name; Debug.Log("Name is " + name); /*撞到装甲的话,计算入射角*/ if (collision.transform.GetComponent <ArmorAttribute>() != null) { Vector3 ShellDirection = this.GetComponent <GetDirection>().Direction; Vector3 ArmorDirection = collision.collider.GetComponent <GetDirection>().Direction; float fenzi, fenmu; fenzi = (ShellDirection.x * ArmorDirection.x) + (ShellDirection.y * ArmorDirection.y) + (ShellDirection.z * ArmorDirection.z); fenmu = (Mathf.Sqrt(Mathf.Pow(ShellDirection.x, 2) + Mathf.Pow(ShellDirection.y, 2) + Mathf.Pow(ShellDirection.z, 2))) * (Mathf.Sqrt(Mathf.Pow(ArmorDirection.x, 2) + Mathf.Pow(ArmorDirection.y, 2) + Mathf.Pow(ArmorDirection.z, 2))); float AOIcos = -(fenzi / fenmu); ArmorAttribute ArmorThickness = collision.collider.GetComponent <ArmorAttribute>(); float RealThickness = ArmorThickness.thickness / Mathf.Abs(AOIcos); MesofAP chuangshenduqu = this.GetComponent <MesofAP>(); float Realchuangshen = chuangshenduqu.chuangshen; if (Realchuangshen >= RealThickness) { //扣血,使用getcomponment使所撞车辆扣血 //Debug.Log("Destroy"); collision.collider.transform.GetComponentInParent <PartAttribute>().aiHealthy -= 300; //Debug.Log("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"); } else { Debug.Log("Nothing happen"); } Debug.Log("等效" + RealThickness); Destroy(this.gameObject); } Destroy(this.gameObject); }
void OnCollisionEnter(Collision collision) { var name = collision.collider.name; Debug.Log("Name is " + name); if (collision.transform.GetComponent <ArmorAttribute>() != null) { /*计算入射角*/ Vector3 ShellDirection = this.GetComponent <GetDirection>().Direction; Vector3 ArmorDirection = collision.collider.GetComponent <GetDirection>().Direction; float fenzi, fenmu; fenzi = (ShellDirection.x * ArmorDirection.x) + (ShellDirection.y * ArmorDirection.y) + (ShellDirection.z * ArmorDirection.z); fenmu = (Mathf.Sqrt(Mathf.Pow(ShellDirection.x, 2) + Mathf.Pow(ShellDirection.y, 2) + Mathf.Pow(ShellDirection.z, 2))) * (Mathf.Sqrt(Mathf.Pow(ArmorDirection.x, 2) + Mathf.Pow(ArmorDirection.y, 2) + Mathf.Pow(ArmorDirection.z, 2))); float AOIcos = -(fenzi / fenmu); ArmorAttribute ArmorThickness = collision.collider.GetComponent <ArmorAttribute>(); float RealThickness = ArmorThickness.thickness / Mathf.Abs(AOIcos); MesofHE chuangshenduqu = this.GetComponent <MesofHE>(); float Realchuangshen = chuangshenduqu.chuangshen; if (Realchuangshen >= RealThickness) { //Debug.Log("HE击穿"); collision.collider.transform.GetComponentInParent <PartAttribute>().aiHealthy -= 500; } else { //Debug.Log("计算伤害");//纸面伤害/2 - 击中处装甲值 collision.collider.transform.GetComponentInParent <PartAttribute>().aiHealthy -= 250 - ArmorThickness.thickness; } Debug.Log("等效" + RealThickness); } Destroy(this.gameObject); }
public void InitializeAttributesStats(ArmorAttribute[] attributes, SkillEffect[] effects) { //characterTransform = Player.Instance.avatarObject.transform; skillEffects = effects; armorAttributes = attributes; }
private static void ApplyAttribute( ArmorAttributes attrs, int min, int max, ArmorAttribute attr, int low, int high, int scale ) { attrs[attr] = Scale( min, max, low / scale, high / scale ) * scale; }
private static void ApplyAttribute( ArmorAttributes attrs, int min, int max, ArmorAttribute attr, int low, int high ) { attrs[attr] = Scale( min, max, low, high ); }
private static void ApplyAttribute(ArmorAttributes attrs, int min, int max, ArmorAttribute attr, int low, int high, int scale) { attrs[attr] = Scale(min, max, low / scale, high / scale) * scale; }
private static void ApplyAttribute(ArmorAttributes attrs, int min, int max, ArmorAttribute attr, int low, int high) { attrs[attr] = Scale(min, max, low, high); }
public OtherArmorAttrInfo(ArmorAttribute attr, int min, int max) { m_Attribute = attr; m_MinIntensity = min; m_MaxIntensity = max; }
public int this[ArmorAttribute attribute] { get { return(GetValue((int)attribute)); } set { SetValue((int)attribute, value); } }