public override void OnCollisionEnter(Collider collider) { ChadControls otherChad = collider.gameObject.GetComponent <ChadControls>(); ChadControls localChad = MatchSystem.instance.LocalChad; // Direct Hit with a Chad if (otherChad) { if (otherChad == localChad && !localChad.ToySoldierAffected) { TEAM_TYPE colliderTeam = MatchSystem.instance.GetPlayerTeam(localChad.gameObject); TEAM_TYPE throwerTeam = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject); if (colliderTeam != throwerTeam) { localChad.ToySoldierAffected = true; Activate(); } } } else if (isOwner) { PickupCollider.enabled = true; pickedUp = false; _DespawnTimer = 0.0f; } }
// this function will be called upon powerup use / collision after trown public override void OnActivate() { //Make sure powerups can only be activated once! if (activated) { return; } activated = true; ChadControls otherChad = null; if (_LastCollider) { otherChad = _LastCollider.gameObject.GetComponent <ChadControls>(); } if (otherChad) { // rustle his jimmies Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, Vector3.Zero, 0.0f); param.bodyPartFactor[(int)Ragdoll.BODYPART.SPINE] = 0.88f; param.bodyPartFactor[(int)Ragdoll.BODYPART.RIGHT_LOWER_LEG] = 10.0f; param.bodyPartFactor[(int)Ragdoll.BODYPART.LEFT_LOWER_LEG] = 5.0f; param.bodyPartFactor[(int)Ragdoll.BODYPART.HEAD] = -2.0f; param.force = otherChad.transform.forward * otherChad.CurrentVelocity.y * 50.0f; otherChad.ActivateRagdoll(3.0f, param); SlipSound.Play(); } Explosion(); }
//public override void OnCollisionEnter(Collider collider) //{ // //Check if colliding with a player // ChadControls otherChad = collider.gameObject.GetComponent<ChadControls>(); // if (!otherChad) // { // base.OnCollisionEnter(collider); // } // else // { // ChadControls localChad = MatchSystem.instance.LocalChad; // TEAM_TYPE playerTeam = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject); // TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(collider.gameObject); // if (localChad && (otherPlayerTeam != playerTeam)) // base.OnCollisionEnter(collider); // } //} // this function will be called upon powerup use / collision after trown public override void OnActivate() { //Make sure powerups can only be activated once! if (activated) { return; } activated = true; // boom particles, Gustav do your magic, sprinkla lite magic till boisen Explosion(); ChadControls localChad = MatchSystem.instance.LocalChad; TEAM_TYPE playerTeam = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject); TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(localChad.gameObject); if (localChad && otherPlayerTeam != playerTeam) { float distance = Vector3.Distance(localChad.transform.position, transform.position); if (distance < ExplosionRadius) { Vector3 forceDir = localChad.transform.position - transform.position; forceDir.Normalize(); forceDir.y += 3.0f; float distForce = ExplosionRadius - distance; Vector3 force = forceDir * ExplosionForce * distForce; Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, force, 0.0f); localChad.ActivateRagdoll(2.0f, param); AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.EXPLODED); } } }
public override void Start() { Chad = gameObject.GetComponent <ChadControls>(); if (Skin != null) { if (Animations.Count > 0) { foreach (var state in Animations) { if (state.Key != ChadControls.STATE.RAGDOLL) // No Ragdoll animations { BlendNode newBlendNode = new BlendNode(Skin.model); for (int i = 0; i < state.Value.Count; ++i) { if (state.Key == ChadControls.STATE.THROWING) { state.Value[i].Node = newBlendNode.appendNode(state.Value[i].Animation, false); } else { state.Value[i].Node = newBlendNode.appendNode(state.Value[i].Animation, true); } } BlendNodes.Add(state.Key, newBlendNode); WeightHandle newWeightHandle = BlendNodes[state.Key].generateWeightHandle(); WeightHandles.Add(state.Key, newWeightHandle); } } WeightHandles[ChadControls.STATE.CHADING].setWeight(0, new WeightTripple(1f)); Skin.setBlendTreeNode(BlendNodes[ChadControls.STATE.CHADING]); } } }
public override void OnCollisionEnter(Collider collider) { _FirstCollider = collider; ChadControls colliderPlayer = _FirstCollider.gameObject.GetComponent <ChadControls>(); if (!colliderPlayer && _JumpTimer == 0 && isOwner) { _Landed = true; if (PointBoi) { _SpawnedLight = true; PointBoi.enabled = true; } m_rigidBody.Friction = 100.0f; m_rigidBody.LinearVelocity = Vector3.Zero; m_rigidBody.FreezeRotation = new Vector3(0, 0, 0); // freeze ya'll's music box _JumpTimer += Time.DeltaTime; base.OnCollisionEnter(collider); } else if (_JumpTimer > 0) { _Landed = true; } }
public override void OnCollisionStay(Collider collider) { if (MatchSystem.instance && isOwner && State != STATE.RAGDOLL && !Locked) { ChadControls otherChad = collider.gameObject.GetComponent <ChadControls>(); if (otherChad) { float modifiedBaseSpeed = PickedUpObject ? PickedUpObject.MovementSpeedModifier * BaseSpeed : BaseSpeed; float TheirVelocity = otherChad.CurrentVelocity.y;//Length(); if (MatchSystem.instance.GetPlayerTeam(collider.gameObject) == MatchSystem.instance.GetPlayerTeam(this.gameObject)) { //Debug.Log("Trying to tackle player on same team, you baka."); } else if (otherChad.CanBeTackled && ((CurrentVelocity.y /*Length()*/ > TackleThreshold || (PickedUpObject && CurrentVelocity.y > BaseSpeed)) && CurrentVelocity.y /*Length()*/ >= TheirVelocity)) { Debug.Log("They tackled with: " + TheirVelocity + "(Forward: " + otherChad.CurrentVelocity.y + ", Strafe: " + otherChad.CurrentVelocity.x + ")"); Debug.Log("You tackled with: " + CurrentVelocity.y /*Length()*/ + "(Forward: " + CurrentVelocity.y + ", Strafe: " + CurrentVelocity.x + ")"); // Activate ragdoll Vector3 force = (transform.forward + Vector3.Up * 0.5f) * ImpactFactor * CurrentVelocity.Length(); Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(otherChad.gameObject.transform.position, force, 0.5f); param.bodyPartFactor[(int)Ragdoll.BODYPART.RIGHT_LOWER_LEG] = 1.3f; param.bodyPartFactor[(int)Ragdoll.BODYPART.LEFT_LOWER_LEG] = 1.3f; otherChad.ActivateRagdoll(MinimumRagdollTimer, param); AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.TACKLED); NetPlayer.HasTackled += 1; CurrentVelocity.y = modifiedBaseSpeed; } } } }
// This function will be called upon powerup use / collision after trown public override void OnActivate() { if (activated) { return; } ChadControls localChad = MatchSystem.instance.LocalChad; if (localChad.ToySoldierAffected) { localChad.SetTiny(); localChad.Acceleration *= 0.5f; localChad.BaseSpeed *= 0.5f; localChad.MaxSpeed *= 0.5f; localChad.FirstJumpForce *= 0.3f; localChad.SecondJumpForce *= 0.3f; activated = true; } StartCoroutine(RemoveToySoldier()); }
virtual public void Pickup(ChadControls chad, Transform hand) { RPCDrop(); SaveObjectOwner(chad); if (!m_rigidBody) { m_rigidBody = gameObject.GetComponent <Rigidbody>(); } m_rigidBody.enabled = false; transform.parent = hand; transform.localPosition = Vector3.Zero; transform.localRotation = Quaternion.Identity; if (PickupOffset) { transform.localPosition = PickupOffset.localPosition; transform.localRotation = PickupOffset.localRotation; } chad.PickedUpObject = this; _Chad = chad; PickupCollider.enabled = false; gameObject.GetComponent <NetworkTransform>().SyncMode = NetworkTransform.TransformSyncMode.SyncNone; pickedUp = true; }
virtual public void Reset() { RPCDrop(); chargeTimeCurrent = 0.0f; _Chad = null; PickupCollider.enabled = false; PickupCollider.enabled = true; gameObject.GetComponent <NetworkTransform>().SyncMode = NetworkTransform.TransformSyncMode.SyncRigidbody; }
public override void Reset() { base.Reset(); _DespawnTime = 30.0f; _DespawnTimer = 0.0f; ObjectOwner = null; }
public override void Pickup(ChadControls chad, Transform hand) { base.Pickup(chad, hand); if (spawner) { spawner.Free(); spawner = null; //Debug.Log("Cleared spawner"); } }
private void ShowPlayers() { Debug.Log("##################################"); Debug.Log("Players:"); foreach (var player in Scene.Players) { if (player.Key != LocalPeer) { ChadControls chad = player.Value.gameObject.GetComponent <ChadControls>(); Debug.Log(player.Key.EndPoint.Address + ":\t" + chad?.rBody.Position); } } Debug.Log("##################################"); }
public override void OnCollisionEnter(Collider collider) { _LastCollider = collider; //Check if colliding with a player ChadControls otherChad = collider.gameObject.GetComponent <ChadControls>(); ChadControls localChad = MatchSystem.instance.LocalChad; if (otherChad && _BananaTimer > 0.1f && otherChad != ObjectOwner || otherChad == ObjectOwner && _BananaTimer > 0.5f) { base.OnCollisionEnter(collider); } else { // colliding with static object m_rigidBody.Friction = 100.0f; m_rigidBody.LinearVelocity = Vector3.Zero; //PickupCollider.enabled = true; // for testing } }
public void RPCDrop() { if (pickedUp) { //Debug.Log("Drop!"); m_rigidBody.enabled = true; gameObject.GetComponent <NetworkTransform>().SyncMode = NetworkTransform.TransformSyncMode.SyncRigidbody; transform.SetParent(null, true); if (_Chad) { _Chad.PickedUpObject = null; _Chad = null; } OnDrop(); StopEmitting(); Cleanup(); pickedUp = false; } }
private IEnumerator BlastingMusic() { //List<ChadControls> affectedChads = new List<ChadControls>(); if (_Note1 && _Note2) { _Note1.Emit = true; _Note2.Emit = true; } if (GramophoneClip) { GramophoneClip.Play(); } // Start blasting ChadControls localChad = MatchSystem.instance.LocalChad; TEAM_TYPE playerTeam = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject); TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(localChad.gameObject); while (_Timer < _DanceDuration) { _Timer += Time.DeltaTime; if (localChad) { float distance = Vector3.Distance(localChad.transform.position, transform.position); if (distance < ExplosionRadius && localChad.State != ChadControls.STATE.RAGDOLL && localChad.State != ChadControls.STATE.DANCING) { localChad.Direction = Vector3.Zero; localChad.rBody.LinearVelocity = new Vector3(0, localChad.rBody.LinearVelocity.y, 0);; localChad.CurrentVelocity = Vector2.Zero; localChad.State = ChadControls.STATE.DANCING; ChadHud.Instance.DeactivateAimHUD(); localChad.ChargeTime = 0; //affectedChads.Add(localChad); } else if (distance > ExplosionRadius && localChad.State == ChadControls.STATE.DANCING) { //foreach (var player in affectedChads) //{ // if (player == localChad) // { // localChad.State = ChadControls.STATE.CHADING; // affectedChads.Remove(player); // buggy? // } //} localChad.State = ChadControls.STATE.CHADING; } } yield return(null); } GramophoneClip.Stop(); // Reset all dancing Chads, the party is over //foreach (var player in affectedChads) //{ // if (player == localChad && localChad.State == ChadControls.STATE.DANCING) // { // localChad.State = ChadControls.STATE.CHADING; // //affectedChads.Remove(player); // buggy? // } //} if (localChad.State == ChadControls.STATE.DANCING) { localChad.State = ChadControls.STATE.CHADING; } //affectedChads.Clear(); Explosion(); }
public override void SaveObjectOwner(ChadControls chad) { ObjectOwner = chad; }
public override void Pickup(ChadControls chad, Transform hand) { base.Pickup(chad, hand); }
virtual public void SaveObjectOwner(ChadControls chad) { }