public void rpcContactProcess(Vector3 position, int otherId) { if (oneImpactVictim == null) { transform.position = position; GameObject other = null; CombatFlow otherFlow = null; if (otherId != -1) { other = PhotonNetwork.GetPhotonView(otherId).gameObject; otherFlow = other.gameObject.GetComponent <CombatFlow>(); } if (other != null) { oneImpactVictim = other.transform.root.gameObject; } Debug.Log("Bomb collided"); // die immediately on collision myCombatFlow.dealLocalDamage(myCombatFlow.getHP()); if (otherFlow != null && myCombatFlow.localOwned) { otherFlow.dealDamage(impactDamage); } } }
// theoretically, this should not be called unless collider is active private void explosionContactProcess(GameObject victim) { // deal damage // apply force GameObject targetRootObj = victim.transform.root.gameObject; //Debug.Log("Explosion contacted: " + victim.name + " with root: " + targetRootObj.name); // only act upon victim root if he is a new victim if (isNewVictim(targetRootObj)) { explosionVictimRootList.Add(targetRootObj); Rigidbody targetRb = targetRootObj.GetComponent <Rigidbody>(); CombatFlow targetCF = targetRootObj.GetComponent <CombatFlow>(); // whether or not explosion should act upon victim bool doAct = true; //various conditions will try to make this false // if target has a CombatFlow if (targetCF != null) { // if target is friendly, and friendlyFire is disabled if (targetCF.team == team && !friendlyFire) { doAct = false; } // if target is a Projectile, and if (targetCF.type == CombatFlow.Type.PROJECTILE && !damageProjectiles) { doAct = false; } } // if explosion will act upon target if (doAct) { // if target has a rigidBody, add explosive force if (targetRb != null) { targetRb.AddExplosionForce(explosiveForce, transform.position, radius); } if (targetCF != null && coreDamage > 0) { //Debug.Log("Explosion acting upon victim: " + targetRootObj + " for " + coreDamage + " damage, list count: " + explosionVictimRootList.Count); //targetCF.currentHP -= coreDamage; targetCF.dealDamage(coreDamage); } } } }
public void rpcContactProcess(Vector3 position, int otherId) { //Debug.LogWarning("rpcContactProcess locally called"); GameObject otherRoot = null; CombatFlow otherFlow = null; if (otherId != -1) { otherRoot = PhotonNetwork.GetPhotonView(otherId).gameObject; otherFlow = otherRoot.GetComponent <CombatFlow>(); } transform.position = position; //Weapon otherWeapon = otherRoot.gameObject.GetComponent<Weapon>(); // If other has a flow and is the one impact victim if (otherFlow != null && otherRoot != impactVictimRoot) { //myCombatFlow.explodeStats.doExplode = false; impactVictimRoot = otherRoot; // don't explode if victim will die and if victim is not a projectile if (impactDamage > otherFlow.getHP() && otherFlow.type != CombatFlow.Type.PROJECTILE) { myCombatFlow.explodeStats.doExplode = false; // death will only trigger enemy explosion } // ========= TRY TO DEAL IMPACT bool doDealImpact = false; // leaving this super obfuscated like this in case more complex conditions wanted later if (otherFlow != null) { doDealImpact = true; } // finally, deal the impact if (doDealImpact && myCombatFlow.localOwned) { otherFlow.dealDamage(impactDamage); Debug.Log("Impact dealing " + impactDamage + " damage to " + otherFlow); } } if (effectsObj != null) { effectsObj.GetComponent <Light>().enabled = false; } if (myCombatFlow != null) { myCombatFlow.dealLocalDamage(myCombatFlow.getHP()); } }
public void killIfBelowFloor() { CombatFlow combatFlow = GetComponent <CombatFlow>(); if (transform.position.y < 0f && combatFlow.localOwned) { combatFlow.dealDamage(combatFlow.getHP()); //combatFlow.currentHP -= combatFlow.currentHP; } }
public void rpcContactProcess(Vector3 position, int otherId) { //Debug.Log("Rocket colliding. Arming time: " + armingTime + ", arming timer: " + armTimeRemaining + ", isArmed: " + armed); Debug.LogWarning("NOTE: ROCKET CONTACT TRIGGERED"); GameObject otherRoot = null; CombatFlow otherFlow = null; if (otherId != -1) { otherRoot = PhotonNetwork.GetPhotonView(otherId).gameObject; otherFlow = otherRoot.GetComponent <CombatFlow>(); } transform.position = position; if (otherRoot != null) // do not do anything against effects { bool doExplode = !otherRoot.CompareTag("Effects"); Debug.LogWarning("NOTE: ROCKET FOUND OTHER ROOT GAMEOBJECT"); if (otherFlow != null) { if (otherFlow.team != myTeam || friendlyImpact) { if (myFlow.localOwned) { //otherFlow.currentHP -= impactDamage; otherFlow.dealDamage(impactDamage); } } else { doExplode = false; } } if (doExplode) { //myFlow.currentHP -= myFlow.currentHP; myFlow.dealLocalDamage(myFlow.getHP()); effectsObj.GetComponent <Light>().enabled = false; effectsBehavior.doCount = true; //Debug.Log("Rocket HP after impact: " + myFlow.getHP()); } } }
public void impactLocal(Vector3 position, GameObject other) { GameObject otherRoot = other; CombatFlow otherFlow = other.GetComponent <CombatFlow>(); transform.position = position; if (otherRoot != null) // do not do anything against effects { bool doExplode = !otherRoot.CompareTag("Effects"); //Debug.LogWarning("NOTE: ROCKET FOUND OTHER ROOT GAMEOBJECT"); if (otherFlow != null) { if (otherFlow.team != myTeam || friendlyImpact) { if (myFlow.localOwned) { //otherFlow.currentHP -= impactDamage; otherFlow.dealDamage(impactDamage); } } else { doExplode = false; } } if (doExplode) { // myFlow.currentHP -= myFlow.currentHP; myFlow.dealLocalDamage(myFlow.getHP()); if (effectsObj != null) { effectsObj.GetComponent <Light>().enabled = false; } //Debug.Log("Rocket HP after impact: " + myFlow.currentHP); } } }
private void OnParticleCollision(GameObject other) // other is target hit by emitter { int collCount = pSystem.GetSafeCollisionEventSize(); if (collisionEvents == null) { collisionEvents = new ParticleCollisionEvent[collCount]; } if (collCount > collisionEvents.Length) { collisionEvents = new ParticleCollisionEvent[collCount]; } int eventCount = pSystem.GetCollisionEvents(other, collisionEvents); // whenever a collision event is triggered, this loops through and processes every one for (int i = 0; i < eventCount; i++) { // Get velocity of (I'm assuming) particle Vector3 incidentVelocity = collisionEvents[i].velocity; // If other object has rigidbody, subtract its velocity to get relative velocity Rigidbody otherRBref = other.GetComponent <Rigidbody>(); if (otherRBref != null) { incidentVelocity -= otherRBref.velocity; } // Calculate component of velocity along normal Vector3 normal = collisionEvents[i].normal; Vector3 incidentNormal = Vector3.Project(incidentVelocity, normal); // Reference to particle emitter var coll = emitterForThisCollision.collision; // Target information GameObject target = other.transform.root.gameObject; CombatFlow targetFlow = target.GetComponent <CombatFlow>(); float currentDamage = 0f; ExplodeStats netExplodeType = null; if (incidentNormal.magnitude > ParticleBehavior.impactFuseVelocity) // if impact velocity is high enough, impact { // set emitter to have all its projectiles lose 100% of lifetime upon collision coll.lifetimeLoss = 1f; // create impact explosion impactExplosionProperties.explode(collisionEvents[i].intersection); // damage currentDamage = impactDamage; } else // low impact velocity, bounce { // set emitter to have all its projectiles lose 40% of lifetime upon collision coll.lifetimeLoss = .4f; // create bounce explosion at intersection bounceExplosionProperties.explode(collisionEvents[i].intersection); // damage currentDamage = bounceDamage; } //if(netExplodeType != null && targetFlow != null && targetFlow.networkReceivedCannonImpacts) //{ // netExplodeType //} // only attempt to sent HP subtraction if target has CombatFlow script component if (targetFlow != null && (rootFlow.isLocalPlayer || rootFlow.localOwned)) { targetFlow.dealDamage(currentDamage); } } // ParticlePhysicsExtensions. collisionCount++; }