Exemplo n.º 1
0
 public void calculateGlobalspeedAndRelateVec(SCENE_OBJ one, SCENE_OBJ other)
 {
     one.computeGlobalSpeed();
     other.computeGlobalSpeed();
     one.relateVec   = other.globalSpeedVec - one.globalSpeedVec;//point to self
     other.relateVec = -one.relateVec;
 }
Exemplo n.º 2
0
    void clearDeath()
    {
        for (int i = 0; i < SCENE_OBJ.ALL.Count; i++)
        {
            SCENE_OBJ obj = SCENE_OBJ.ALL[i];
            if (obj.canDestroy)
            {
                obj.pool.delete(obj);
            }
        }
        for (int i = 0; i < AudioObj.globalAudio.Count; i++)
        {
            AudioObj obj = AudioObj.globalAudio[i];
            if (!obj.audioSrc.isPlaying)
            {
                obj.deleteFromScene();
            }
        }

        if (Explode.pool.live != null)
        {
            for (int i = 0; i < Explode.pool.live.Count; i++)
            {
                Explode obj = Explode.pool.live[i];
                if (!obj.src.isPlaying)
                {
                    obj.deleteFormScene();
                }
            }
        }
    }
Exemplo n.º 3
0
    virtual public bool isObjsMatchCondition(SCENE_OBJ obj)
    {
        if (obj == this)
        {
            return(false);
        }

        if (relateVec == Vector3.zero)
        {
            return(false);
        }

        Vector3 distVec = obj.transform.position - transform.position;

        float getAWayOrNearDot = Vector3.Dot(relateVec, distVec.normalized);
        //if (getAWayOrNearDot >= 0) //is getting away
        //    return false;

        float distSqr = distVec.sqrMagnitude;
        //float possibleDist = dimension + obj.dimension;
        //if (dist > possibleDist)//too far away
        //    return false;

        float relateSpeed  = Mathf.Abs(getAWayOrNearDot);
        float possibleDist = relateSpeed * MainLoop.lastFrameTime + dimension + obj.dimension;

        if (distSqr > possibleDist * possibleDist)
        {
            return(false);
        }



        return(true);
    }
Exemplo n.º 4
0
    public void informBelongToObj(ContactInfo info)
    {
        SCENE_OBJ belongTo = belongToObj;

        while (belongTo != null)
        {
            belongTo.collideAction(info);
            belongTo = belongTo.belongToObj;
        }
    }
Exemplo n.º 5
0
 public void copy(ContactInfo otherInfo)
 {
     self              = otherInfo.self;
     other             = otherInfo.other;
     extraObj          = otherInfo.extraObj;
     coupleContactInfo = otherInfo.coupleContactInfo;
     blockDirect       = otherInfo.blockDirect;
     selfVertex        = otherInfo.selfVertex;
     otherSurface      = otherInfo.otherSurface;
 }
Exemplo n.º 6
0
    public SURFACE otherSurface; //correspond to the surface of CollideInfo

    public void reset()
    {
        other             = null;
        extraObj          = null;
        coupleContactInfo = null;
        blockDirect       = Vector3.zero;
        selfVertex        = null;
        selfSurface       = null;
        otherSurface      = null;
    }
Exemplo n.º 7
0
    public virtual void postProcess()
    {
        //run obj postprocess First
        for (int i = 0; i < SCENE_OBJ.ALL.Count; i++)
        {
            SCENE_OBJ obj = SCENE_OBJ.ALL[i];
            obj.postProcess();
        }

        clearDeath();
    }
Exemplo n.º 8
0
 public void init(VERTEX[] inPoints, int[,] surfaceVertexIndex, int surfaceIndex, SCENE_OBJ obj)
 {
     for (int i = 0; i < points.Length; i++)
     {
         int tt = surfaceVertexIndex[surfaceIndex, i];
         points[i] = inPoints[tt];
         points[i].belongToSurfaces.Add(this);
     }
     index       = surfaceIndex;
     belongToObj = obj;
 }
Exemplo n.º 9
0
    public void computeGlobalSpeed()
    {
        globalSpeedVec = speedVec;
        SCENE_OBJ belongTo = belongToObj;

        while (belongTo != null)
        {
            globalSpeedVec += belongTo.speedVec;
            belongTo        = belongTo.belongToObj;
        }
    }
Exemplo n.º 10
0
 public void init()
 {
     minCollideTime   = -1;
     collidePoint     = Vector3.zero;
     collideSurfaceP0 = Vector3.zero;
     collideSurfaceP1 = Vector3.zero;
     intersectPoint   = Vector3.zero;
     vertex           = null;
     surface          = null;
     node             = null;
     reachGoalobj     = null;
 }
Exemplo n.º 11
0
    public static SCENE_OBJ createFromPool(IPool <SCENE_OBJ> sceneObjPool)
    {
        SCENE_OBJ TObj = sceneObjPool.create();

        if (TObj == null)
        {
            return(null);
        }
        TObj.transform.parent = Stage.onStage;

        TObj.pool = sceneObjPool;
        return(TObj);
    }
Exemplo n.º 12
0
    public static void collideSceneObjProcess()
    {
        SCENE_OBJ A = collideInfo.vertex.belongToObj;  //vertex
        SCENE_OBJ B = collideInfo.surface.belongToObj; //surface

        //Debug.Log ( "collide occur!!(" + A.transform.name + "," + B.transform.name + ")" + collideInfo.minCollideTime );
        newContactA.reset();
        newContactB.reset();
        newContactA.other = B;
        newContactB.other = A;
        newContactA.self  = A;
        newContactB.self  = B;
        //newContactA.coupleContactInfo = newContactB;
        //newContactB.coupleContactInfo = newContactA;
        newContactA.blockDirect = collideInfo.surface.normal.direct;
        newContactB.blockDirect = -newContactA.blockDirect;


        //record surface
        newContactA.otherSurface = newContactB.otherSurface = collideInfo.surface;
        //if surface contact surface record surface
        bool isSurfaceContact = false;

        for (int i = 0; i < collideInfo.vertex.normals.Count; i++)
        {
            NORMAL normal = collideInfo.vertex.normals[i];
            if (normal.direct == -collideInfo.surface.normal.direct)
            {
                newContactA.selfSurface = newContactB.selfSurface = normal.surface;
                isSurfaceContact        = true;
                break;
            }
        }
        //otherwise record vertex
        if (!isSurfaceContact)
        {
            newContactA.selfVertex = newContactB.selfVertex = collideInfo.vertex;
        }

        A.collideAction(newContactA);
        B.collideAction(newContactB);

        A.informBelongToObj(newContactA);
        B.informBelongToObj(newContactB);
    }
Exemplo n.º 13
0
 public VERTEX(SCENE_OBJ belongto = null)
 {
     belongToObj = belongto;
 }