Ejemplo n.º 1
0
    private IEnumerator slam(float seconds)
    {
        float sec = seconds;

        Vector3 direction;

        DinoCollisions dinoCol = GetComponent <DinoCollisions>();

        dinoCol.enabled = false;

        NetworkAnimations netanim = GetComponentInChildren <NetworkAnimations>();

        netanim.SetBool("Melee", true);

        DinoCollisions otherCol = null;

        while (sec > 0)
        {
            direction = transform.TransformDirection(Vector3.forward);


            //if(Physics.SphereCastAll(this.transform.position, 5.0f, direction, out hit, 20.0f));
            hit = Physics.SphereCastAll(this.transform.position, 10.0f, direction, 20.0f);

            foreach (RaycastHit _ray in hit)
            {
                if (_ray.transform.tag == "Dino" || _ray.transform.tag == "Ai")
                {
                    otherCol         = _ray.transform.GetComponent <DinoCollisions>();
                    otherCol.enabled = false;

                    if (somethingHit == false)
                    {
                        Debug.Log("hit " + _ray.transform.name);
                        Health health = _ray.transform.GetComponent <Health>();
                        health.Damage(damage);
                    }

                    somethingHit = true;
                    break;
                }
            }

            if (somethingHit == true)
            {
                break;
            }

            this.rigidbody.velocity = transform.TransformDirection(Vector3.forward) * speedBoost;

            sec -= 1 * Time.deltaTime;

            yield return(new WaitForSeconds(0.01f));;
        }

        yield return(new WaitForSeconds(0.5f));

        if (otherCol != null)
        {
            otherCol.enabled = true;
        }
        dinoCol.enabled = true;



        somethingHit = false;

        netanim.SetBool("Melee", false);

        networkView.RPC("DisableVFX", RPCMode.All);
    }
Ejemplo n.º 2
0
    private IEnumerator buzz(float time)
    {
        /* Using a Raycast out the front of the Dino to detect a collision seems to work
         * well for forward melee attacks such as this as it prevents a weapon like the BuzzSaw
         * here from doing damage to dinos behind the attacker on trigger pull who may be in
         * range of the "capsule colliders", but are in fact behind the BuzzSaw attacker where
         * the attack should not affect them. Darren */

        RaycastHit[] targets;
        bool         hitOne  = false;
        float        seconds = time;

        DinoCollisions myCollision = GetComponent <DinoCollisions>();

        myCollision.enabled = false;

        DinoCollisions damageColl = null;
        Vector3        buzzForward;

        while (seconds > 0)
        {
            buzzForward = transform.forward;
            targets     = Physics.SphereCastAll(this.transform.position, ColliderRadius, buzzForward, ColliderRange);

            foreach (RaycastHit rayHit in targets)
            {
                if (rayHit.transform.tag == "Dino" || rayHit.transform.tag == "Ai")
                {
                    damageColl         = rayHit.transform.GetComponent <DinoCollisions>();
                    damageColl.enabled = false;

                    if (hitOne == false)
                    {
                        Debug.Log(rayHit.transform.name + "Took BuzzSaw damage");
                        Health health = rayHit.transform.GetComponent <Health>();
                        health.Damage(BuzzSawDamage);
                    }
                    hitOne = true;
                    break;
                }
            }

            if (hitOne == true)
            {
                break;
            }
            // COMMENTS: On instantaneous speed burst...

            /* I tried the AccelationMod from motioncontrol here and in
             * one other place and it didn't seem to have any effect on speed */
            // motControl.AccelerationMod(BuzzSpeedFactor, duration);


            /* I tried several different versions of the AddForce/AddRelativeForce etc with
             * or without a ForceMode. The ForceMode.VelocityChange did speed up the Spino
             * but on collision with damagable walls this newly applied force had him bouncing
             * around like he's in a pinball machine, or blasting other dinos in to outerspace. So
             * I'm finding the rigidbody.velocity = transform.TransformDirection(Vector3.forward) * speedfactor;
             * method to be the best way to go for a temporary, instant speed burst. Darren */
            //this.rigidbody.AddForce(buzzForward * BuzzSpeedFactor, ForceMode.VelocityChange);
            rigidbody.velocity = buzzForward * BuzzSpeedFactor + new Vector3(0, rigidbody.velocity.y, 0);
            seconds           -= Time.deltaTime;
            yield return(null);
        }

        if (damageColl != null)
        {
            damageColl.enabled = true;
        }
        myCollision.enabled = true;

        hitOne = false;

        netanim.SetBool("Melee", false);
    }