Exemplo n.º 1
0
 private void CheckDriveUpdate <T>(Dictionary <T, Vector3> startPositions) where T : MonoBehaviour
 {
     for (int i = 0; i < groundObjects.Count; i++)
     {
         GameObject gameObject = groundObjects[i];
         if (gameObject == null)
         {
             continue;
         }
         T componentInParent = gameObject.GetComponentInParent <T>();
         if (!((Object)componentInParent != (Object)null) || !startPositions.ContainsKey(componentInParent))
         {
             continue;
         }
         float magnitude = (startPositions[componentInParent] - gameObject.transform.position).To2D().magnitude;
         if (magnitude > 5f)
         {
             if (typeof(T) == typeof(FloatingMesh))
             {
                 StatsAndAchievements.AddShip(magnitude);
             }
             else
             {
                 StatsAndAchievements.AddDrive(magnitude);
             }
             startPositions[componentInParent] = gameObject.transform.position;
         }
     }
 }
Exemplo n.º 2
0
    private static void CheckDriveEnd <T>(GameObject groundObject, Dictionary <T, Vector3> startPositions) where T : MonoBehaviour
    {
        T componentInParent = groundObject.GetComponentInParent <T>();

        if (!((Object)componentInParent != (Object)null) || !startPositions.ContainsKey(componentInParent))
        {
            return;
        }
        bool flag = true;

        for (int i = 0; i < all.Count; i++)
        {
            for (int j = 0; j < all[i].groundObjects.Count; j++)
            {
                GameObject gameObject = all[i].groundObjects[j];
                if (!(gameObject == null) && gameObject.transform.IsChildOf(componentInParent.transform))
                {
                    flag = false;
                    break;
                }
            }
        }
        if (!flag)
        {
            return;
        }
        float magnitude = (startPositions[componentInParent] - groundObject.transform.position).To2D().magnitude;

        if (magnitude > 0f)
        {
            if (typeof(T) == typeof(FloatingMesh))
            {
                StatsAndAchievements.AddShip(magnitude);
            }
            else
            {
                StatsAndAchievements.AddDrive(magnitude);
            }
        }
        startPositions.Remove(componentInParent);
    }