Esempio n. 1
0
    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);
        }
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    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));
 }
Esempio n. 8
0
 public float GetDistanceHorizontal(PlanetAttachStatic target)
 {
     return(Mathf.Abs(_GetDelta(target)));
 }
Esempio n. 9
0
    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);
    }