Beispiel #1
0
    //private bool readyToEmit;

    //private bool startTrailOn;

    // Start is called before the first frame update
    void Awake()
    {
        rb           = GetComponent <Rigidbody>();
        explodeStats = GetComponent <ExplodeStats>();

        //explodeStats.damage = 0f;
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        isHostInstance = GameManager.getGM().isHostInstance;



        if (PhotonNetwork.PlayerList.Length == 1 || (isHostInstance && GetComponent <CreepControl>() != null))
        {
            localOwned = true;
        }

        //localOwned = isHostInstance;

        explodeStats = GetComponent <ExplodeStats>();

        // spawn icon, set reference here to the TgtHudIconScript of icon spawned
        myHudIconRef = TgtIconManager.tgtIconManager.spawnIcon(this).GetComponent <TgtHudIcon>();// add my icon to hud

        if (!isLocalPlayer)
        {
            spawnRadarIcon();
        }


        if (type == Type.AIRCRAFT)
        {
            GameManager.getGM().getTeamAircraftList(team).Add(this);
        }
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        explode = GetComponent <ExplodeStats>();

        fireRateTimer      = fireRateDelay;
        reloadTimer        = reloadDelay;
        roundsInCurrentMag = roundsPerMag;


        rootFlow = transform.root.GetComponent <CombatFlow>();


        //maxDist = shellSpeed * shellSpeed
        //  * Mathf.Asin(2 * Mathf.Deg2Rad * 45f) / Physics.gravity.magnitude;

        maxDist = shellSpeed * shellSpeed * Mathf.Sin(Mathf.PI / 2) / Physics.gravity.magnitude;
        //maxDist = 3500f;

        //Debug.LogError(rootFlow.gameObject.name + "'s max dist: " + maxDist);
    }
Beispiel #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++;
    }