private void Start()
 {
     if (isFirst)
     {
         pickUp        = GetComponent <TrainPickUpDrop>();
         trainMovement = GetComponent <TrainMovement>();
     }
 }
Exemplo n.º 2
0
    private void Start()
    {
        moving     = true;
        wagon      = GetComponent <Wagon>();
        pickupdrop = GetComponent <TrainPickUpDrop>();
        Boost      = GetComponent <Boost>();

        // Set up vertex neighbours
        for (int i = 0; i < VertexHolder.childCount; i++)
        {
            Vertex  vert      = VertexHolder.GetChild(i).GetComponent <Vertex>();
            Vector2 vertexPos = VertexHolder.GetChild(i).position;
            for (int j = 0; j < VertexHolder.childCount; j++)
            {
                if (i == j)
                {
                    continue;
                }

                Transform otherVecTR   = VertexHolder.GetChild(j);
                Vector2   otherVertPos = otherVecTR.position;
                if (vertexPos + Vector2.up == otherVertPos)
                {
                    vert.neighbours.Add(otherVecTR.GetComponent <Vertex>());
                    vert.dirToNeighbours.Add(Direction.UP);
                }
                else if (vertexPos + Vector2.down == otherVertPos)
                {
                    vert.neighbours.Add(otherVecTR.GetComponent <Vertex>());
                    vert.dirToNeighbours.Add(Direction.DOWN);
                }
                else if (vertexPos + Vector2.left == otherVertPos)
                {
                    vert.neighbours.Add(otherVecTR.GetComponent <Vertex>());
                    vert.dirToNeighbours.Add(Direction.LEFT);
                }
                else if (vertexPos + Vector2.right == otherVertPos)
                {
                    vert.neighbours.Add(otherVecTR.GetComponent <Vertex>());
                    vert.dirToNeighbours.Add(Direction.RIGHT);
                }
            }
        }
    }