예제 #1
0
    public override void Fire()
    {
        NetworkAnimations netanim = GetComponentInChildren <NetworkAnimations> ();

        netanim.SetBool("Melee", true);
    }
예제 #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (!networkView.isMine)
        {
            return;
        }
        // Forward / Backwack Velocity
        if (Mathf.Abs(inputMovementAxis) > InputDeadzone)
        {
            // Calculate how fast we should be moving
            var targetVelocity = new Vector3(0, 0, inputMovementAxis);
            targetVelocity  = transform.TransformDirection(targetVelocity);
            targetVelocity *= (inputMovementAxis > 0) ? MaxSpeed : MaxSpeedBack;

            // Apply a force that attempts to reach our target velocity
            var velocity       = rigidbody.velocity;
            var velocityChange = (targetVelocity - velocity);
            velocityChange.y = 0;

            var maxdv = Vector3.Normalize(velocityChange) * MaxDeltaVelocity;
            if (velocityChange.magnitude > maxdv.magnitude)
            {
                velocityChange = maxdv;
            }

            if (onGround)
            {
                rigidbody.AddForce(velocityChange, ForceMode.VelocityChange);
            }
            else
            {
                rigidbody.AddForce(velocityChange * AirControl, ForceMode.VelocityChange);
            }
        }

        // Rotation
        if (onGround)
        {
            rigidbody.angularVelocity = (new Vector3(0, TurnSpeed * inputRotationAxis * 0.99f, 0));
        }
        else
        {
            rigidbody.angularVelocity = (new Vector3(0, TurnSpeed * inputRotationAxis * AirControl * 0.99f, 0));
        }

        // Jumping
        if (onGround)
        {
            // The Jump Function
            if (isJumping)
            {
                rigidbody.velocity = new Vector3(rigidbody.velocity.x, Mathf.Sqrt(2.0f * JumpHeight * -Physics.gravity.y), rigidbody.velocity.z);
                netanim.SetBool("Jump", true);
                land = false;
            }
            else
            {
                netanim.SetBool("Jump", false);
            }
        }
        else if (isJumping)
        {
            float      jumpDamper = rigidbody.velocity.magnitude * Time.deltaTime;
            RaycastHit hit;
            Ray        downray = new Ray(rigidbody.transform.position, rigidbody.velocity.normalized);
            if (Physics.Raycast(downray, out hit, jumpDamper) && !land)
            {
                Debug.Log("JumpDamper = " + Mathf.Abs(jumpDamper));
                netanim.SetBool("Jump", false);
                land = true;
            }
        }

        isJumping = false;
        onGround  = false;

        netanim.SetFloat("Speed", rigidbody.velocity.magnitude / MaxSpeed);
        netanim.SetFloat("Direction", inputRotationAxis);
    }
예제 #3
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);
    }
예제 #4
0
 public override void Fire()
 {
     netanim.SetBool("Melee", true);
 }