Exemplo n.º 1
0
 //Set the next action for next frame
 public void setNextStep()
 {
     //Lessen the duration
     currentStep.duration -= 1;
     //Change steps if we're done with this one
     if (currentStep.duration <= 0)
     {
         //update data
         int newIndex = (currentStep.index + 1) % travelPath.Count;
         currentStep = new path_entry(travelPath [newIndex]);
     }
 }
Exemplo n.º 2
0
    private Rigidbody2D rb;                                     //my Rigidbody

    // Use this for initialization
    void Start()
    {
        rb        = GetComponent <Rigidbody2D> ();
        prevMoves = new List <move>();
        IList <path_entry> listOfMoves = new List <path_entry>();       //List of moves

        float[] durations = { 180, 90, 180, 90, 180, 90, 180, 90 };     //Frames
        float[] xMoves    = { 2f, 0f, 2f, 0f, -2f, 0f, -2f, 0f };
        float[] yMoves    = { 0f, 2f, 0f, -2f, 0f, 2f, 0f, -2f };

        for (int i = 0; i < numMoves; i++)
        {
            path_entry entry = new path_entry(durations [i], new Vector2(xMoves [i], yMoves [i]), i);
            listOfMoves.Add(entry);
        }

        myPath      = new path(listOfMoves);
        rb.velocity = myPath.getVelocity();
    }
Exemplo n.º 3
0
 //Constructor
 public path(IList <path_entry> tp)
 {
     travelPath  = tp;
     currentStep = new path_entry(travelPath[0]);
 }
Exemplo n.º 4
0
 public path_entry(path_entry p)
 {
     duration = p.duration;
     velocity = p.velocity;
     index    = p.index;
 }