void Start() { states = GetComponent <StatesManager>(); states.Init(); agent = GetComponent <NavMeshAgent>(); }
public void Init(StatesManager st) { r_manager = st.r_manager; anim = st.anim; LoadCharacter(); hair = LoadCharacterObject(hairObj); eyebrows = LoadCharacterObject(eyebrowsObj); LoadMask(maskObj); LoadCharacterObject(other); }
public void GetHit(StatesManager s, RuntimeWeapon c, HitPosition hp) { HumanBodyBones t = HumanBodyBones.Chest; if (hp != null) { t = hp.bone; } float baseDamage = c.stats.GetDamage(); //float baseDamage = 25; switch (t) { case HumanBodyBones.Head: anim.Play("damage 2"); baseDamage *= 2; baseDamage += Random.Range(-5, 5); break; case HumanBodyBones.Chest: anim.Play("damage 2"); baseDamage += Random.Range(-12, 12); break; case HumanBodyBones.LeftUpperArm: baseDamage *= .5f; anim.Play("damage 1"); baseDamage += Random.Range(-12, 12); break; case HumanBodyBones.RightUpperArm: baseDamage *= .5f; anim.Play("damage 1"); baseDamage += Random.Range(-12, 12); break; } health -= Mathf.RoundToInt(baseDamage); if (health < 0) { a_hook.enabled = false; StartCoroutine(EnableRagdoll_AfterDelay(.1f)); states.isDead = true; } }
public void Init(StatesManager st) { states = st; anim = states.anim; shoulder = anim.GetBoneTransform(HumanBodyBones.RightShoulder).transform; aimPivot = new GameObject().transform; aimPivot.name = "aim pivot"; aimPivot.transform.parent = states.transform; rh_target = new GameObject().transform; rh_target.name = "right hand target"; rh_target.parent = aimPivot; states.inp.aimPosition = states.transform.position + transform.forward * 15; states.inp.aimPosition.y += 1.4f; }
void HandleDamage(RaycastHit h, RuntimeWeapon c, Vector3 d) { Rigidbody rigid = h.transform.GetComponent <Rigidbody>(); if (rigid != null) { if (!rigid.isKinematic) { rigid.AddForceAtPosition(d * 20, h.point, ForceMode.Impulse); } } StatesManager st = h.transform.GetComponentInParent <StatesManager>(); if (st != null) { if (st != this) { if (st.states.isDead) { return; } HitPosition hitPos = h.transform.GetComponent <HitPosition>(); GameObject p = objPool.RequestObject("BloodSplat_FX"); p.transform.position = h.point; st.GetHit(this, c, hitPos); } } else { GameObject p = objPool.RequestObject("bullet_hit"); p.transform.position = h.point; p.transform.LookAt(a_hook.aimPivot.position); } }