public override IEnumerator IEResolve() { Debug.Log("Starting Flight's IEResolve"); running = true; ActionReq a = actions[0]; GameGrid2D gg = a.t == pb.pobj.playerId ? pb.playerGrid : pb.enemyGrid; // Select grid to get coord's Cell2D cell = gg.GetCell(a.loc[0]); CellStruct cs = a.t == pb.pobj.playerId ? pGrid[(int)a.loc[0].x, (int)a.loc[0].y] : eGrid[(int)a.loc[0].x, (int)a.loc[0].y]; //TODO change this garbage float time = 0; while (time <= delay) //Delay first { time += Time.deltaTime; yield return(null); } time = 0; //Delay artificially for a bit; cell.OnBuild(); cell.SetCellStruct(cs); while (time <= buildDelay) { time += Time.deltaTime; yield return(null); } running = false; Destroy(gameObject); }
public override IEnumerator IEResolve() { running = true; Debug.Log("Starting Flight's IEResolve"); float time = 0; //Delay first while (time <= delay) { time += Time.deltaTime; yield return(null); } time = 0; // Now launch trailParticle.Play(false); while (time <= duration) { float interpolant = time / duration; //Set new scale float scale = Mathf.Lerp(scaleMin, scaleMax, curve.Evaluate(interpolant)); Vector3 newscale = new Vector3(orig_scale.x * scale, orig_scale.y * scale, orig_scale.z); // Scale object up and down based on curve, multipled by height scalar transform.localScale = newscale; //Set new position Vector3 newpos = Vector3.Lerp(startpos, endpos, interpolant); newpos.z = orig_z; transform.position = newpos; //Update rotation rock.transform.Rotate(new Vector3(0, 0, rotation * Time.deltaTime)); //Update time and yield time += Time.deltaTime; yield return(null); } Debug.Log("Projectile has landed"); //the projectile has landed, play sound, update cell, etc. ActionReq a = actions[0]; GameGrid2D gg = a.t == pb.pobj.playerId ? pb.playerGrid : pb.enemyGrid; // Select grid to get coord's Cell2D cell = gg.GetCell(a.loc[0]); CellStruct cs = a.t == pb.pobj.playerId ? pGrid[(int)a.loc[0].x, (int)a.loc[0].y] : eGrid[(int)a.loc[0].x, (int)a.loc[0].y]; //TODO change this garbage cell.OnHit(); cell.SetCellStruct(cs); running = false; // Say we're done running when we hit the end location StartCoroutine(IEFade()); }