Пример #1
0
 public static IEnumerator relax(SimpleLeg legOne, SimpleLeg legTwo)
 {
     legOne.relaxFoot();
     legOne.relaxThigh();
     legTwo.relaxFoot();
     legTwo.relaxThigh();
     yield return new WaitForFixedUpdate();
 }
Пример #2
0
 public static IEnumerator delayJump(SimpleLeg legOne, SimpleLeg legTwo)
 {
     Debug.Log("Delay");
     legOne.lift();
     legTwo.lift();
     while(jumpKeyPressed(false))
     {
         yield return new WaitForFixedUpdate();
     }
     yield return legOne.StartCoroutine(MovementUtility.jump(legOne, legTwo));
 }
Пример #3
0
 public static IEnumerator jump(SimpleLeg legOne, SimpleLeg legTwo)
 {
     Debug.Log("jump");
     legOne.jump();
     legTwo.jump();
     while(!(legOne.isFullyLowered() || legTwo.isFullyLowered())) {
         yield return new WaitForFixedUpdate();
     }
     legOne.relaxThigh();
     legTwo.relaxThigh();
     yield return new WaitForSeconds(0.5f);
 }
Пример #4
0
    public static void checkFeet(SimpleLeg legOne, SimpleLeg legTwo)
    {
        float heightDiff = SimpleLeg.getYAxisDiff(legOne, legTwo);
        SimpleLeg highLeg = legOne;
        SimpleLeg lowLeg = legTwo;

        if(heightDiff < 0f) {
            lowLeg = legOne;
            highLeg = legTwo;
        }

        highLeg.advanceOpposed();
        lowLeg.advance();
    }
Пример #5
0
 public static IEnumerator crouch(SimpleLeg legOne, SimpleLeg legTwo)
 {
     legOne.lift();
     legTwo.lift();
     yield return new WaitForFixedUpdate();
 }
Пример #6
0
 public static IEnumerator walkOneLeg(SimpleLeg leg1, SimpleLeg leg2)
 {
     MovementUtility.checkFeet(leg1, leg2);
     leg1.lower();
     leg2.lift();
     while(!leg1.isFullyLowered()) {
         Debug.DrawLine(leg1.thigh.transform.position, leg1.thigh.transform.position, Color.cyan);
         leg1.lower();
         leg2.lift();
         MovementUtility.checkFeet(leg1, leg2);
         yield return new WaitForFixedUpdate();
     }
     yield return null;
 }
Пример #7
0
 public static IEnumerator stand(SimpleLeg legOne, SimpleLeg legTwo)
 {
     legOne.footAdvanceFactor = 1f;
     legTwo.footAdvanceFactor = 1f;
     legOne.lower();
     legTwo.lower();
     if(SimpleLeg.getXAxisDiff(legOne, legTwo) < 0f) {
         legOne.advance();
         legTwo.advanceOpposed();
     }else{
         legOne.advanceOpposed();
         legTwo.advance();
     }
     yield return new WaitForFixedUpdate();
 }
Пример #8
0
    void Start()
    {
        legIntentToFunction = new Dictionary<LegsIntent, LegsFunction>();
        legIntentToFunction.Add(LegsIntent.NONE, MovementUtility.relax);
        legIntentToFunction.Add(LegsIntent.STAND, MovementUtility.stand);
        legIntentToFunction.Add(LegsIntent.CROUCH, MovementUtility.crouch);
        if(delayJump) {
            legIntentToFunction.Add(LegsIntent.JUMP, MovementUtility.delayJump);
        } else {
            legIntentToFunction.Add(LegsIntent.JUMP, MovementUtility.jump);
        }
        legIntentToFunction.Add(LegsIntent.WALK, MovementUtility.walkOneLeg);

        if(legOne == null) {
            Vector3 position = this.transform.position;
            position.y = position.y + 1f;
            this.transform.position = position;
            legOne = MovementUtility.spawnLeg(this.gameObject, legPrefab, footPrefab, legData, .4f, "One");
        }
        if(legTwo == null) {
            legTwo = MovementUtility.spawnLeg(this.gameObject, legPrefab, footPrefab, legData, -.4f, "Two");
        }

        legIntentSetter = manualLegs;
        if(!fullManual) {
            legIntentSetter = autoIntent;
            if(tryInputs) {
                legIntentSetter = getIntentFromInputs;
            }
            StartCoroutine(doLegs());
        }
        StartCoroutine(legIntentSetter());
    }
Пример #9
0
 //TODO: this will likely go all screwy on inclines
 public static float getYAxisDiff(SimpleLeg first, SimpleLeg other)
 {
     return first.thigh.transform.localPosition.y - other.thigh.transform.localPosition.y;
 }
Пример #10
0
 //TODO: this will likely go all screwy on inclines
 public static float getXAxisDiff(SimpleLeg first, SimpleLeg other)
 {
     return first.foot.transform.localPosition.x - other.foot.transform.localPosition.x;
 }