示例#1
0
 override public void startHurt(HitFeedback feedback)
 {
     if (isDead)
     {
         startFallDown();
         //headSoundSource.clip = bipedalSounds[19];
         //headSoundSource.Play();
     }
     else
     {
         base.startHurt(feedback);
         //headSoundSource.clip = bipedalSounds[Random.Range(15, 19)];
         //headSoundSource.Play();
     }
 }
示例#2
0
        void OnCollisionEnter(Collision collision)
        {
            //	Debug.Log(this.name + " vvvvvvvv  "+this.rigidbody.velocity);
            ContactPointInfo cp = new ContactPointInfo();

            cp.collider1 = collision.contacts[0].thisCollider;
            cp.collider2 = collision.contacts[0].otherCollider;
            cp.cp        = collision.contacts[0].point;
            cp.n         = collision.contacts[0].normal;
            cp.v         = collision.relativeVelocity;

            HitFeedback fb = new HitFeedback();

            fb.feedbackARB = this;
            fb.localPos    = this.getLocalCoordinatesPoint(cp.cp);
            //if(cp.collider2.rigidbody != null && cp.collider2.rigidbody.velocity.magnitude > 0.01f){
            fb.force = collision.relativeVelocity;
            //}else{
            //fb.force = cp.collider2.rigidbody.mass * collision.relativeVelocity;
            //}
            fb.bodySpringKp         = -19 * fb.force.magnitude + 580;
            fb.bodySpringKp         = Mathf.Clamp(fb.bodySpringKp, 10, 200);
            fb.bodySpringKd         = -0.5f * fb.force.magnitude + 20;
            fb.bodySpringKd         = Mathf.Clamp(fb.bodySpringKd, 5, 10);
            fb.rootExternalTorqueKp = -2 * fb.force.magnitude + 60;
            fb.rootExternalTorqueKp = Mathf.Clamp(fb.rootExternalTorqueKp, 0.0001f, 10);
            fb.rootExternalTorqueKd = -10 * fb.force.magnitude + 300;
            fb.rootExternalTorqueKd = Mathf.Clamp(fb.rootExternalTorqueKd, 0.0001f, 100);
            fb.power       = 6.7f * fb.force.magnitude - 100;
            fb.power       = Mathf.Clamp(fb.power, 0, 100);
            fb.isTouchDown = true;

            if (onCollisionEnterHandler != null)
            {
                onCollisionEnterHandler(fb, cp);
            }
        }
示例#3
0
 override protected void ResponseHitOthersFeedback(HitFeedback feedback, ContactPointInfo cp)
 {
     base.ResponseHitOthersFeedback(feedback, cp);
     if (!feedback.isHit)
     {
         /*
          * if (cp.collider2.tag.Contains ("enemyTrunk")) {
          *      //if(cp.collider2.tag == "enemyTrunk"){
          *      EnemyBip enemy = ((cp.collider2.GetComponent ("CWRigidBody") as CWRigidBody).getAFParent () as Character).ownerObject.GetComponent ("EnemyBip") as EnemyBip;
          *
          *      HitFeedback hit = feedback.copy ();
          *      hit.feedbackARB = cp.collider2.GetComponent ("CWRigidBody") as CWRigidBody;
          *      if (hit.feedbackARB.name == "head") {
          *              hit.bodySpringKp = 30;
          *              hit.bodySpringKd = 5;
          *              hit.force /= 1.5f;
          *      }
          *      Vector3 f = Vector3.zero;
          *      f += character.getLocalFrontAxis () * hit.force.x;
          *      f += character.getLocalUpAxis () * hit.force.y;
          *      f += character.getLocalLeftAxis () * hit.force.z;
          *      f = controller.getCharacterFrame () * f;
          *
          *      float levelDiff = GameAttribute.gameAttribute.loadPlayerLevel () - enemy.level;
          *      enemy.addLife (-1 * Mathf.Clamp (hit.power + levelDiff, 1, 100));
          *      hit.localPos = hit.feedbackARB.getLocalCoordinatesPoint (cp.cp);
          *      enemy.startHurt (hit);
          *      cp.collider2.attachedRigidbody.AddForceAtPosition (f, cp.cp, ForceMode.Impulse);
          *      //enemy.pelvis.GetComponent<Rigidbody> ().AddForce (0.5f*f, ForceMode.Impulse);
          *      RFGameManager.instance.addPunch (hit.feedbackARB, cp.cp);
          *
          *      if (weapon == null) {
          *              if (cp.collider1.gameObject == lLowerArm || cp.collider1.gameObject == lLowerLeg) {
          *                      lHandSoundSource.clip = bipedalSounds [Random.Range (2, 10)];
          *                      lHandSoundSource.Play ();
          *              } else if (cp.collider1.gameObject == rLowerArm || cp.collider1.gameObject == rLowerLeg) {
          *                      rHandSoundSource.clip = bipedalSounds [Random.Range (2, 10)];
          *                      rHandSoundSource.Play ();
          *              }
          *      } else {
          *              weapon.playAttackSounds ();
          *              weapon.reduceWeaponWastageRate (2);
          *      }
          *
          *      RFGameManager.instance.addExperience (2 * enemy.level + GameAttribute.gameAttribute.loadPlayerLevel () + 5);
          *
          *      if (enemy.getIsStanding() && RFGameManager.instance.getGameState () == RFGameState.idle) {
          *              RFGameManager.instance.gameStartFighting ();
          *              enemy.resetResist ();
          *              enemy.setLookState (HeadLookState.none, null, Vector3.zero);
          *              enemy.setHandTouchState (HandTouchState.none, null, Vector3.zero, HandTouchMode.doubleHand);
          *      }
          *
          *      //gameManager.createBloodSplash(cp.collider2.gameObject, cp.cp);
          * } else {
          *      if (weapon == null) {
          *      } else {
          *              weapon.playAttackSounds (false);
          *              weapon.reduceWeaponWastageRate (1);
          *      }
          * }*/
         feedback.isHit = true;
     }
 }
示例#4
0
    override protected void ResponseHitLimbsFeedback(HitFeedback feedback, ContactPointInfo cp)
    {
        base.ResponseHitLimbsFeedback(feedback, cp);

        float volume = 0.03f * feedback.force.magnitude;

        if (feedback.feedbackARB == controller.getLFoot())
        {
            if (cp.collider2.tag.Contains("carpet"))
            {
                lFootSoundSource.clip   = bipedalSounds[0];
                lFootSoundSource.pitch  = 1;
                lFootSoundSource.volume = volume;
                lFootSoundSource.Play();
            }
            else if (cp.collider2.tag.Contains("wood"))
            {
                lFootSoundSource.clip   = bipedalSounds[1];
                lFootSoundSource.pitch  = 1;
                lFootSoundSource.volume = volume;
                lFootSoundSource.Play();
            }
            else if (cp.collider2.tag.Contains("terrain"))
            {
                lFootSoundSource.clip   = bipedalSounds[20];
                lFootSoundSource.pitch  = 0.6f;
                lFootSoundSource.volume = volume;
                lFootSoundSource.Play();
            }

            /*if (lShoes != null && rShoes != null) {
             *      lShoes.reduceShoesWastageRate (0.0025f * feedback.force.magnitude);
             *      rShoes.reduceShoesWastageRate (0.0025f * feedback.force.magnitude);
             * }*/
        }
        else if (feedback.feedbackARB == controller.getRFoot())
        {
            if (cp.collider2.tag.Contains("carpet"))
            {
                rFootSoundSource.clip   = bipedalSounds[0];
                lFootSoundSource.pitch  = 1;
                rFootSoundSource.volume = volume;
                rFootSoundSource.Play();
            }
            else if (cp.collider2.tag.Contains("wood"))
            {
                rFootSoundSource.clip   = bipedalSounds[1];
                lFootSoundSource.pitch  = 1;
                rFootSoundSource.volume = volume;
                rFootSoundSource.Play();
            }
            else if (cp.collider2.tag.Contains("terrain"))
            {
                lFootSoundSource.clip   = bipedalSounds[20];
                lFootSoundSource.pitch  = 0.6f;
                lFootSoundSource.volume = volume;
                lFootSoundSource.Play();
            }

            /*if (lShoes != null && rShoes != null) {
             *      lShoes.reduceShoesWastageRate (0.0025f * feedback.force.magnitude);
             *      rShoes.reduceShoesWastageRate (0.0025f * feedback.force.magnitude);
             * }*/
        }
    }