Exemple #1
0
 public void EvaluateInput(InputButton button, InputEvent ievent)
 {
     if (!player)
     {
         if (!started)
         {
             StartReplay();
         }
         if (replayIndex >= 0)
         {
             if (replayIndex < inputs.Count)
             {
                 for (int i = replayIndex; i < inputs.Count; ++i)
                 {
                     InputSaver saver = inputs[replayIndex];
                     var        ts    = Time.time - replayStartTs;
                     if (ts >= saver.ts)
                     {
                         if (suicide)
                         {
                             Transform obj = instantiatedObject.transform.Find("Visual");
                             if (obj != null && rotateToZeroTimer < 0)
                             {
                                 FreezeObject(obj);
                             }
                         }
                         button = saver.ib;
                         ievent = saver.ie;
                         replayIndex++;
                         if (saver.hasTrans)
                         {
                             instantiatedObject.transform.position = Vector3.Lerp(instantiatedObject.transform.position, saver.pos, 0.1f);
                             instantiatedObject.transform.rotation = Quaternion.Lerp(instantiatedObject.transform.rotation, saver.rot, 0.1f);
                         }
                         SendMovementToController(button, ievent);
                     }
                     else
                     {
                         EvaluateAllInputs();
                         return;
                     }
                 }
             }
             else
             {
                 allFinished = true;
                 instantiatedObject.layer = LayerMask.NameToLayer("Corpses");
                 Transform obj = instantiatedObject.transform.Find("Visual");
                 if (obj != null && rotateToZeroTimer < 0)
                 {
                     FreezeObject(obj);
                 }
                 //ResetMovement();
                 return;
             }
         }
     }
     else
     {
         var ts = Time.time - originalStartTs;
         if (IsDead())
         {
             ResetMovement();
             return;
         }
         if (!suicide)
         {
             Debug.Log("adding more inputs: " + button.ToString() + ", event: " + ievent + ", ts: " + ts);
             Transform trans = instantiatedObject.transform;
             if (controller.ShouldSaveTransform())
             {
                 inputs.Add(new InputSaver(button, ievent, ts, trans.position, trans.rotation));
             }
             else
             {
                 inputs.Add(new InputSaver(button, ievent, ts));
             }
             SendMovementToController(button, ievent);
         }
     }
 }