void Update() { UnitFrame?.Move(this); if (false && UnitFrame.NextMove?.MoveType == MoveType.Add) { Position FinalDestination = UnitFrame.NextMove.Positions[UnitFrame.NextMove.Positions.Count - 1]; HexCell targetCell = UnitFrame.HexGrid.GroundCells[FinalDestination]; Vector3 unitPos3 = targetCell.Cell.transform.localPosition; unitPos3.y += UnitFrame.HexGrid.hexCellHeight + AboveGround; transform.position = Vector3.MoveTowards(transform.position, unitPos3, 1); } else if (UnitFrame.NextMove?.MoveType == MoveType.Move || UnitFrame.NextMove?.MoveType == MoveType.Add) { Position FinalDestination = UnitFrame.NextMove.Positions[UnitFrame.NextMove.Positions.Count - 1]; HexCell targetCell = UnitFrame.HexGrid.GroundCells[FinalDestination]; Vector3 unitPos3 = targetCell.Cell.transform.localPosition; unitPos3.y += UnitFrame.HexGrid.hexCellHeight + AboveGround; if (UnitFrame.NextMove.Positions.Count > 0) { float speed = 1.75f / UnitFrame.HexGrid.GameSpeed; float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, unitPos3, step); UpdateDirection(unitPos3); } else { transform.position = Vector3.MoveTowards(transform.position, unitPos3, 1); } } }
// Update is called once per frame void Update() { UnitFrame?.Move(this); if (UnitFrame?.NextMove?.MoveType == MoveType.Upgrade) { if (UnitFrame.NextMove?.MoveType == MoveType.Upgrade && UnitFrame.NextMove?.Stats != null) { UnitFrame.MoveUpdateStats = UnitFrame.NextMove.Stats; UnitFrame.Assemble(); } if (particleSource == null) { Position from = UnitFrame.NextMove.Positions[0]; HexCell sourceCell = UnitFrame.HexGrid.GroundCells[from]; particleSource = UnitFrame.HexGrid.MakeParticleSource("ExtractSource"); particleSource.transform.SetParent(sourceCell.Cell.transform, false); } Position to = UnitFrame.NextMove.Positions[UnitFrame.NextMove.Positions.Count - 1]; HexCell targetCell = UnitFrame.HexGrid.GroundCells[to]; ParticleSystemForceField particleTarget = UnitFrame.HexGrid.MakeParticleTarget(); particleTarget.transform.SetParent(targetCell.Cell.transform, false); Vector3 unitPos3 = particleTarget.transform.position; unitPos3.y += 0.1f; particleTarget.transform.position = unitPos3; particleSource.externalForces.SetInfluence(0, particleTarget); HexGrid.Destroy(particleTarget, 2.5f); particleSource.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); var main = particleSource.main; main.duration = particleSource.main.duration * UnitFrame.HexGrid.GameSpeed; //particleSource.main.duration = particleSource.main.duration * UnitFrame.HexGrid.GameSpeed; particleSource.Play(); ParticleSystem particleDust = UnitFrame.HexGrid.MakeParticleSource("Build"); particleDust.transform.SetParent(targetCell.Cell.transform, false); particleDust.transform.position = particleTarget.transform.position; particleDust.Play(); HexGrid.Destroy(particleDust, 2.5f); UnitFrame.NextMove = null; } }
void Update() { UnitFrame?.Move(this); }