IEnumerator followPath() { isHeadingToThePoint = false; if (isFollowingPath) { guardAnimState = animationType.walking; if (pointWhereGuardIs + 1 >= pathfPoints.Length) { headingPoint = 0; } else { headingPoint = pointWhereGuardIs + 1; } navAgent.SetDestination(pathfPoints[headingPoint].position); isHeadingToThePoint = true; } else { guardAnimState = animationType.idle; yield return(new WaitForSeconds(Random.Range(2, 8))); isFollowingPath = true; StartCoroutine(followPath()); yield break; } }
public void moveTo(Vector3 position) { guardAnimState = animationType.walking; headingTo = position; isMovingTo = true; navAgent.SetDestination(position); }
public Animation(animationType animType) { frames = new List <Frame>(); currentFrame = 0; timeBetweenFrames = 0; this.animType = animType; animationDirection = true; }
public Animation() { frames = new List <Frame>(); currentFrame = 0; timeBetweenFrames = 1; animType = animationType.oneShot; animationDirection = true; }
void startJob() { if (guardJob == guardJobType.followPath) { if (Random.Range(0, 1) == 1) { isFollowingPath = true; } else { isFollowingPath = false; } StartCoroutine(followPath()); } else if (guardJob == guardJobType.Static) { isFollowingPath = false; guardAnimState = animationType.idle; } }
void Update() { if (isHeadingToThePoint) { if (Vector3.Distance(transform.position, pathfPoints[headingPoint].position) < 7) { pointWhereGuardIs = headingPoint; startJob(); } } if (isMovingTo) { if (Vector3.Distance(transform.position, headingTo) < 4) { Debug.Log("Ended"); isMovingTo = false; headingTo = new Vector3(0, 0, 0); guardAnimState = animationType.idle; } } guardAnimationUpdate(); }
//加载动作 private IBaseAnimation loadAM( AID aid ) { Type animationType = null; if ( aid != null ) { animationType = AnimationKeyValue.getSingleton().getAnimation( aid ); if ( animationType != null && animationType == IBaseAnimation ) { if ( animationType.BaseType == AniamtionContainer ) { animationType am = new animationType(); ( am as AniamtionContainer ).start( aid ); _hashtable.Add( aid.id, am ); } else { _hashtable.Add( aid.id, animationType ); } } else { Debug.Log( " the animation '" + aid.id + "' do not registered" ); return null; } } return animation; }
public void SetAnimation( animationType type ) { //set the new animation to the one specified if(CurType != type){ switch (type){ case animationType.IdleLeft: //set frame coordinates Xmin = 12; Xmax = 17; Yframe = 1; //set speed animationDelay = 0.18f; //set wrapping CurWrap = wrap.Loop; //always cut SetFrameMin(); //set the current animation CurType = type; break; case animationType.IdleUp: //set frame coordinates Xmin = 12; Xmax = 17; Yframe = 2; //set speed animationDelay = 0.18f; //set wrapping CurWrap = wrap.Loop; //always cut SetFrameMin(); //set the current animation CurType = type; break; case animationType.MoveLeft: //set frame coordinates Xmin = 0; Xmax = 12; Yframe = 1; //set speed animationDelay = 0.05f; timer = animationDelay; //cut straight to animation //set wrapping CurWrap = wrap.Loop; if(!FrameInBounds()){ //if out of bounds, set to min. otherwise, keep frame SetFrameMin(); }//set the current animation CurType = type; break; case animationType.MoveLegs: //set frame coordinates Xmin = 0; Xmax = 12; Yframe = 3; //set speed animationDelay = 0.05f; //set wrapping CurWrap = wrap.Loop; if(!FrameInBounds()){ //if out of bounds, set to min. otherwise, keep frame SetFrameMin(); }//set the current animation CurType = type; break; case animationType.MoveUp: //set frame coordinates Xmin = 0; Xmax = 12; Yframe = 2; //set speed animationDelay = 0.05f; timer = animationDelay; //cut straight to animation //set wrapping CurWrap = wrap.Loop; if(!FrameInBounds()){ //if out of bounds, set to min. otherwise, keep frame SetFrameMin(); }//set the current animation CurType = type; break; case animationType.CrouchStart: //set frame coordinates Xmin = 14; Xmax = 17; Yframe = 9; //set speed animationDelay = 0.1f; //always cut----------------- SetFrameMin(); //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = type; break; case animationType.CrouchLeft: if(CurType == animationType.CrouchMove || CurType == animationType.HitCrouch ||(CurType == animationType.CrouchStart && offsetX >= Xmax * tilingX)){//if came from crouch left or crouch start //set frame coordinates Xmin = 12; Xmax = 16; Yframe = 3; //set speed animationDelay = 0.18f; //set wrapping CurWrap = wrap.Loop; //always cut SetFrameMin(); //set the current animation CurType = type; }else{ //we didn't SetAnimation(animationType.CrouchStart);//start the crouch SetFallback(animationType.CrouchLeft); } break; case animationType.CrouchMove: if(CurType == animationType.CrouchLeft || (CurType == animationType.CrouchStart && offsetX >= Xmax * tilingX)){//if came from crouch left or crouch start //set frame coordinates Xmin = 8; Xmax = 14; Yframe = 9; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.Loop; //always cut SetFrameMin(); //set the current animation CurType = type; }else{ SetAnimation(animationType.CrouchStart);//start the crouch SetFallback(animationType.CrouchMove); } break; case animationType.JumpLeft: //set frame coordinates Xmin = 0; Xmax = 8; Yframe = 8; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.OneShotHold; //always cut----------------- SetFrameMin(); //set the current animation CurType = type; break; case animationType.JumpUp: //set frame coordinates Xmin = 8; Xmax = 16; Yframe = 8; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.OneShotHold; //always cut----------------- SetFrameMin(); //set the current animation CurType = type; break; case animationType.JumpDown: //set frame coordinates Xmin = 0; Xmax = 8; Yframe = 9; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.OneShotHold; //always cut----------------- SetFrameMin(); //set the current animation CurType = type; break; case animationType.Turn: //set frame coordinates Xmin = 16; Xmax = 17; Yframe = 3; //set speed animationDelay = 0.2f; //set wrapping CurWrap = wrap.OneShot; //always cut----------------- SetFrameMin(); //set the current animation CurType = type; break; case animationType.ShootLeft: //set frame coordinates Xmin = 0; Xmax = 8; Yframe = 4; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = animationType.IdleUp; break; case animationType.ShootUp: //set frame coordinates Xmin = 8; Xmax = 16; Yframe = 4; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = animationType.IdleLeft; break; case animationType.ShootMoveLeft: //special //set frame coordinates Xmin = 0; Xmax = 8; Yframe = 5; //set speed //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = animationType.IdleUp; break; case animationType.ShootMoveUp: //special //set frame coordinates Xmin = 8; Xmax = 16; Yframe = 5; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = animationType.IdleUp; break; case animationType.ShootCrouch: //set frame coordinates Xmin = 0; Xmax = 8; Yframe = 6; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = animationType.CrouchStart; break; case animationType.ShootFallLeft: //set frame coordinates Xmin = 8; Xmax = 16; Yframe = 6; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShotHold; //set the current animation CurType = animationType.IdleLeft; break; case animationType.ShootFallUp: //set frame coordinates Xmin = 0; Xmax = 8; Yframe = 7; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShotHold; //set the current animation CurType = animationType.IdleLeft; break; case animationType.ShootFallDown: //set frame coordinates Xmin = 8; Xmax = 16; Yframe = 7; //set speed animationDelay = 0.06f; //set wrapping CurWrap = wrap.OneShotHold; //set the current animation CurType = animationType.JumpDown; break; case animationType.ThrowIdle: //set frame coordinates Xmin = 0; Xmax = 4; Yframe = 10; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = type; break; case animationType.ThrowMove: //special //set frame coordinates Xmin = 4; Xmax = 8; Yframe = 10; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = type; break; case animationType.ThrowCrouch: //set frame coordinates Xmin = 8; Xmax = 12; Yframe = 10; //set speed animationDelay = 0.1f; //set wrapping CurWrap = wrap.OneShot; //set the current animation CurType = animationType.CrouchStart; break; case animationType.ThrowFall: //set frame coordinates Xmin = 12; Xmax = 16; Yframe = 10; //set speed animationDelay = 0.1f; //set the current animation CurType = animationType.JumpLeft; break; case animationType.Die: //set frame coordinates Xmin = 0; Xmax = 9; Yframe = 11; //set speed animationDelay = 0.07f; //always cut SetFrameMin(); //set wrapping CurWrap = wrap.OneShotHold; //set the current animation CurType = animationType.Die; break; case animationType.HitLeft: //set frame coordinates Xmin = 16; Xmax = 17; Yframe = 4; //always cut SetFrameMin(); //set speed animationDelay = 0.1f; //set the current animation CurType = type; break; case animationType.HitUp: //set frame coordinates Xmin = 16; Xmax = 17; Yframe = 5; //always cut SetFrameMin(); //set speed animationDelay = 0.1f; //set the current animation CurType = type; break; case animationType.HitJump: //set frame coordinates Xmin = 16; Xmax = 17; Yframe = 6; //always cut SetFrameMin(); //set speed animationDelay = 0.1f; //set the current animation CurType = type; break; case animationType.HitCrouch: //set frame coordinates Xmin = 16; Xmax = 17; Yframe = 7; //always cut SetFrameMin(); //set speed animationDelay = 0.1f; //set the current animation CurType = animationType.CrouchLeft; break; } } }
public void SetFallback( animationType type ) { //set fallback type FallbackType = type; }