// Control method that is interfaced with from outside the class public bool CorrectPose(BodyFrame bf) { // Updates body frame data this._bf = bf; subject = retrieveBody(); if (subject == null) { currentStatus = BodyStatus.NONE; return(false); } if (!correctDistance(subject)) { return(false); } if (!handsCheck(subject) || !feetCheck(subject)) { return(false); } currentStatus = BodyStatus.CORRECT; return(true); }
public void Shoot() { isShoot = true; if (bodyStatus == BodyStatus.Up_Shoot || bodyStatus == BodyStatus.Up_Idle) { bodyStatus = BodyStatus.Up_Shoot; shootPos = shootPos_Up; z_Rotation = -90; } else { print(bodyStatus); if (bodyStatus == BodyStatus.Down_Shoot || bodyStatus == BodyStatus.Down_Idle) { shootPos = shootPos_Down; z_Rotation = 90; } else { bodyStatus = BodyStatus.Hor_Shoot; if (playMove.isRightDir) { shootPos = shootPos_Hor; z_Rotation = 180; } else { shootPos = shootPos_Hor; z_Rotation = 0; } } } }
void CheckGroundStatus() { RaycastHit hitInfo; // 0.1f is a small offset to start the ray from inside the character // it is also good to note that the transform position in the sample assets is at the base of the character Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, 15000); DistanceToGround = hitInfo.distance - 0.1f; groundNormal = hitInfo.normal; //if (transform.position.y<waterlevel.transform.position.y) { //bodyStatus = BodyStatus.isSwimming; //m_Rigidbody.mass = 0f; //animator.applyRootMotion = false; //} else if (bodyStatus == BodyStatus.isSwimming || (DistanceToGround < 0.1f && (bodyStatus == BodyStatus.isJumping) && m_Rigidbody.velocity.y < 0.01f)) { bodyStatus = BodyStatus.isOnGround; m_Rigidbody.mass = 1f; //animator.applyRootMotion = true; } else if (DistanceToGround < 10 && bodyStatus == BodyStatus.isFlying) { bodyStatus = BodyStatus.isJumping; } else if (DistanceToGround > 15 && bodyStatus == BodyStatus.isJumping && ReadyToFly) { bodyStatus = BodyStatus.isFlying; m_Rigidbody.mass = 0f; ReadyToFly = false; } }
/// <summary> /// /// </summary> /// <param name="canCollide"></param> /// <param name="sleepingAllowed"></param> /// <param name="fixedRotation"></param> /// <param name="status"></param> /// <param name="fixtures"></param> /// <param name="joints"></param> /// <param name="mass">Current Mass of the entity.</param> /// <param name="linearVelocity">Current linear velocity of the entity in meters per second.</param> /// <param name="angularVelocity">Current angular velocity of the entity in radians per sec.</param> /// <param name="bodyType"></param> public PhysicsComponentState( bool canCollide, bool sleepingAllowed, bool fixedRotation, BodyStatus status, List <Fixture> fixtures, List <Joint> joints, float mass, Vector2 linearVelocity, float angularVelocity, BodyType bodyType) : base(NetIDs.PHYSICS) { CanCollide = canCollide; SleepingAllowed = sleepingAllowed; FixedRotation = fixedRotation; Status = status; Fixtures = fixtures; Joints = joints; LinearVelocity = linearVelocity; AngularVelocity = angularVelocity; Mass = (int)Math.Round(mass * 1000); // rounds kg to nearest gram BodyType = bodyType; }
public CollidableComponentState(bool canCollide, BodyStatus status, List <IPhysShape> physShapes) : base(NetIDs.COLLIDABLE) { CanCollide = canCollide; Status = status; PhysShapes = physShapes; }
/// <inheritdoc /> public override void HandleComponentState(ComponentState?curState, ComponentState?nextState) { if (curState == null) { return; } var newState = (CollidableComponentState)curState; _canCollide = newState.CanCollide; _status = newState.Status; //TODO: Is this always true? if (newState.PhysShapes != null) { _physShapes = newState.PhysShapes; foreach (var shape in _physShapes) { shape.ApplyState(); } Dirty(); UpdateEntityTree(); } }
// Distance from camera (just depth) to ensure subject isn't too far or too close private bool correctDistance(Body body) { double actualDistanceFromCam = getDistance(subject); double difference = actualDistanceFromCam - targetDistanceFromCam; double abs_diff = Math.Abs(difference); if (abs_diff > distanceTolerance) { // Replace with some sort of visual feedback for liveness if (difference < 0) { currentStatus = BodyStatus.TOO_CLOSE; Log.Write("Move away: " + abs_diff + " metres"); } else if (abs_diff > 0) { currentStatus = BodyStatus.TOO_CLOSE; Log.Write("Move closer: " + abs_diff + " metres"); } needToMove = Math.Round(abs_diff, 2); return(false); } else { needToMove = 0; } return(true); }
void CheckGroundStatus() { RaycastHit hitInfo; // 0.1f is a small offset to start the ray from inside the character // it is also good to note that the transform position in the sample assets is at the base of the character Physics.Raycast (transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, 15000); DistanceToGround = hitInfo.distance - 0.1f; groundNormal = hitInfo.normal; if (transform.position.y<waterlevel.transform.position.y) { bodyStatus = BodyStatus.isSwimming; m_Rigidbody.mass = 0f; //animator.applyRootMotion = false; } else if (bodyStatus == BodyStatus.isSwimming || (DistanceToGround < 0.1f && (bodyStatus == BodyStatus.isJumping) && m_Rigidbody.velocity.y <0.01f)) { bodyStatus = BodyStatus.isOnGround; m_Rigidbody.mass = 1f; //animator.applyRootMotion = true; } else if (DistanceToGround < 10 && bodyStatus == BodyStatus.isFlying) { bodyStatus = BodyStatus.isJumping; } else if (DistanceToGround > 15 && bodyStatus == BodyStatus.isJumping && ReadyToFly) { bodyStatus = BodyStatus.isFlying; m_Rigidbody.mass = 0f; ReadyToFly=false; } }
public void Init(float maxHP, float showInfectedThreshold, float healthDecreaseRateOnInfected) { this.bodyStatus = BodyStatus.NORMAL; this.maxHP = maxHP; this.showInfectedThreshold = showInfectedThreshold; this.healthDecreaseRateOnInfected = healthDecreaseRateOnInfected; this.currentHP = this.maxHP; }
void StartJumping() { if (m_Rigidbody.useGravity == false) { m_Rigidbody.useGravity = true; } m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, jumpPower, m_Rigidbody.velocity.z); bodyStatus = BodyStatus.isJumping; }
void StartFalling() { if (m_Rigidbody.useGravity == false) { m_Rigidbody.useGravity = true; } ReadyToFly = false; bodyStatus = BodyStatus.isJumping; }
// REST GETを試す public IEnumerator Get(string url) { var request = new UnityWebRequest(); request.downloadHandler = new DownloadHandlerBuffer(); request.url = url; request.SetRequestHeader("Content-Type", "application/json; charset=UTF-8"); request.method = UnityWebRequest.kHttpVerbGET; yield return(request.SendWebRequest()); if (request.result == UnityWebRequest.Result.ConnectionError) { Debug.Log(request.error); } else { if (request.responseCode == 200) { Debug.Log("success"); BodyStatus bs = JsonUtility.FromJson <BodyStatus>(request.downloadHandler.text); // x float valLeft = bs.accelLeft[0] / 4000 * 100; float valRight = bs.accelRight[0] / 4000 * 100; Debug.Log(bs.accelLeft[0]); if (0 < valLeft) { val1 = valLeft; val2 = 0; } else { val1 = 0; val2 = -valLeft; } if (0 < valRight) { val3 = valRight; val4 = 0; } else { val3 = 0; val4 = -valRight; } } else { Debug.Log("failed"); } } }
/// <summary> /// /// </summary> /// <param name="canCollide"></param> /// <param name="status"></param> /// <param name="physShapes"></param> /// <param name="hard"></param> /// <param name="mass">Current Mass of the entity.</param> /// <param name="linearVelocity">Current linear velocity of the entity in meters per second.</param> /// <param name="angularVelocity">Current angular velocity of the entity in radians per sec.</param> /// <param name="anchored">Whether or not the entity is anchored in place.</param> public PhysicsComponentState(bool canCollide, BodyStatus status, List <IPhysShape> physShapes, bool hard, float mass, Vector2 linearVelocity, float angularVelocity, bool anchored) : base(NetIDs.PHYSICS) { CanCollide = canCollide; Status = status; PhysShapes = physShapes; Hard = hard; LinearVelocity = linearVelocity; AngularVelocity = angularVelocity; Mass = (int)Math.Round(mass * 1000); // rounds kg to nearest gram Anchored = anchored; }
public override void _Ready() { _bodyStatus = new BodyStatus() { bodyDestroyed = false, bodyHealth = 1 }; _bossBodyHealthSetter = GetNode <HealthSetter>(bossBodyNodePath); _bossBodyHealthSetter.healthChanged += HandleBodyHealthChanged; HandleBodyHealthChanged(_bossBodyHealthSetter.GetCurrentHealth(), _bossBodyHealthSetter.GetMaxHealth()); }
public void Shoot() { isShoot = true; bodyStatus = BodyStatus.Hor_Shoot; legStatus = LegStatus.DownShoot; if (playMove.isRightDir) { shootPos = shootPos_HorDown; z_Rotation = 180; } else { shootPos = shootPos_HorDown; z_Rotation = 0; } }
// Checks that feet are within a certain margin of each other on the Y axis private bool feetCheck(Body body) { Joint rightKnee = subject.Joints[JointType.ElbowRight]; Joint rightFoot = subject.Joints[JointType.FootRight]; Joint leftFoot = subject.Joints[JointType.FootLeft]; double lowerLegLength = jointDistance(rightKnee, rightFoot); if (compareJointsAxis(PointCloud.Axis.Y, leftFoot, rightFoot) > jointTolerance * lowerLegLength) { currentStatus = BodyStatus.WRONG_POSE; return(false); } return(true); }
void Start() { ReadyToFly = false; bodyStatus = BodyStatus.isOnGround; animator = GetComponent <Animator>(); m_Rigidbody = GetComponent <Rigidbody>(); m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotation; //try { moveSpeedMultiplier = GameInformation.BasePlayer.Balance / 20f; } //catch (System.Exception) {moveSpeedMultiplier = 5f;throw;} //PlayerMass = GameInformation.BasePlayer.Momentum / 100f; //jumpPower = 5 * (GameInformation.BasePlayer.Balance / GameInformation.BasePlayer.Momentum); jumpPower = 5f; moveSpeedMultiplier = 5f; PlayerMass = 1f; }
/// <summary> /// /// </summary> /// <param name="canCollide"></param> /// <param name="sleepingAllowed"></param> /// <param name="fixedRotation"></param> /// <param name="status"></param> /// <param name="linearVelocity">Current linear velocity of the entity in meters per second.</param> /// <param name="angularVelocity">Current angular velocity of the entity in radians per sec.</param> /// <param name="bodyType"></param> public PhysicsComponentState( bool canCollide, bool sleepingAllowed, bool fixedRotation, BodyStatus status, Vector2 linearVelocity, float angularVelocity, BodyType bodyType) { CanCollide = canCollide; SleepingAllowed = sleepingAllowed; FixedRotation = fixedRotation; Status = status; LinearVelocity = linearVelocity; AngularVelocity = angularVelocity; BodyType = bodyType; }
public void Update() { if (bodyStatus == BodyStatus.DEATH) { return; } if (bodyStatus == BodyStatus.INFECTED_HIDDEN || bodyStatus == BodyStatus.INFECTED_SHOWN) { currentHP -= healthDecreaseRateOnInfected; if (currentHP <= 0) { Die(); } else if (currentHP < showInfectedThreshold) { bodyStatus = BodyStatus.INFECTED_SHOWN; } } }
public void Write(string dir) { // Set the BodyStatus to complete to prevent test errors BodyStatus = BodyStatus.TestComp; // Save final frame index to storedata //StoreData.ind_fr[button_num - 1] = fr; StoreData.ind_fr[button_num - 1] = fr; // This makes sure that the trailing zeros get deleted from the jagged arrays containing the joint positions and orientations StoreData.set_actual_length(fr, button_num - 1); // At the end of each condition let's save the output csv files WriteBodyData WBD = new WriteBodyData(); WBD.writeJoints(dir, button_num - 1, fr, StoreData); //if (JointTS) WriteTrackingData.TrackingStateToCSV(dir, button_num - 1, fr); fr = 0; }
// Checks that hands are within a certain margin of each other on the Y axis private bool handsCheck(Body body) { Joint rightElbow = subject.Joints[JointType.ElbowRight]; // used for calculating arm length to measure tolerance Joint rightHand = subject.Joints[JointType.HandRight], leftHand = subject.Joints[JointType.HandLeft]; Joint rightHip = subject.Joints[JointType.HipRight], leftHip = subject.Joints[JointType.HipLeft]; if (rightHip.Position.Y < rightHand.Position.Y || leftHip.Position.Y < leftHand.Position.Y) { currentStatus = BodyStatus.WRONG_POSE; return(false); } double forearmLength = jointDistance(rightElbow, rightHand); if (compareJointsAxis(PointCloud.Axis.Y, leftHand, rightHand) > jointTolerance * forearmLength) { currentStatus = BodyStatus.WRONG_POSE; return(false); } return(true); }
public void Destroy(Body body) { Status = BodyStatus.Destroyed; ExplosionAnimation.Activate (body); //body.DestroyFixture(); body.Dispose(); }
// Update is called once per frame void Update() { //bodyStatus = BodyStatus.Hor_Throw; print(bodyStatus); //上身srBody= 向上射击、静止 横向射击、静止 switch (bodyStatus) { case BodyStatus.Hor_Shoot: timerBody_Hor_Shoot += Time.deltaTime; if (timerBody_Hor_Shoot > animIntervalBody_Hor_Shoot) { timerBody_Hor_Shoot -= animIntervalBody_Hor_Shoot; animIndexBody_Hor_Shoot++; animIndexBody_Hor_Shoot %= animLengthBody_Hor_Shoot; srBody.sprite = spBody_Hor_Shoot[animIndexBody_Hor_Shoot]; if (animIndexBody_Hor_Shoot == 2) { Shoot(); Instantiate(projectile, new Vector3(shootPos.position.x, shootPos.position.y), Quaternion.Euler(0, 0, z_Rotation)); AudioSource.PlayClipAtPoint(playMove.soundShoot, new Vector3(0, 0, 0)); } if (animIndexBody_Hor_Shoot == animLengthBody_Up_Shoot - 1) { isShoot = false; bodyStatus = BodyStatus.Hor_Idle; } } break; case BodyStatus.Hor_Atk: timerBody_Hor_Atk += Time.deltaTime; if (timerBody_Hor_Atk > animIntervalBody_Hor_Atk) { timerBody_Hor_Atk -= animIntervalBody_Hor_Atk; animIndexBody_Hor_Atk++; animIndexBody_Hor_Atk %= animLengthBody_Hor_Atk; srBody.sprite = spBody_Hor_Atk[animIndexBody_Hor_Atk]; if (animIndexBody_Hor_Atk == 2) { AudioSource.PlayClipAtPoint(playMove.soundTieGuo, new Vector3(0, 0, 0)); } if (animIndexBody_Hor_Atk == animLengthBody_Hor_Atk - 1) { isShoot = false; bodyStatus = BodyStatus.Hor_Idle; } } break; case BodyStatus.Hor_Idle: timerBody_Hor_Idle += Time.deltaTime; if (timerBody_Hor_Idle > animIntervalBody_Hor_Idle) { timerBody_Hor_Idle -= animIntervalBody_Hor_Idle; animIndexBody_Hor_Idle++; animIndexBody_Hor_Idle %= animLengthBody_Hor_Idle; srBody.sprite = spBody_Hor_Idle[animIndexBody_Hor_Idle]; } break; case BodyStatus.Hor_Throw: timerBody_Hor_Throw += Time.deltaTime; if (timerBody_Hor_Throw > animIntervalBody_Hor_Throw) { timerBody_Hor_Throw -= animIntervalBody_Hor_Throw; animIndexBody_Hor_Throw++; print(animIndexBody_Hor_Throw + " " + Time.deltaTime); animIndexBody_Hor_Throw %= animLengthBody_Hor_Throw; srBody.sprite = spBody_Hor_Throw[animIndexBody_Hor_Throw]; if (animIndexBody_Hor_Throw == 2) { Instantiate(sld, new Vector3(throwPos.position.x, throwPos.position.y), Quaternion.Euler(0, 0, 0)); //AudioSource.PlayClipAtPoint(playMove.soundShoot, new Vector3(0, 0, 0)); } if (animIndexBody_Hor_Throw == animLengthBody_Hor_Throw - 1) { isThrow = false; bodyStatus = BodyStatus.Hor_Idle; } } break; case BodyStatus.Up_Shoot: timerBody_Up_Shoot += Time.deltaTime; if (timerBody_Up_Shoot > animIntervalBody_Up_Shoot) { timerBody_Up_Shoot -= animIntervalBody_Up_Shoot; animIndexBody_Up_Shoot++; animIndexBody_Up_Shoot %= animLengthBody_Up_Shoot; srBody.sprite = spBody_Up_Shoot[animIndexBody_Up_Shoot]; if (animIndexBody_Up_Shoot == 2) { Shoot(); Instantiate(projectile, new Vector3(shootPos.position.x, shootPos.position.y), Quaternion.Euler(0, 0, z_Rotation)); AudioSource.PlayClipAtPoint(playMove.soundShoot, new Vector3(0, 0, 0)); } if (animIndexBody_Up_Shoot == animLengthBody_Up_Shoot - 1) { isShoot = false; bodyStatus = BodyStatus.Up_Idle; } } break; case BodyStatus.Up_Idle: timerBody_Up_Idle += Time.deltaTime; if (timerBody_Up_Idle > animIntervalBody_Up_Idle) { timerBody_Up_Idle -= animIntervalBody_Up_Idle; animIndexBody_Up_Idle++; animIndexBody_Up_Idle %= animLengthBody_Up_Idle; srBody.sprite = spBody_Up_Idle[animIndexBody_Up_Idle]; } break; default: break; } #region leg //下身srLeg= switch (legStatus) { case LegStatus.Idle: timerLeg_Idle += Time.deltaTime; if (timerLeg_Idle > animIntervalLeg_Idle) { timerLeg_Idle -= animIntervalLeg_Idle; animIndexLeg_Idle++; animIndexLeg_Idle %= animLengthLeg_Idle; srLeg.sprite = spLeg_Idle[animIndexLeg_Idle]; } break; case LegStatus.Walk: timerLeg_Walk += Time.deltaTime; if (timerLeg_Walk > animIntervalLeg_Walk) { timerLeg_Walk -= animIntervalLeg_Walk; animIndexLeg_Walk++; animIndexLeg_Walk %= animLengthLeg_Walk; srLeg.sprite = spLeg_Walk[animIndexLeg_Walk]; } break; default: break; } #endregion }
public void Throw() { isThrow = true; bodyStatus = BodyStatus.Hor_Throw; }
public void Die() { bodyStatus = BodyStatus.DEATH; }
void Start() { ReadyToFly = false; bodyStatus = BodyStatus.isOnGround; animator = GetComponent<Animator>(); m_Rigidbody = GetComponent<Rigidbody>(); try { moveSpeedMultiplier = GameInformation.BasePlayer.Balance / 20f; } catch (System.Exception) {moveSpeedMultiplier = 5f;throw;} m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotation; PlayerMass = GameInformation.BasePlayer.Momentum / 100f; jumpPower = 5 * (GameInformation.BasePlayer.Balance / GameInformation.BasePlayer.Momentum); }
void StartFalling() { if (m_Rigidbody.useGravity == false) m_Rigidbody.useGravity = true; ReadyToFly = false; bodyStatus = BodyStatus.isJumping; }
void StartJumping() { if(m_Rigidbody.useGravity == false) m_Rigidbody.useGravity = true; m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, jumpPower, m_Rigidbody.velocity.z); bodyStatus = BodyStatus.isJumping; }
/// <summary> /// extract body data from body frame data /// </summary> /// <param name="bodyframe"></param> void ExtractBodyData(BodyFrame bodyframe) { if (bodyframe == null) { return; } using (bodyframe) { // if the array isn't there, make a new one if (bodies == null) { bodies = new Body[bodyframe.BodyCount]; } // update the array bodyframe.GetAndRefreshBodyData(bodies); //analyze all bodies and get the closest one singlebody = GetClosestBody(); floorplane = bodyframe.FloorClipPlane; tt = bodyframe.RelativeTime; } // make sure that tere is abody to track if (singlebody == null) { //skipframe = true; return; } // Identify a single body that's been tracked and use its index to track the right joints left_wrist = singlebody.Joints[JointType.WristLeft]; left_hip = singlebody.Joints[JointType.HipLeft]; right_wrist = singlebody.Joints[JointType.WristRight]; right_hip = singlebody.Joints[JointType.HipRight]; left_ankle = singlebody.Joints[JointType.AnkleLeft]; right_ankle = singlebody.Joints[JointType.AnkleRight]; spineBase = singlebody.Joints[JointType.SpineBase]; spineTop = singlebody.Joints[JointType.SpineShoulder]; // Additional joints to be saved to a text file for data analysis spine_mid = singlebody.Joints[JointType.SpineMid]; shoulder_left = singlebody.Joints[JointType.ShoulderLeft]; shoulder_right = singlebody.Joints[JointType.ShoulderRight]; elbow_left = singlebody.Joints[JointType.ElbowLeft]; elbow_right = singlebody.Joints[JointType.ElbowRight]; head = singlebody.Joints[JointType.Head]; knee_left = singlebody.Joints[JointType.KneeLeft]; knee_right = singlebody.Joints[JointType.KneeRight]; neck = singlebody.Joints[JointType.Neck]; thumb_left = singlebody.Joints[JointType.ThumbLeft]; thumb_right = singlebody.Joints[JointType.ThumbRight]; foot_left = singlebody.Joints[JointType.FootLeft]; foot_right = singlebody.Joints[JointType.FootRight]; hand_left = singlebody.Joints[JointType.HandLeft]; hand_right = singlebody.Joints[JointType.HandRight]; hand_tip_left = singlebody.Joints[JointType.HandTipLeft]; hand_tip_right = singlebody.Joints[JointType.HandTipRight]; // setup hand detection data //right_hand_status = -2; //left_hand_status = -2; if (fr == 0) { first = tt.TotalMilliseconds; Timestamps[fr] = 0; } else { if ((Timestamps[fr] - Timestamps[fr - 1]) > (1000 / 5)) { BodyStatus = BodyStatus.FrameRateError; } } if (!singlebody.IsTracked || (left_wrist.TrackingState == TrackingState.NotTracked || left_hip.TrackingState == TrackingState.NotTracked || right_wrist.TrackingState == TrackingState.NotTracked || right_hip.TrackingState == TrackingState.NotTracked || left_ankle.TrackingState == TrackingState.NotTracked || right_ankle.TrackingState == TrackingState.NotTracked || spineBase.TrackingState == TrackingState.NotTracked || spineTop.TrackingState == TrackingState.NotTracked)) { BodyStatus = BodyStatus.JointNotTracked; } else if (singlebody.Joints[JointType.SpineBase].Position.Z >= 4) { BodyStatus = BodyStatus.FarAway; } else if (singlebody.ClippedEdges != FrameEdges.None) { BodyStatus = BodyStatus.CloseToEdge; } else { BodyStatus = BodyStatus.Good; } if (BodyStatus != BodyStatus.Good) { ; } //skipframe = true; }
public void SetInfected() { bodyStatus = BodyStatus.INFECTED_HIDDEN; }
public void Cure() { bodyStatus = BodyStatus.NORMAL; currentHP = maxHP; }
public void Shoot() { isShoot = true; if (bodyStatus == BodyStatus.Up_Shoot || bodyStatus == BodyStatus.Up_Idle) { bodyStatus = BodyStatus.Up_Shoot; shootPos = shootPos_Up; z_Rotation = -90; } else { bodyStatus = BodyStatus.Hor_Shoot; if (playMove.isRightDir) { shootPos = shootPos_Hor; z_Rotation = 180; } else { shootPos = shootPos_Hor; z_Rotation = 0; } } }
// Update is called once per frame void Update() { //bodyStatus = BodyStatus.Hor_Throw; print(bodyStatus); //上身srBody= 向上射击、静止 横向射击、静止 switch (bodyStatus) { case BodyStatus.Hor_Shoot: timerBody_Hor_Shoot += Time.deltaTime; if (timerBody_Hor_Shoot > animIntervalBody_Hor_Shoot) { timerBody_Hor_Shoot -= animIntervalBody_Hor_Shoot; animIndexBody_Hor_Shoot++; animIndexBody_Hor_Shoot %= animLengthBody_Hor_Shoot; srBody.sprite = spBody_Hor_Shoot[animIndexBody_Hor_Shoot]; if (animIndexBody_Hor_Shoot == 2) { Shoot(); Instantiate(projectile, new Vector3(shootPos.position.x, shootPos.position.y), Quaternion.Euler(0, 0, z_Rotation)); AudioSource.PlayClipAtPoint(playMove.soundShoot, new Vector3(0, 0, 0)); } if (animIndexBody_Hor_Shoot == animLengthBody_Up_Shoot - 1) { isShoot = false; bodyStatus = BodyStatus.Hor_Idle; } } break; case BodyStatus.Hor_Atk: timerBody_Hor_Atk += Time.deltaTime; if (timerBody_Hor_Atk > animIntervalBody_Hor_Atk) { timerBody_Hor_Atk -= animIntervalBody_Hor_Atk; animIndexBody_Hor_Atk++; animIndexBody_Hor_Atk %= animLengthBody_Hor_Atk; srBody.sprite = spBody_Hor_Atk[animIndexBody_Hor_Atk]; if (animIndexBody_Hor_Atk == 2) { AudioSource.PlayClipAtPoint(playMove.soundTieGuo, new Vector3(0, 0, 0)); } if (animIndexBody_Hor_Atk == animLengthBody_Hor_Atk - 1) { isShoot = false; bodyStatus = BodyStatus.Hor_Idle; } } break; case BodyStatus.Hor_Idle: timerBody_Hor_Idle += Time.deltaTime; if (timerBody_Hor_Idle > animIntervalBody_Hor_Idle) { timerBody_Hor_Idle -= animIntervalBody_Hor_Idle; animIndexBody_Hor_Idle++; animIndexBody_Hor_Idle %= animLengthBody_Hor_Idle; srBody.sprite = spBody_Hor_Idle[animIndexBody_Hor_Idle]; } break; case BodyStatus.Hor_Throw: timerBody_Hor_Throw += Time.deltaTime; if (timerBody_Hor_Throw > animIntervalBody_Hor_Throw) { timerBody_Hor_Throw -= animIntervalBody_Hor_Throw; animIndexBody_Hor_Throw++; print(animIndexBody_Hor_Throw+" "+Time.deltaTime); animIndexBody_Hor_Throw %= animLengthBody_Hor_Throw; srBody.sprite = spBody_Hor_Throw[animIndexBody_Hor_Throw]; if (animIndexBody_Hor_Throw == 2) { Instantiate(sld, new Vector3(throwPos.position.x, throwPos.position.y), Quaternion.Euler(0, 0, 0)); //AudioSource.PlayClipAtPoint(playMove.soundShoot, new Vector3(0, 0, 0)); } if (animIndexBody_Hor_Throw == animLengthBody_Hor_Throw - 1) { isThrow = false; bodyStatus = BodyStatus.Hor_Idle; } } break; case BodyStatus.Up_Shoot: timerBody_Up_Shoot += Time.deltaTime; if (timerBody_Up_Shoot > animIntervalBody_Up_Shoot) { timerBody_Up_Shoot -= animIntervalBody_Up_Shoot; animIndexBody_Up_Shoot++; animIndexBody_Up_Shoot %= animLengthBody_Up_Shoot; srBody.sprite = spBody_Up_Shoot[animIndexBody_Up_Shoot]; if (animIndexBody_Up_Shoot == 2) { Shoot(); Instantiate(projectile, new Vector3(shootPos.position.x, shootPos.position.y), Quaternion.Euler(0, 0, z_Rotation)); AudioSource.PlayClipAtPoint(playMove.soundShoot, new Vector3(0, 0, 0)); } if (animIndexBody_Up_Shoot == animLengthBody_Up_Shoot - 1) { isShoot = false; bodyStatus = BodyStatus.Up_Idle; } } break; case BodyStatus.Up_Idle: timerBody_Up_Idle += Time.deltaTime; if (timerBody_Up_Idle > animIntervalBody_Up_Idle) { timerBody_Up_Idle -= animIntervalBody_Up_Idle; animIndexBody_Up_Idle++; animIndexBody_Up_Idle %= animLengthBody_Up_Idle; srBody.sprite = spBody_Up_Idle[animIndexBody_Up_Idle]; } break; default: break; } #region leg //下身srLeg= switch (legStatus) { case LegStatus.Idle: timerLeg_Idle += Time.deltaTime; if (timerLeg_Idle > animIntervalLeg_Idle) { timerLeg_Idle -= animIntervalLeg_Idle; animIndexLeg_Idle++; animIndexLeg_Idle %= animLengthLeg_Idle; srLeg.sprite = spLeg_Idle[animIndexLeg_Idle]; } break; case LegStatus.Walk: timerLeg_Walk += Time.deltaTime; if (timerLeg_Walk > animIntervalLeg_Walk) { timerLeg_Walk -= animIntervalLeg_Walk; animIndexLeg_Walk++; animIndexLeg_Walk %= animLengthLeg_Walk; srLeg.sprite = spLeg_Walk[animIndexLeg_Walk]; } break; default: break; } #endregion }
public void Throw() { isThrow = true; bodyStatus = BodyStatus.Hor_Throw; legStatus = LegStatus.DownShoot; }