// Update is called once per frame void Update() { if (isAnimating == false) { // Nothing for us to do. return; } if (Vector3.Distance( new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), targetPosition) < smoothDistance) { // We've reached the target position -- do we still have moves in the queue? if ( (moveQueue == null || moveQueueIndex == (moveQueue.Length)) && ((this.transform.position.y - smoothDistance) > targetPosition.y) ) { // We are totally out of moves (and too high up), the only thing left to do is drop down. this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), ref velocity, smoothTimeVertical); // Check for bops if (stoneToBop != null) { stoneToBop.ReturnToStorage(); stoneToBop = null; } } else { // Right position, right height -- let's advance the queue AdvanceMoveQueue(); } } else if (this.transform.position.y < (smoothHeight - smoothDistance)) { // We want to rise up before we move sideways. this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z), ref velocity, smoothTimeVertical); } else { // Normal movement (sideways) this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(targetPosition.x, smoothHeight, targetPosition.z), ref velocity, smoothTime); } }
void Update() { if (isAnimating == false) { return; } if (Vector3.Distance( new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), targetPosition) < smoothDistance) { // We've reached the target position -- do we still have moves in the queue? if ((moveQueue == null || moveQueueIndex == moveQueue.Length) && (this.transform.position.y - smoothDistance) > targetPosition.y ) { // We are above target position // Out of moves, drop down the stone this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), ref velocity, smoothTimeVertical); // Check for bops if (stoneToBop != null) { stoneToBop.ReturnToStorage(); stoneToBop = null; } } else { // Right position, right height, advance cube AdvanceMoveQueue(); } } // Rise stone up before moving sideways else if (this.transform.position.y < (smoothHeight - smoothDistance)) { this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z), ref velocity, smoothTimeVertical); } else { this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(targetPosition.x, smoothHeight, targetPosition.z), ref velocity, smoothTime); } }
private void Update() { if (m_IsAnimating == false) { return; } if (Vector3.Distance( new Vector3(this.transform.position.x, m_TargetPosition.y, this.transform.position.z), m_TargetPosition) < m_SmoothDistance) { // Reached the target position if ( (moveQueue == null || moveQueueIndex == (moveQueue.Length)) && ((this.transform.position.y - m_SmoothDistance) > m_TargetPosition.y) ) { // Out of moves, need to do is drop down. this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(this.transform.position.x, m_TargetPosition.y, this.transform.position.z), ref m_Velocity, m_SmoothTimeVertical); // Check to see if we need to remove an opponents stone if (m_StoneToBop != null) { m_StoneToBop.ReturnToStorage(); m_StoneToBop = null; } } else { AdvanceMoveQueue(); } } else if (this.transform.position.y < (m_SmoothHeight - m_SmoothDistance)) { // Rise up before moving sideways. this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(this.transform.position.x, m_SmoothHeight, this.transform.position.z), ref m_Velocity, m_SmoothTimeVertical); } else { // Sideways movement this.transform.position = Vector3.SmoothDamp( this.transform.position, new Vector3(m_TargetPosition.x, m_SmoothHeight, m_TargetPosition.z), ref m_Velocity, m_SmoothTime); } }
// Update is called once per frame void Update() { if (isAnimating == false) { //nothing for us todo. return; } if (Vector3.Distance(new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), targetPosition) < smoothDiatance) { //we've reached the target position -- do we still have moves in the queue? if ((moveQueue == null || moveQueueIndex == (moveQueue.Length)) && ((this.transform.position.y - smoothDiatance) > targetPosition.y) ) { // drop down this.transform.position = Vector3.SmoothDamp(this.transform.position, new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), ref velocity, smoothTimeVertical); //check for bops if (stoneToBop != null) { stoneToBop.ReturnToStorage(); stoneToBop = null; } } else { //right position,right height. AdvanceMoveQueue(); } } else if (this.transform.position.y < (smoothHeight - smoothDiatance)) { // rise up before move sideways. this.transform.position = Vector3.SmoothDamp(this.transform.position, new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z), ref velocity, smoothTimeVertical); } else { //normal movement this.transform.position = Vector3.SmoothDamp(this.transform.position, new Vector3(targetPosition.x, smoothHeight, targetPosition.z), ref velocity, smoothTime); } }
// Update is called once per frame void Update() { if (isAnimating == false) { return; } if (Vector3.Distance(new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), targetPosition) < smoothDistance) { //we have reached the target. do we still have moves in the queue? if ((moveQueue == null || moveQueueIndex == (moveQueue.Length)) && (this.transform.position.y - smoothDistance) > targetPosition.y) { //we are above our target //we are totally out of moves, only thing to do is drop down. this.transform.position = Vector3.SmoothDamp(this.transform.position, new Vector3(this.transform.position.x, targetPosition.y, this.transform.position.z), ref velocity, smoothTimeVertical); //check for bops if (stoneToBop != null) { stoneToBop.ReturnToStorage(); stoneToBop = null; } } else { //right pos, heigh -- advance queue AdvanceMoveQueue(); } } // we want to rise up before we move sideways else if (this.transform.position.y < (smoothHeight - smoothDistance)) { this.transform.position = Vector3.SmoothDamp(this.transform.position, new Vector3(this.transform.position.x, smoothHeight, this.transform.position.z), ref velocity, smoothTimeVertical); } else { this.transform.position = Vector3.SmoothDamp(this.transform.position, new Vector3(targetPosition.x, smoothHeight, targetPosition.z), ref velocity, smoothTime); } }