// Use this for initialization void Awake() { myCamera = GetComponentInChildren <CameraController>(); inventory = GetComponent <Inventory>(); armPart = GetComponentInChildren <ArmPart>(); torsoPart = GetComponentInChildren <TorsoPart>(); legPart = GetComponentInChildren <LegPart>(); AddInitialItems(new GameObject[3] { armPart.gameObject, torsoPart.gameObject, legPart.gameObject }); currHp = torsoPart.maxHp; currStamina = torsoPart.maxStamina; uiBars = GetComponent <HandleUIBars>(); uiBars.UpdateBarMaxValue(0, torsoPart.maxHp); uiBars.UpdateBarMaxValue(1, torsoPart.maxStamina); uiBars.UpdateBarValue(0, currHp); uiBars.UpdateBarValue(1, currStamina); startRegeningStamina = false; timerRestDelay = 0; armPart.ArmsAddedToBody(this); CanAttack = true; }
public GameObject BuildCharacter(GameObject characterContainer, PartsManager caller = null) { SetEquippedUsingIndex(equip.equippedParts); if (currentTorsoPrefab == null) { return(null); } GameObject ad = Instantiate(currentTorsoPrefab, characterContainer.transform, false); ad.transform.localPosition = Vector3.zero; if (caller != null) { caller.TorsoEquipped = ad.GetComponent <TorsoPart>(); } TorsoPart parent = ad.GetComponent <TorsoPart>(); if (currentHeadPrefab != null) { GameObject adding = Instantiate(currentHeadPrefab, parent.neckForHead.transform, false); adding.transform.localPosition = Vector3.zero; if (caller != null) { caller.headEquipped = adding.GetComponent <ItemPart>(); } } if (currentLeftArmPrefab != null) { GameObject adding = Instantiate(currentLeftArmPrefab, parent.LeftArmUpper.transform, false); ArmPart armPart = adding.GetComponent <ArmPart>(); armPart.EquipArm(parent, parent.LeftArmUpper, parent.LeftArmFore, parent.LeftArmHand); if (caller != null) { caller.leftArmEquipped = armPart; } } if (currentRightArmPrefab != null) { GameObject adding = Instantiate(currentRightArmPrefab, parent.RightArmUpper.transform, false); ArmPart armPart = adding.GetComponent <ArmPart>(); armPart.EquipArm(parent, parent.RightArmUpper, parent.RightArmFore, parent.RightArmHand); if (caller != null) { caller.rightArmEquipped = armPart; } } if (currentLeftLegPrefab != null) { GameObject adding = Instantiate(currentLeftLegPrefab, parent.LeftUpperThigh.transform, false); LegPart legPart = adding.GetComponent <LegPart>(); legPart.EquipLeg(parent.LeftUpperThigh, parent.Leftshin, parent.LefttAnkle, parent.LeftFoot); if (caller != null) { caller.leftLegEquipped = legPart; } } if (currentRightLegPrefab != null) { GameObject adding = Instantiate(currentRightLegPrefab, parent.RightUpperThigh.transform, false); LegPart legPart = adding.GetComponent <LegPart>(); legPart.EquipLeg(parent.RightUpperThigh, parent.Rightshin, parent.RightAnkle, parent.RightFoot); if (caller != null) { caller.rightLegEquipped = legPart; } } if (parent.bodyType == BodyType.FourArm) { Debug.Log("Four"); if (currentRightArmPrefab != null) { GameObject adding = Instantiate(currentRightArmPrefab, parent.LowerRightArmUpper.transform, false); ArmPart armPart = adding.GetComponent <ArmPart>(); armPart.EquipArm(parent, parent.LowerRightArmUpper, parent.LowerRightArmFore, parent.LowerRightArmHand); } if (currentLeftArmPrefab != null) { GameObject adding = Instantiate(currentLeftArmPrefab, parent.LowerLeftArmUpper.transform, false); ArmPart armPart = adding.GetComponent <ArmPart>(); armPart.EquipArm(parent, parent.LowerLeftArmUpper, parent.LowerLeftArmFore, parent.LowerLeftArmHand); } } return(ad); }
public void EquipArm(TorsoPart torso, GameObject upperArmSpot, GameObject foreArmSpot, GameObject handSpot) { upperArmSpot.transform.localScale = Scale; transform.SetParent(upperArmSpot.transform, false); if (torso.bodyType != BodyType.FourArm) { foreArm.transform.SetParent(foreArmSpot.transform, false); hand.transform.SetParent(handSpot.transform, false); foreArm.transform.localPosition = Vector3.zero; foreArm.transform.localRotation = Quaternion.identity; hand.transform.localPosition = Vector3.zero; hand.transform.localRotation = Quaternion.identity; } if (FourFoot) { foot.SetActive(true); FourFoot.SetActive(false); } if (torso.bodyType == BodyType.FourLeg) { transform.localScale += new Vector3(0, .6f, 0); foreArm.transform.localScale += new Vector3(0, .6f, 0); hand.transform.rotation = new Quaternion(0, 20, -70, 0); foreArm.transform.localPosition += new Vector3(0, .2f, 0); hand.transform.localPosition += new Vector3(0, -.15f, 0); if (FourFoot) { FourFoot.SetActive(true); foot.SetActive(false); } if (armType == ArmType.FourLeg) { foreArm.transform.localPosition += new Vector3(-0.036f, -0.07f, 0.045f); } } if (textureMaterial) { foreArm.GetComponentInChildren <Renderer>().material = textureMaterial; if (FourFoot && FourFoot.gameObject.activeSelf) { foreach (Renderer item in FourFoot.GetComponentsInChildren <Renderer>()) { item.material = textureMaterial; } } else { hand.GetComponentInChildren <Renderer>().material = textureMaterial; } } }
internal void DamageSet(SetFeedback setFeedback) { if (!body) { body = FindObjectOfType <TorsoPart>(); } timer = 3; switch (setFeedback) { case SetFeedback.EnemyHit: body.Animate(Animations.Attack); PlaySound(setFeedback); foreach (ParticleSystem item in enemyhitParticle) { item.Play(); } break; case SetFeedback.EnemyCrit: body.Animate(Animations.Attack); PlaySound(setFeedback); foreach (ParticleSystem item in enemycritParticle) { item.Play(); } break; case SetFeedback.PlayerHit: body.Animate(Animations.Hurt); PlaySound(setFeedback); foreach (ParticleSystem item in playerhitParticle) { item.Play(); } break; case SetFeedback.PlayerDodged: PlaySound(setFeedback); foreach (ParticleSystem item in enemymissedParticle) { item.Play(); } break; case SetFeedback.PlayerMissed: body.Animate(Animations.Hurt); PlaySound(setFeedback); foreach (ParticleSystem item in playermissedParticle) { item.Play(); } break; case SetFeedback.PlayerCountered: body.Animate(Animations.Attack); PlaySound(setFeedback); foreach (ParticleSystem item in playercounteredParticle) { item.Play(); } break; default: break; } }