public static Keys KeyBindingFromLimbType(LimbType type) { if (type == LimbType.Head) { return(HeadAction); } if (type == LimbType.RightArm) { return(ArmRightAction); } if (type == LimbType.LeftArm) { return(ArmLeftAction); } if (type == LimbType.LeftLeg) { return(LegLeftAction); } if (type == LimbType.RightLeg) { return(LegRightAction); } return(Keys.F24); }
public Blob RemoveBodyPart(LimbType whichLimb) { Blob removed = GetBodyPart(whichLimb); SetBodyPart(whichLimb, null); return(removed); }
public Limb FetchLimb(AnimalType limbAnimal, LimbType limbType) { // First get all limbs that have the right animal var limbsForAnimal = new List <Limb>(); //Debug.Log("Getting limbs for " + limbAnimal); foreach (Limb limb in limbList) { if (limb.animalType == limbAnimal && limb.limbType_ == limbType) { return(limb); //limbsForAnimal.Add(limb); //Debug.Log("Adding limb ... " + limb.limbType + " for " + limb.animal); } } // Then N+1 all limbs of right type //foreach (Limb limb in limbsForAnimal) //{ // if (limb.limbType == limbType) // { // //Debug.Log("Returning limb ... " + limb.limbType); // return limb; // } //} // Fallback var randLimb = limbList[Random.Range(0, limbList.Length)]; //Debug.LogError("Fallback limb: " + randLimb.animal + " " + randLimb.limbType); return(randLimb); }
//---------------------------------------------- public UnitLimb(LimbType limb, float maxBreakForce) { LimbPart = limb; m_MaxBreakForce = maxBreakForce; m_BreakForce = maxBreakForce; }
void TryPickupBodyPart(LimbType type) { List <LimbPickup> touchedParts = new List <LimbPickup>(); List <LimbPickup> allParts = LimbManager.Instance.GetLimbs(); //collide all parts for (int i = 0; i < allParts.Count; i++) { LimbPickup part = allParts[i]; if (part.blob.Collides(blob)) { touchedParts.Add(part); } } //test for matching limb for (int i = 0; i < touchedParts.Count; i++) { LimbPickup part = touchedParts[i]; Limb limb = part.blob.GetComponent <Limb>(); if (limb.IsMatchingLimb(type)) { part.Pickup(); AddLimbFromLimb(type, limb); AttachAbilityToPart(type, limb); SoundManager.PlaySound(SoundManager.SFX_ATTACH_LIMB); return; } } }
System.Guid RemoveLimb(LimbType limbtype) { for (int i = 0; i < limbs.Count; i++) { if (limbs[i].getLimb() == limbtype) { limbs.RemoveAt(i); localPositions.RemoveAt(i); for (int t = 0; t < transform.childCount; t++) { if (transform.GetChild(t).GetComponent <Limb>()) { if (transform.GetChild(t).GetComponent <Limb>().getLimb() == limbtype) { System.Guid oldId = transform.GetChild(t).GetComponent <Limb>().id; Destroy(transform.GetChild(t).gameObject); return(oldId); } } } } } return(System.Guid.Empty); }
void SetBodyPartFacing(LimbType type, Facing face) { if (GetBodyPart(type) != null) { GetBodyPart(type).GetComponent <LimbVisual>().SetFacing(face); } }
public WearableSprite(Wearable item, Sprite sprite, bool hideLimb, LimbType depthLimb = LimbType.None) { WearableComponent = item; Sprite = sprite; HideLimb = hideLimb; DepthLimb = depthLimb; }
public void UnmuteTrack(LimbType type) { int trackIndex = limbTypes.FindIndex(t => t == type); if (trackIndex != -1 && trackIndex < limbTracks.Count) { limbTracks[trackIndex].mute = false; } }
public WearableSprite(Wearable item, Sprite sprite, bool hideLimb, bool inheritLimbDepth = true, LimbType depthLimb = LimbType.None) { WearableComponent = item; Sprite = sprite; HideLimb = hideLimb; InheritLimbDepth = inheritLimbDepth; DepthLimb = depthLimb; }
public void DetachLimb(LimbType limb, AttachmentSlot slot) { int slotIndex = limbSlots.FindIndex(s => s == slot); if (slotIndex != -1 && slotIndex < slotTracks.Count) { SlotTracks tracks = slotTracks[slotIndex]; tracks.MuteTrack(limb); } }
void DropLimb(LimbType limbType) { Limb limb = limbs[limbType]; limbs[limbType] = null; if (limb != null) { StartCoroutine(DropLimbDelayed(limb, LIMB_DROP_DELAY)); } }
public override void StartPhase() { StartCoroutine(WaitForGo()); opponentTransform = NetworkPlayerManager.Instance.players[0].transform; timer = crossingTimer; lastHit = LimbType.None; _active = true; localHited = false; globalHited = false; }
public WearableSprite(Wearable item, Sprite sprite, LimbType limb, bool hideLimb, bool inheritLimbDepth = true, LimbType depthLimb = LimbType.None, string sound = null) { WearableComponent = item; Sprite = sprite; Limb = limb; HideLimb = hideLimb; InheritLimbDepth = inheritLimbDepth; DepthLimb = depthLimb; Sound = sound; }
public RocketLeg(Dude body, LimbType limbType) : base(body, limbType) { velocity = new Vector2(0, 400); maxThrowTime = 10f; throwTime = 0f; chargePower = 0f; chargeSpeed = .4f; chargeMax = 1; }
public HammerArm(Dude body, LimbType limbType) : base(body, limbType) { velocity = new Vector2(0, 420); maxThrowTime = .75f; throwTime = 0f; sweetMin = .7f; sweetMax = .9f; sweetBonus = 2f; chargePower = 0f; chargeSpeed = 2f; chargeMax = 1; }
public BombHead(Dude body, LimbType limbType) : base(body, limbType) { hasBeenUnpressed = false; velocity = new Vector2(0, 420); maxThrowTime = .75f; throwTime = 0f; sweetMin = .7f; sweetMax = .9f; sweetBonus = 2f; chargePower = 0f; chargeSpeed = 5f; chargeMax = 5f; }
public HumanHead(Dude body, LimbType limbType) : base(body, limbType) { velocity = new Vector2(0, 420); maxThrowTime = .75f; throwTime = 0f; sweetMin = .1f; sweetMax = .4f; sweetBonus = 1f; chargePower = 0f; chargeSpeed = 5f; chargeMax = .5f; chargeMove = new Vector2(0, -5); }
void ThrowLimb(LimbType limbtype) { GameObject objectToSpawn = null; System.Guid limbID = RemoveLimb(limbtype); //If player does not have limb of this type no limb is thrown if (limbID == System.Guid.Empty) { print("No limb left of this type"); return; } switch (limbtype) { case LimbType.Arm: objectToSpawn = armPrefab; break; case LimbType.Leg: objectToSpawn = legPrefab; break; default: break; } GameObject launchedLimb = Instantiate(objectToSpawn, (Vector3)Random.insideUnitCircle * 0.25f + transform.position, Quaternion.Euler(0, 0, Random.Range(0, 360))); launchedLimb.GetComponent <Limb>().id = limbID; launchedLimb.GetComponent <Limb>().Throw(GetArmCount, visualPlayerID); Vector2 dir = Vector2.zero; dir = target.transform.position - transform.position; launchedLimb.GetComponent <Rigidbody2D>().mass = 1; launchedLimb.GetComponent <Rigidbody2D>().AddForce(dir.normalized * (throwBaseForce + throwMultiplier * GetArmCount), ForceMode2D.Impulse); Destroy(launchedLimb.GetComponent <HingeJoint2D>()); PlayRandomSound(throwSounds); }
public static string ToAttributeString(this HumanoidMuscleType _this) { if (_this < HumanoidMuscleType.Root) { int delta = _this - HumanoidMuscleType.Motion; return(nameof(HumanoidMuscleType.Motion) + GetTransformPostfix(delta % 7)); } if (_this < HumanoidMuscleType.Limbs) { int delta = _this - HumanoidMuscleType.Root; return(nameof(HumanoidMuscleType.Root) + GetTransformPostfix(delta % 7)); } if (_this < HumanoidMuscleType.Muscles) { int delta = _this - HumanoidMuscleType.Limbs; LimbType limb = (LimbType)(delta / 7); return(limb.ToBoneType().ToAttributeString() + GetTransformPostfix(delta % 7)); } if (_this < HumanoidMuscleType.Fingers) { int delta = _this - HumanoidMuscleType.Muscles; MuscleType muscle = (MuscleType)delta; return(muscle.ToAttributeString()); } if (_this < HumanoidMuscleType.TDoFBones) { const int armSize = (int)FingerType.Last * (int)FingerDoFType.Last; const int dofSize = (int)FingerDoFType.Last; int delta = _this - HumanoidMuscleType.Fingers; ArmType arm = (ArmType)(delta / armSize); delta = delta % armSize; FingerType finger = (FingerType)(delta / dofSize); delta = delta % dofSize; FingerDoFType dof = (FingerDoFType)delta; return($"{arm.ToBoneType().ToAttributeString()}.{finger.ToAttributeString()}.{dof.ToAttributeString()}"); } if (_this < HumanoidMuscleType.Last) { const int TDoFSize = (int)TDoFBoneType.Last; int delta = _this - HumanoidMuscleType.TDoFBones; TDoFBoneType tdof = (TDoFBoneType)(delta / TDoFSize); return($"{tdof.ToBoneType().ToAttributeString()}{GetTDoFTransformPostfix(delta % TDoFSize)}"); } throw new ArgumentException(_this.ToString()); }
public LaserHead(Dude myBody, LimbType whichLimb) : base(myBody, whichLimb) { hasBeenUnpressed = false; velocity = new Vector2(0, 420); throwTime = 0f; maxThrowTime = .75f; sweetMin = .7f; sweetMax = .9f; sweetBonus = 1f; chargePower = 0f; chargeSpeed = 2f; chargeMax = 3; //meleeAhead = 10f; bulletFireTrajectory = new Vector2(0, 500); }
public bool IsMatchingLimb(LimbType limbType) { if (limbType == LimbType.Head) { return(type == LimbComponentType.Head); } else if (limbType == LimbType.LeftArm || limbType == LimbType.RightArm) { return(type == LimbComponentType.Arm); } else if (limbType == LimbType.LeftLeg || limbType == LimbType.RightLeg) { return(type == LimbComponentType.Leg); } return(false); }
public void callHit(HitInfo info) { if (localHited || !_active) { return; } localHited = true; globalHited = true; lastHit = (LimbType)info.limbHit; float multiplier = 1; switch (lastHit) { case LimbType.Head: multiplier = 3; break; case LimbType.Hand: multiplier = 1; break; case LimbType.Torso: multiplier = 2; break; } if (lastHit == LimbType.None) { return; } photonView.RPC("CalculateScore", PhotonTargets.All, NetworkPlayerManager.Instance.playerID, multiplier); photonView.RPC("ReceiveRegisterHit", PhotonTargets.Others, SerializationToolkit.ObjectToByteArray(info)); if (OnJoustHit != null) { OnJoustHit.Invoke(info); } Instantiate(blood, info.hitPoint.Deserialize(), Quaternion.identity); }
public static BoneType ToBoneType(this LimbType _this) { switch (_this) { case LimbType.LeftFoot: return(BoneType.LeftFoot); case LimbType.RightFoot: return(BoneType.RightFoot); case LimbType.LeftHand: return(BoneType.LeftHand); case LimbType.RightHand: return(BoneType.RightHand); default: throw new ArgumentException(_this.ToString()); } }
public void Die() { IsAlive = false; var keys = limbs.Keys; var types = new LimbType[keys.Count]; var index = 0; foreach (LimbType t in keys) { types[index++] = t; } for (int i = 0; i < types.Length; ++i) { DropLimb(types[i]); } DropRoot(); }
public void AddLimbFromLimb(LimbType limbType, Limb previousLimb) { if (GetBodyPart(limbType) == null) { Blob limb = new Blob(); limb.transform.Parent = blob.transform; limb.transform.LocalPosition = new Vector2(0, yCoordinates[(int)limbType]); Limb.LimbPosition positionType = Limb.LimbPosition.Left; if (limbType == LimbType.RightLeg || limbType == LimbType.RightArm) { positionType = Limb.LimbPosition.Right; } Limb visual = new Limb(previousLimb, positionType, randomDepth); limb.AddComponent(visual); SetBodyPart(limbType, limb); SetFacing(facing); } }
public void AddLimb(LimbType limbType, bool isHuman) { if (GetBodyPart(limbType) == null) { Blob limb = new Blob(); limb.transform.Parent = blob.transform; limb.transform.LocalPosition = new Vector2(0, yCoordinates[(int)limbType]); Limb.LimbComponentType componentType = Limb.LimbComponentType.Head; if (limbType == LimbType.Head) { componentType = Limb.LimbComponentType.Head; } else if (limbType == LimbType.LeftArm || limbType == LimbType.RightArm) { componentType = Limb.LimbComponentType.Arm; } else if (limbType == LimbType.LeftLeg || limbType == LimbType.RightLeg) { componentType = Limb.LimbComponentType.Leg; } else if (limbType == LimbType.Torso) { componentType = Limb.LimbComponentType.Torso; } Limb.LimbPosition positionType = Limb.LimbPosition.Left; if (limbType == LimbType.RightLeg || limbType == LimbType.RightArm) { positionType = Limb.LimbPosition.Right; } Limb visual = new Limb(componentType, positionType, randomDepth, isHuman); limb.AddComponent(visual); SetBodyPart(limbType, limb); SetFacing(facing); } }
public void LimbFly(int health, int damage) { while (damage-- > 0) { int numLimbs = Enum.GetValues(typeof(LimbType)).Length; LimbType whichLimb = (LimbType)RandomCore.random.Next(numLimbs); for (int tries = 0; tries < numLimbs; tries++) { whichLimb = (LimbType)whichLimb + 1; if ((int)whichLimb >= numLimbs - 1) { whichLimb = (LimbType)0; } Blob part = RemoveBodyPart(whichLimb); if (part != null) { part.transform.Parent = null; part.GetComponent <LimbVisual>().FlyInRandomDirection(); break; } } } }
public LimbPos(LimbType limbType, Vector2 position, bool allowUsingLimb) { LimbType = limbType; Position = position; AllowUsingLimb = allowUsingLimb; }
public virtual void ServerRead(ClientNetObject type, NetBuffer msg, Client c) { if (GameMain.Server == null) { return; } switch (type) { case ClientNetObject.CHARACTER_INPUT: if (c.Character != this) { #if DEBUG DebugConsole.Log("Received a character update message from a client who's not controlling the character"); #endif return; } UInt16 networkUpdateID = msg.ReadUInt16(); byte inputCount = msg.ReadByte(); if (AllowInput) { Enabled = true; } for (int i = 0; i < inputCount; i++) { InputNetFlags newInput = (InputNetFlags)msg.ReadRangedInteger(0, (int)InputNetFlags.MaxVal); UInt16 newAim = 0; UInt16 newInteract = 0; if (newInput.HasFlag(InputNetFlags.Aim)) { newAim = msg.ReadUInt16(); } if (newInput.HasFlag(InputNetFlags.Select) || newInput.HasFlag(InputNetFlags.Use)) { newInteract = msg.ReadUInt16(); } //if (AllowInput) //{ if (NetIdUtils.IdMoreRecent((ushort)(networkUpdateID - i), LastNetworkUpdateID) && (i < 60)) { NetInputMem newMem = new NetInputMem(); newMem.states = newInput; newMem.intAim = newAim; newMem.interact = newInteract; newMem.networkUpdateID = (ushort)(networkUpdateID - i); memInput.Insert(i, newMem); } //} } if (NetIdUtils.IdMoreRecent(networkUpdateID, LastNetworkUpdateID)) { LastNetworkUpdateID = networkUpdateID; } if (memInput.Count > 60) { //deleting inputs from the queue here means the server is way behind and data needs to be dropped //we'll make the server drop down to 30 inputs for good measure memInput.RemoveRange(30, memInput.Count - 30); } break; case ClientNetObject.ENTITY_STATE: int eventType = msg.ReadRangedInteger(0, 3); switch (eventType) { case 0: inventory.ServerRead(type, msg, c); break; case 1: bool doingCPR = msg.ReadBoolean(); if (c.Character != this) { #if DEBUG DebugConsole.Log("Received a character update message from a client who's not controlling the character"); #endif return; } AnimController.Anim = doingCPR ? AnimController.Animation.CPR : AnimController.Animation.None; break; case 2: if (c.Character != this) { #if DEBUG DebugConsole.Log("Received a character update message from a client who's not controlling the character"); #endif return; } if (IsUnconscious) { Kill(lastAttackCauseOfDeath); } break; case 3: LimbType grabLimb = (LimbType)msg.ReadUInt16(); if (c.Character != this) { #if DEBUG DebugConsole.Log("Received a character update message from a client who's not controlling the character"); #endif return; } AnimController.GrabLimb = grabLimb; break; } break; } msg.ReadPadBits(); }
public LimbPos(LimbType limbType, Vector2 position) { this.limbType = limbType; this.position = position; }
public Limb(Ragdoll ragdoll, Character character, LimbParams limbParams) { this.ragdoll = ragdoll; this.character = character; this.limbParams = limbParams; wearingItems = new List <WearableSprite>(); dir = Direction.Right; body = new PhysicsBody(limbParams); type = limbParams.Type; if (limbParams.IgnoreCollisions) { body.CollisionCategories = Category.None; body.CollidesWith = Category.None; ignoreCollisions = true; } else { //limbs don't collide with each other body.CollisionCategories = Physics.CollisionCharacter; body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionItem & ~Physics.CollisionItemBlocking; } body.UserData = this; pullJoint = new FixedMouseJoint(body.FarseerBody, ConvertUnits.ToSimUnits(limbParams.PullPos * Scale)) { Enabled = false, MaxForce = ((type == LimbType.LeftHand || type == LimbType.RightHand) ? 400.0f : 150.0f) * body.Mass }; GameMain.World.AddJoint(pullJoint); var element = limbParams.Element; if (element.Attribute("mouthpos") != null) { MouthPos = ConvertUnits.ToSimUnits(element.GetAttributeVector2("mouthpos", Vector2.Zero)); } body.BodyType = BodyType.Dynamic; body.FarseerBody.AngularDamping = LimbAngularDamping; damageModifiers = new List <DamageModifier>(); foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "attack": attack = new Attack(subElement, (character == null ? "null" : character.Name) + ", limb " + type); if (attack.DamageRange <= 0) { switch (body.BodyShape) { case PhysicsBody.Shape.Circle: attack.DamageRange = body.radius; break; case PhysicsBody.Shape.Capsule: attack.DamageRange = body.height / 2 + body.radius; break; case PhysicsBody.Shape.Rectangle: attack.DamageRange = new Vector2(body.width / 2.0f, body.height / 2.0f).Length(); break; } attack.DamageRange = ConvertUnits.ToDisplayUnits(attack.DamageRange); } break; case "damagemodifier": damageModifiers.Add(new DamageModifier(subElement, character.Name)); break; } } SerializableProperties = SerializableProperty.GetProperties(this); InitProjSpecific(element); }