public Vector2 GetDirTo(PlanetAttachStatic target, bool horizontalOnly = false) { float x; switch (CheckSide(target)) { case Util.Side.Left: x = -1; break; case Util.Side.Right: x = 1; break; default: x = 0; break; } if (horizontalOnly) { return(new Vector2(x, 0)); } else { return((new Vector2(x, target.mPlanetPos.y - mPlanetPos.y)).normalized); } }
float _GetDelta(PlanetAttachStatic against) { float x = mPlanetPos.x, xAgainst = against.mPlanetPos.x; float d = x - xAgainst; if (d > planet.surfaceLength * 0.5f) { d -= planet.surfaceLength; } else if (d < -planet.surfaceLength * 0.5f) { d += planet.surfaceLength; } return(d); }
void Update() { switch (mCurState) { case State.Inactive: break; case State.Spawn: Transform t = EntityManager.instance.Spawn(type, null, null, null, useSpawnFX); mPoolController = t.GetComponentInChildren <PoolDataController>(); Vector3 pos = transform.position; t.position = new Vector3(pos.x, pos.y, t.position.z); PlanetAttachStatic pa = t.GetComponentInChildren <PlanetAttachStatic>(); if (pa != null) { pa.RefreshPos(); } ChangeState(State.SpawnWait); break; case State.SpawnWait: if (mPoolController != null) { if (mPoolController.claimed) { if (mCurTime >= delayRespawn) { ChangeState(State.Spawn); } else { mCurTime += Time.deltaTime; } } } else { ChangeState(State.Spawn); } break; } }
public Vector2 GetDirTo(PlanetAttachStatic target, bool horizontalOnly=false) { float x; switch(CheckSide(target)) { case Util.Side.Left: x = -1; break; case Util.Side.Right: x = 1; break; default: x = 0; break; } if(horizontalOnly) { return new Vector2(x, 0); } else { return (new Vector2(x, target.mPlanetPos.y - mPlanetPos.y)).normalized; } }
public Util.Side CheckSide(PlanetAttachStatic against) { float d = _GetDelta(against); return d == 0.0f ? Util.Side.None : d < 0.0f ? Util.Side.Right : Util.Side.Left; }
float _GetDelta(PlanetAttachStatic against) { float x=mPlanetPos.x, xAgainst = against.mPlanetPos.x; float d = x - xAgainst; if(d > planet.surfaceLength*0.5f) { d -= planet.surfaceLength; } else if(d < -planet.surfaceLength*0.5f) { d += planet.surfaceLength; } return d; }
public float GetDistanceHorizontal(PlanetAttachStatic target) { return Mathf.Abs(_GetDelta(target)); }
public float GetDistanceHorizontal(PlanetAttachStatic target) { return(Mathf.Abs(_GetDelta(target))); }
public Util.Side CheckSide(PlanetAttachStatic against) { float d = _GetDelta(against); return(d == 0.0f ? Util.Side.None : d < 0.0f ? Util.Side.Right : Util.Side.Left); }