Exemplo n.º 1
0
    private void ded()
    {
        if (effectsLight != null)
        {
            effectsLight.enabled    = false;
            effectsBehavior.doCount = true;
        }

        explodeStats.explode(transform.position);
        GameObject.Destroy(gameObject);
    }
Exemplo n.º 2
0
 void explode()
 {
     if (explodeStats != null)
     {
         if (isLocalPlayer || localOwned) // only deal damage if local instance owns the object
         {
             // will deal networked damage
             explodeStats.explode(transform.position);
         }
         else
         {
             // cosmetic-only explosion that all non-owner instances will see
             explodeStats.cosmeticLocalExplode(transform.position);
         }
     }
 }
Exemplo n.º 3
0
    private void fire()
    {
        // copy variable data over to determine what kind of shell
        GameObject shell = GameObject.Instantiate(shellSettings);

        shell.transform.position  = projectileSpawn.transform.position;
        shell.transform.rotation  = projectileSpawn.transform.rotation;
        shell.transform.rotation *= getShellSpreadRotation(shellSpreadHoriz, shellSpreadVert);
        shell.SetActive(true);

        shell.GetComponent <Rigidbody>().velocity = shell.transform.forward * shellSpeed;

        //shell.GetComponent<TankShell>().readyEmit();

        if (explodeOnLaunch)
        {
            explode.explode(explodePosition.position);
        }
    }
Exemplo n.º 4
0
    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++;
    }