public void GetThrower() { thrower = null; if (weaponType != BodyPartType.None) { bool weaponRight = IsRightArm(weaponType); bool weaponLeft = IsLeftArm(weaponType); if (weaponRight) { thrower = bodyParts.Find(x => x.bodyPartType == BodyPartType.ArmLeftHand && x.CanThrowStart()); } else if (weaponLeft) { thrower = bodyParts.Find(x => x.bodyPartType == BodyPartType.ArmRightHand && x.CanThrowStart()); } else { if (thrower == null) { thrower = bodyParts.Find(x => x.bodyPartType == BodyPartType.ArmRightHand && x.CanThrowStart()); } if (thrower == null) { thrower = bodyParts.Find(x => x.bodyPartType == BodyPartType.ArmLeftHand && x.CanThrowStart()); } } } }
public void SelectWeapon(ActorBodyPart bp) { if (weapon != null) { if (!weapon.CanWeaponDeselect()) { Debug.Log("Failed to deselect" + weapon + " " + weapon.debugState); return; } weapon.Select(false); weapon = null; } if (bp == null) { return; } if (bp.CanWeaponSelect()) { weapon = bp; GetThrower(); if (thrower == null) { weapon = null; return; } weapon.Select(true); } }
public void Cycle() { for (int i = 0; i < 10; ++i) { switch (weaponType) { case BodyPartType.ArmRightUpper: weaponType = BodyPartType.ArmRightLower; break; case BodyPartType.ArmRightLower: weaponType = BodyPartType.ArmLeftUpper; break; default: case BodyPartType.ArmLeftUpper: weaponType = BodyPartType.ArmLeftLower; break; case BodyPartType.ArmLeftLower: weaponType = BodyPartType.LegRightUpper; break; case BodyPartType.LegRightUpper: weaponType = BodyPartType.LegRightLower; break; case BodyPartType.LegRightLower: weaponType = BodyPartType.LegLeftUpper; break; case BodyPartType.LegLeftUpper: weaponType = BodyPartType.LegLeftLower; break; case BodyPartType.LegLeftLower: weaponType = BodyPartType.ArmRightUpper; break; } ActorBodyPart nextWeapon = bodyParts.Find(x => x.bodyPartType == weaponType && x.CanWeaponSelect()); SelectWeapon(nextWeapon); if (weapon != null) { break; } } }
public void OnCollisionEnter(Collision collision) { if (collision.relativeVelocity.sqrMagnitude < 3f * 3f) { return; } ActorBodyPart bodyPart = collision.collider.GetComponent <ActorBodyPart>(); if (bodyPart != null) { if (bodyPart.thisBody == thisBody) { return; } else { bodyPart.HitBy(this); this.HitBy(bodyPart); } } else { //wall or ground? if (glueState == GlueState.LIMB || glueState == GlueState.FREE) { Expire(); } else { } } }
void OnDormant() { GameObject debris = Instantiate(this.gameObject, thisTransform.position, thisTransform.rotation) as GameObject; debris.layer = LayerMask.NameToLayer("Projectile"); debris.transform.localScale = originalScale; ActorBodyPart debrisPart = debris.GetComponent <ActorBodyPart>(); //debrisPart.thisRenderer.material = new Material(thisRenderer.material); debrisPart.thisRenderer.material.color = Color.green; debrisPart.thisRigidbody.velocity = thisRigidbody.velocity; //debrisPart.SetParent(thisTransform.parent); Destroy(debrisPart); thisTransform.localScale = 0.0001f * Vector3.one; if (thisBody != null) { thisBody.Dormant(this); } else { Debug.Log("Missing body" + this.gameObject); Destroy(this.gameObject); } }
void Deregister(ActorBodyPart bp) { bodyParts.Remove(bp); if (bp.childPart != null) { Deregister(bp.childPart); } }
void Regrow() { ActorBodyPart bp = regrowList[0]; while (bp.parentPart != null && regrowList.Contains(bp.parentPart)) { bp = bp.parentPart; } regrowList.Remove(bp); bp.growSpeed = IsSuper() ? 4f : 1f; bp.machine.SetState(PartState.GROWING); }
public void Dormant(ActorBodyPart bp) { if (bp.bodyPartType == BodyPartType.Head) { Debug.Log("Death!"); foreach (ActorBodyPart bodyPart in bodyParts) { bodyPart.Expire(); } Game.Instance.livingActors.Remove(thisActor); } else { regrowList.Add(bp); } }
IEnumerator LaunchRoutine(float amount) { while (projectile.stateLock) { yield return(new WaitForSeconds(0.1f)); } amount = 0.33f + 0.67f * amount; thrower.machine.SetState(PartState.ATTACHED); SelectWeapon(null); yield return(null); projectile.Launch(amount * maxForce, currentDirection); Deregister(projectile); thrower = null; yield return(null); EvaluateSelf(); }
public void EvaluateSelf() { ActorBodyPart legLowerLeft = bodyParts.Find(x => x.bodyPartType == BodyPartType.LegLeftLower && x.CanWalk()); ActorBodyPart legLowerRight = bodyParts.Find(x => x.bodyPartType == BodyPartType.LegRightLower && x.CanWalk()); ActorBodyPart legUpperLeft = bodyParts.Find(x => x.bodyPartType == BodyPartType.LegLeftUpper && x.CanWalk()); ActorBodyPart legUpperRight = bodyParts.Find(x => x.bodyPartType == BodyPartType.LegRightUpper && x.CanWalk()); ActorBodyPart head = bodyParts.Find(x => x.bodyPartType == BodyPartType.Head && x.CanWalk()); hasHead = head != null; canWalkNormal = legLowerLeft != null && legLowerRight != null; canWalkHop = legLowerLeft != null || legLowerRight != null; canWalkKneel = legUpperLeft != null && legUpperRight != null && legLowerLeft == null && legLowerRight == null; if (canWalkNormal) { skeleton.transform.position = Vector3.zero; } else if (canWalkKneel) { skeleton.transform.position = 0.31f * Vector3.down; } else { } }
// Use this for initialization void Awake() { weapon = null; thrower = null; }
public void Test() { ActorBodyPart legLowerLeft = bodyParts.Find(x => x.bodyPartType == BodyPartType.LegLeftLower); legLowerLeft.Glue(GlueState.SKELETON); }
public void Register(ActorBodyPart bp) { bodyParts.Add(bp); EvaluateSelf(); }
public void Launch(float amount) { projectile = weapon; StartCoroutine(LaunchRoutine(amount)); }
public void HitBy(ActorBodyPart other) { //Debug.Log(this+"hit by "+other+" glueState"+glueState); Expire(); }