public void levantar(ponto2D ponto, Vector3 position, Vector3 levantarStartPosition) { this.wargrid = ponto; this.newPosition = position; this.estado = tileStates.subir; this.gameObject.transform.position = levantarStartPosition; }
// Update is called once per frame void Update() { switch (this.estado) { case tileStates.descer: this.startPosition = this.gameObject.transform.position; this.estado = tileStates.descendo; break; case tileStates.subir: this.startPosition = this.gameObject.transform.position; this.estado = tileStates.subindo; break; case tileStates.inativo: this.fixedPosition = tilePoolCoord(this.poolPosition); this.estado = tileStates.idle; break; default: this.gameObject.transform.position = fixedPosition; this.gameObject.transform.rotation = fixedRotation; break; } //Movimenta o Tile caso esteja em um estado de movimento. if (this.estado == tileStates.subindo || this.estado == tileStates.descendo) { float lerpVelocity = 1 / (this.tileVelocity); this.gameObject.transform.position = Vector3.Lerp(startPosition, newPosition, lerpVelocity); this.startPosition = this.gameObject.transform.position; //Para o lerp ao final do movimento. if ( this.gameObject.transform.position == newPosition) { if (this.estado == tileStates.subindo) { this.estado = tileStates.ativo; this.fixedPosition = this.transform.position; this.fixedRotation = this.transform.rotation; } else { this.estado = tileStates.inativo; //this.fixedPosition = this.transform.position; //this.fixedRotation = this.transform.rotation; } } } /* // DEPRECATED CODE if (this.gameObject.GetComponent<NavMeshObstacle>().isActiveAndEnabled) { this.gameObject.GetComponent<Renderer>().material.color = Color.red; } else { this.gameObject.GetComponent<Renderer>().material.color = Color.grey; } if (this.colidindoComAliado) { this.gameObject.GetComponent<Renderer>().material.color = Color.blue; } */ }
private Vector3 startPosition; // posição inicial do movimento do tile #endregion Fields #region Methods public void abaixar(ponto2D ponto, Vector3 position) { this.newPosition = position; this.estado = tileStates.descer; }
// Use this for initialization void Start() { this.estado = tileStates.idle; this.gameObject.GetComponent<Renderer>().material.color = Color.grey; this.fixedPosition = this.transform.position; this.fixedRotation = this.transform.rotation; this.tileVelocity = 5; }