Esempio n. 1
0
    bool MakeBelt()
    {
        if (slot1 == null || slot2 == null)
        {
            return(false);
        }

        if (currentBelt)
        {
            Destroy(currentBelt);
        }
        var belt = Instantiate(buildObject, Vector3.zero, Quaternion.identity).GetComponent <ConveyorBeltSegment>();

        belt.ResetPath(slot1, slot2);

        slot1.belt = belt;
        slot2.belt = belt;

        mPoleMaker.currentPole = null;

        slot1 = null;
        slot2 = null;

        return(true);
    }
Esempio n. 2
0
    public override void CustomReset()
    {
        slot1 = null;
        slot2 = null;

        if (currentBelt)
        {
            Destroy(currentBelt);
        }

        mPoleMaker.CustomReset();
    }
Esempio n. 3
0
    void MakeTempBelt(ConveyorInputSlot start, ConveyorOutputSlot end)
    {
        if (currentBelt)
        {
            Destroy(currentBelt);
        }

        currentBelt = Instantiate(buildObject, Vector3.zero, Quaternion.identity);
        var b = currentBelt.GetComponent <ConveyorBeltSegment>();

        b.ResetPath(start, end);
    }
Esempio n. 4
0
    public override bool ParseInput(ref Ray mouseRay)
    {
        RaycastHit hit;

        if (mPoleMaker.currentPole)
        {
            var belt = currentBelt.GetComponent <ConveyorBeltSegment>();

            if (slot1)
            {
                slot1.belt = belt;
                mPoleMaker.currentPole.GetComponentInChildren <ConveyorOutputSlot>().belt = belt;
            }
            else if (slot2)
            {
                slot2.belt = belt;
                mPoleMaker.currentPole.GetComponentInChildren <ConveyorInputSlot>().belt = belt;
            }
            slot1 = null;
            slot2 = null;
            mPoleMaker.currentPole = null;
            if (currentBelt)
            {
                currentBelt = null;
            }

            return(true);
        }

        if (Physics.Raycast(mouseRay, out hit, playerRange, InputMask))
        {
            slot1 = hit.collider.GetComponent <ConveyorInputSlot>();
            if (slot1.belt)
            {
                slot1 = null;
            }
            return(MakeBelt());
        }
        else if (Physics.Raycast(mouseRay, out hit, playerRange, OutputMask))
        {
            slot2 = hit.collider.GetComponent <ConveyorOutputSlot>();
            if (slot2.belt)
            {
                slot2 = null;
            }
            return(MakeBelt());
        }

        return(false);
    }
Esempio n. 5
0
    public void ResetPath(ConveyorInputSlot start, ConveyorOutputSlot end)
    {
        startPos = start;
        endPos   = end;
        path     = new Path(endPos.transform, startPos.transform);
        MakeMesh();
        myPoints = path.CalculateEvenlySpaceOrientedPoints(PointDistance);

        MyResources.Clear();
        for (int i = 0; i < myPoints.Length - 1; ++i)
        {
            MyResources.Add(new ResourceData());
            MyResources[i].point = myPoints[i];
        }
        MyResources.RemoveAt(0);
        //MyResources.RemoveAt(0);
    }