public bool EjectPart(CombotPart part) { if (part == null) { return(false); } Instantiate( gameManager.GetPrefab("Explosion"), part.transform.position, part.transform.rotation, part.transform.parent ); Instantiate( gameManager.GetPrefab("Explosion"), part.transform.position, part.transform.rotation, part.transform ); part.transform.SetParent(null); Rigidbody[] rbs = part.transform.GetComponentsInChildren <Rigidbody>(); foreach (Rigidbody rb in rbs) { rb.useGravity = true; rb.isKinematic = false; } Destroy(part.GetComponent <CharacterJoint>()); part.GetComponent <Rigidbody>().AddForce(Vector3.up * 10, ForceMode.Acceleration); if (part.PartType == CombotPart.Type.Legs || part.PartType == CombotPart.Type.Head) { unitControl.Die(Vector3.zero); } animator.Rebind(); return(true); }
public void SetUp(SkeletonData setUpData) { root = setUpData.rootTransform; rightHand = setUpData.rightHand; leftHand = setUpData.leftHand; leftArmPart = setUpData.leftArmPart; leftArmPart.Skeleton = this; rightArmPart = setUpData.rightArmPart; rightArmPart.Skeleton = this; leftLegPart = setUpData.leftLegPart; leftLegPart.Skeleton = this; rightLegPart = setUpData.rightLegPart; rightLegPart.Skeleton = this; headPart = setUpData.headPart; headPart.Skeleton = this; torsoPart = setUpData.torsoPart; torsoPart.Skeleton = this; foreach (JointData joint in setUpData.joints) { SetUpJoint(joint, setUpData.layerName); } unitControl = GetComponent <UnitControl>(); animator = GetComponent <Animator>(); gameManager = GameManager.Instance; }
public void UnitHit(UnitControl unitControl, CombotPart part) { if (unitControl.IsPlayer) { uiControl.AddDamageUI(part); } }
public void AddDamageUI(CombotPart part) { if (!damageList.IsDamageListFull) { DamageEntry entry = damageList.AddEntry(part.name); part.AddDamageMarker(entry); } }
public float HitPart(string partName, DamageInfo info) { CombotPart part = GetPart(partName); if (part != null) { return(part.AbsorbDamage(info)); } return(info.damageAmount); }
void InitializeParts() { foreach (GameObject part in partsToInitialize) { CombotPart partControl = part.GetComponent <CombotPart>(); if (partControl) { partControl.Init(unitControl); } } }
void AddLegs() { GameObject part = Instantiate(gameManager.GetCombotPart(legsPrefab)) as GameObject; part.transform.position = transform.position; part.transform.rotation = transform.rotation; part.transform.localScale = transform.localScale; Transform leftSkel = part.transform.Find("LeftUpperLeg_Skel"); if (!leftSkel) { Debug.Log("Can't Find LeftUpperLeg_Skel"); } leftSkel.SetParent(leftLegAttach.parent); Destroy(leftLegAttach.gameObject); Transform rightSkel = part.transform.Find("RightUpperLeg_Skel"); rightSkel.SetParent(rightLegAttach.parent); Destroy(rightLegAttach.gameObject); Transform partGeo = part.transform.Find("Legs_Geo"); partGeo.SetParent(geoGroup); CombotPart partSetup = part.GetComponent <CombotPart>(); CombotPart rightControl = rightSkel.gameObject.AddComponent <CombotPart>(); CombotPart leftControl = leftSkel.gameObject.AddComponent <CombotPart>(); rightControl.Setup( unitControl, CombotPart.Type.Legs, partSetup.maxHealth, partSetup.armor ); leftControl.Setup( unitControl, CombotPart.Type.Legs, partSetup.maxHealth, partSetup.armor ); leftControl.SetPair(rightControl); rightControl.SetPair(leftControl); Destroy(part); partsToInitialize.Add(rightControl); partsToInitialize.Add(leftControl); }
void AddHead() { GameObject part = Instantiate(gameManager.GetCombotPart(headPrefab)) as GameObject; part.transform.position = transform.position; part.transform.rotation = transform.rotation; part.transform.localScale = transform.localScale; Transform partSkel = part.transform.Find("Head_Skel"); if (!partSkel) { Debug.Log("Can't Find Head_Skel"); } if (!headAttach) { Debug.Log("Can't Find headAttach"); } partSkel.SetParent(headAttach.parent); partSkel.SetAsFirstSibling(); Destroy(headAttach.gameObject); Transform partGeo = part.transform.Find("Head_Geo"); partGeo.SetParent(geoGroup); CombotPart partSetup = part.GetComponent <CombotPart>(); CombotPart partControl = partSkel.gameObject.AddComponent <CombotPart>(); partControl.Setup( unitControl, CombotPart.Type.Head, partSetup.maxHealth, partSetup.armor ); Destroy(part); partsToInitialize.Add(partControl); }
void AddTorso() { GameObject part = Instantiate(gameManager.GetCombotPart(torsoPrefab)) as GameObject; part.transform.position = transform.position; part.transform.rotation = transform.rotation; part.transform.localScale = transform.localScale; Transform rootSkel = part.transform.Find("Hips_Skel"); rootSkel.SetParent(rootMotion, false); leftLegAttach = rootSkel.transform.Find("LeftUpperLeg_Skel"); rightLegAttach = rootSkel.transform.Find("RightUpperLeg_Skel"); leftArmAttach = rootSkel.transform.Find("Spine_Skel/Torso_Skel/LeftClav_Skel/LeftUpperArm_Skel"); rightArmAttach = rootSkel.transform.Find("Spine_Skel/Torso_Skel/RightClav_Skel/RightUpperArm_Skel"); headAttach = rootSkel.transform.Find("Spine_Skel/Torso_Skel/Neck_Skel/Head_Skel"); Transform partGeo = part.transform.Find("Torso_Geo"); partGeo.GetComponent <Renderer>().material.color = combotColor; partGeo.SetParent(geoGroup, false); unitControl.Torso = rootSkel.transform.Find("Spine_Skel/Torso_Skel"); CombotPart partSetup = part.GetComponent <CombotPart>(); CombotPart partControl = rootSkel.gameObject.AddComponent <CombotPart>(); partControl.Setup( unitControl, CombotPart.Type.Torso, partSetup.maxHealth, partSetup.armor ); Destroy(part); partsToInitialize.Add(partControl); }
public void SetPair(CombotPart pair) { partPair = pair; }