public void ShowUnequippedItem(ModMount mount) { StatPack pack = new StatPack(); PowerupAttachable otherItem = controller.GetCar().GetComponent <PowerupManager>().GetMod(mount); if (otherItem == null) { return; } StatPack otherPack = otherItem.GetComponent <PowerupStats>().GetPack(); ShowStatBars(pack, otherPack); }
public void ShowUnequippedItem(WeaponMount mount) { StatPack pack = new StatPack(); PowerupAttachable otherItem = controller.GetCar().GetComponent <PowerupManager>().GetWeapon(mount); if (otherItem == null) { return; } StatPack otherPack = otherItem.GetComponent <PowerupStats>().GetPack(); ShowStatBars(pack, otherPack); damageSliders.ShowPotentialWeapon(mount, controller.GetCar().GetComponent <PowerupManager>().baseDamage); }
public PowerupManager Attach(PowerupAttachable attachment, AttachType aType) { if (attachment.isWeapon) { WeaponMount slot = attachment.weaponLocation; List <Joint> attachJoints = new List <Joint>(); List <GameObject> newWeapons = new List <GameObject>(); if (equippedWeapons.ContainsKey(slot)) { equippedWeapons[slot].GetComponent <PowerupMain>().UnEquip(); } equippedWeapons[slot] = attachment; if (physicalWeapons.ContainsKey(slot)) { foreach (GameObject oldWeapon in physicalWeapons[slot]) { Destroy(oldWeapon); } } switch (slot) { case WeaponMount.Grill: attachJoints.Add(Joint.FBumper); break; case WeaponMount.Hitch: attachJoints.Add(Joint.RBumper); break; case WeaponMount.Doors: attachJoints.Add(Joint.LDoor); attachJoints.Add(Joint.RDoor); break; case WeaponMount.Roof: attachJoints.Add(Joint.Center); break; case WeaponMount.Wheels: attachJoints.Add(Joint.FLTire); attachJoints.Add(Joint.FRTire); attachJoints.Add(Joint.BLTire); attachJoints.Add(Joint.BRTire); break; } foreach (Joint joint in attachJoints) { FixedJoint2D tJoint = joints[joint]; PowerupAttachable newAttachment = Instantiate(attachment.gameObject).GetComponent <PowerupAttachable>(); newAttachment.GetComponent <PowerupMain>().SetManager(this); newWeapons.Add(newAttachment.gameObject); newAttachment.SetAnchor(joint); if (joint == Joint.BLTire || joint == Joint.FLTire || joint == Joint.LDoor) { newAttachment.gameObject.transform.localScale = new Vector3(-1, 1, 1); newAttachment.gameObject.transform.position = gameObject.transform.position + new Vector3(tJoint.anchor.x, tJoint.anchor.y, 0f) - new Vector3(newAttachment.anchorOverride.x, newAttachment.anchorOverride.y, 0); } else { newAttachment.gameObject.transform.position = gameObject.transform.position + new Vector3(tJoint.anchor.x, tJoint.anchor.y, 0f) + new Vector3(newAttachment.anchorOverride.x, newAttachment.anchorOverride.y, 0); } switch (aType) { case AttachType.Spring: tJoint.connectedBody = newAttachment.gameObject.GetComponent <Rigidbody2D>(); tJoint.connectedAnchor = newAttachment.anchorOverride; tJoint.enabled = true; break; case AttachType.Fixed: default: newAttachment.gameObject.transform.parent = gameObject.transform; break; } } physicalWeapons[slot] = newWeapons; } else { if (equippedMods.ContainsKey(attachment.modLocation)) { equippedMods[attachment.modLocation].GetComponent <PowerupMain>().UnEquip(); } equippedMods[attachment.modLocation] = attachment; } attachment.GetComponent <PowerupMain>().Equip(); ReCalcStats(); return(this); }