示例#1
0
    public void CreateObject()
    {
        PuterPoint points   = newestInstance.GetComponent <PuterPoint>();
        float      distance = (points.StartPoint - transform.position).magnitude;

        while (distance < tooCloseCreateDistance)
        {
            GameObject prefab    = putPrefabs[(int)Random.Range(0, putPrefabs.Count)];
            GameObject newGround = Instantiate(prefab);
            if (sequenceSprites != null)
            {
                newGround.GetComponent <SequenceSpriteSetter>().SequenceSpritesWithIndex = sequenceSprites;
            }
            Vector3 position = points.EndPoint - newGround.transform.TransformVector(newGround.GetComponent <PuterPoint>().startPoint);
            newGround.transform.position = position;
            newGround.transform.SetParent(putTransformParent, true);
            nowInstances.Add(newGround);
            newestInstance = newGround;
            points         = newestInstance.GetComponent <PuterPoint>();
            distance       = (points.StartPoint - transform.position).magnitude;
            ParallaxMove parallax = newGround.GetComponent <ParallaxMove>();
            if (parallax != null)
            {
                parallax.movement        = parallaxMovement;
                parallax.sequenceSprites = sequenceSprites;
            }
            DisableMonoBehaviourByPlayerDie disableEvent = newGround.GetComponent <DisableMonoBehaviourByPlayerDie>();
            if (disableEvent != null)
            {
                disableEvent.movementFsm = parallaxMovement;
            }
        }
    }
示例#2
0
    public void OnSceneGUI()
    {
        PuterPoint script = (PuterPoint)target;

        Handles.color     = Color.yellow;
        script.StartPoint = Handles.PositionHandle(script.StartPoint, Quaternion.identity);
        Handles.ArrowHandleCap(0, script.StartPoint, Quaternion.identity, 1f, EventType.Repaint);
        Handles.color   = Color.red;
        script.EndPoint = Handles.PositionHandle(script.EndPoint, Quaternion.identity);
        Handles.ArrowHandleCap(1, script.EndPoint, Quaternion.identity, 1f, EventType.Repaint);
    }
示例#3
0
    public void DestroyTooFarObject()
    {
        List <GameObject> removeList = new List <GameObject>();

        foreach (var ground in nowInstances)
        {
            PuterPoint points   = ground.GetComponent <PuterPoint>();
            float      distance = (points.EndPoint - transform.position).magnitude;
            if (distance > tooFarDestroyDistance)
            {
                removeList.Add(ground);
                Destroy(ground);
            }
        }
        foreach (var ground in removeList)
        {
            nowInstances.Remove(ground);
        }
    }