static void RemoveTweak(SplineAnimator target)
    {
        var sequencers = Object.FindObjectsOfType(typeof(SplineCameraSequencer)) as SplineCameraSequencer[];

        if (sequencers.Length < 1)
        {
            return;
        }

        var seq = sequencers[0];

        if (!seq.activeTrigger)
        {
            return;
        }

        var trigger = seq.activeTrigger;

        var arr = (trigger.tweaks != null) ? new ArrayList(trigger.tweaks): new ArrayList();

        foreach (SplineCameraTrigger.SplineAnimatorTweak tweak in arr)
        {
            if (tweak != null && tweak.target == target)
            {
                arr.Remove(tweak);
                break;
            }
        }
        trigger.tweaks = arr.ToArray(typeof(SplineCameraTrigger.SplineAnimatorTweak)) as SplineCameraTrigger.SplineAnimatorTweak[];
    }
Beispiel #2
0
    static public SplineAnimator FindClosestSpline(Transform root)
    {
        var t = root;

        while (t)
        {
            var seq = t.gameObject.GetComponent <SplineCameraSequencer>();
            if (seq && seq.master)
            {
                return(seq.master);
            }
            t = t.parent;
        }
        SplineAnimator s = null;

        if (root.parent)
        {
            s = root.parent.GetComponentInChildren <SplineAnimator>() as SplineAnimator;
        }
        if (!s)
        {
            s = Object.FindObjectOfType(typeof(SplineAnimator)) as SplineAnimator;
        }
        return(s);
    }
    static SplineCameraTrigger.SplineAnimatorTweak AddTweak(SplineAnimator target,
                                                            out SplineCameraTrigger trigger)
    {
        trigger = null;

        var sequencers = Object.FindObjectsOfType(typeof(SplineCameraSequencer)) as SplineCameraSequencer[];

        if (sequencers.Length < 1)
        {
            return(null);
        }

        var seq = sequencers[0];
        var t   = FindTweak(seq, target, out trigger);

        if (t != null)
        {
            return(t);
        }

        if (!seq.activeTrigger)
        {
            return(null);
        }
        trigger = seq.activeTrigger;

        var arr = (trigger.tweaks != null) ? new ArrayList(trigger.tweaks): new ArrayList();

        t        = new SplineCameraTrigger.SplineAnimatorTweak();
        t.target = target;
        arr.Add(t);
        trigger.tweaks = arr.ToArray(typeof(SplineCameraTrigger.SplineAnimatorTweak)) as SplineCameraTrigger.SplineAnimatorTweak[];

        return(t);
    }
Beispiel #4
0
    public void UpdatePositionOnSpline()
    {
        if (!spline || !spline.spline)
        {
            return;
        }

        prevPosition         = transform.position;
        prevSpline           = spline;
        prevSplineTimeLength = spline.timeLength;

        //Debug.Log ("UpdatePositionOnSpline " + this);
        splineAnimatorFrame = GetClosestFrameOnSpline(spline, transform.position, ref splinePosition);
    }
Beispiel #5
0
        void Start()
        {
            cameraShake    = CameraShake.instance;
            uiManager      = UIManager.instance;
            audioManager   = AudioManager.instance;
            poolManager    = PoolManager.instance;
            blockCrane     = BlockCrane.instance;
            splineAnimator = SplineAnimator.instance;

            if (Environment == null)
            {
                Debug.LogWarning("Environment object required");
                return;
            }

            if (Background == null)
            {
                Debug.LogWarning("Background object required");
                return;
            }

            if (blockCrane.BlockList.Count == 0)
            {
                Debug.LogWarning("At least 1 block needed");
                return;
            }

            currentCash = PlayerPrefs.GetFloat("Cash", StartingCash);
            uiManager.SetCash(string.Format("{0:0}", currentCash));

            gameActive = true;

            float blockHeight = blockCrane.Initialize();

            splineAnimator.Initialize(blockHeight);
            audioManager.Initialize();

            if (RemoveHorizon > 0)
            {
                RemoveHorizon = -RemoveHorizon;
            }

            if (Skybox != null)
            {
                SetSkyboxIndex(0);      // Initialize Skybox
            }

            InitializeProps();
        }
    static SplineCameraTrigger.SplineAnimatorTweak FindTweak(SplineAnimator target, out SplineCameraTrigger trigger)
    {
        trigger = null;
        var sequencers = Object.FindObjectsOfType(typeof(SplineCameraSequencer)) as SplineCameraSequencer[];

        foreach (var s in sequencers)
        {
            var tweak = FindTweak(s, target, out trigger);
            if (tweak != null)
            {
                return(tweak);
            }
        }
        return(null);
    }
Beispiel #7
0
 public virtual void Start()
 {
     prevPosition = transform.position;
     if (!spline)
     {
         spline = FindClosestSpline(transform);
     }
     if (!localAudioListener && camera)
     {
         localAudioListener = FindAudioListener(camera.gameObject);
     }
     if (!cameraAnimation && camera)
     {
         cameraAnimation = camera.GetComponent <Animation>();
     }
 }
Beispiel #8
0
/*
 *      static public float GetClosestPositionOnSpline(SplineAnimator spline, Vector3 pos, float accuracy)
 *      {
 *              return GetClosestPositionOnSpline(spline, pos, accuracy, 256);
 *      }
 *
 *      static public float GetClosestPositionOnSpline(SplineAnimator spline, Vector3 pos, float accuracy, int maxStepCount)
 *      {
 *              float bestT = 0;
 *              var len = spline.timeLength;
 *              var step = Mathf.Max(accuracy, len / (float)maxStepCount);
 *              for (float t = 0; t < len; t += step)
 *                      if (Vector3.Distance(pos, spline.GetPositionOnSpline(t)) < Vector3.Distance(pos, spline.GetPositionOnSpline(bestT)))
 *                              bestT = t;
 *
 *              return bestT;
 *      }
 */
    static public int GetClosestFrameOnSpline(SplineAnimator spline, Vector3 pos, ref Vector3 splinePosition)
    {
        int   bestFrame    = 0;
        float bestDistance = Mathf.Infinity;
        var   len          = spline.frameCount;

        int cachedFrameNumber = 0; double cachedTime = 0;

        for (var q = 0; q < len; q++)
        {
            var posOnSpline = spline.GetPositionOnSpline(q, ref cachedFrameNumber, ref cachedTime);
            var distance    = Vector3.Distance(pos, posOnSpline);
            if (distance >= bestDistance)
            {
                continue;
            }
            bestFrame      = q;
            bestDistance   = distance;
            splinePosition = posOnSpline;
        }

        return(bestFrame);
    }
 //GameObject Stuff
 void Update()
 {
     if(gui == null)  {
         gui = GameObject.Find("GUI").GetComponent<MenuCamera>();
     }
     switch(currentState) {
         case (int)NetworkState.idle:
             if(menuGUI == null){
                 menuGUI = gui.AddMovie("MainMenu.swf");
             }
             break;
         case (int)NetworkState.matching:
             MatchMake();
             break;
         case (int)NetworkState.loading0:
             LoadNetworkObjects();
             break;
         case (int)NetworkState.loading1:
         case (int)NetworkState.loading2:
             if(!localLoaded) {
                 PairNetworkObjects();
             }
             break;
         case (int)NetworkState.loading3:
             //Delete Stuff From GameStart.
             GameObject.Destroy(GameObject.Find("MainCamera"));
             menuGUI.Destroy();
             currentState++;
             break;
         case (int)NetworkState.prepare0:
             if(Network.isServer) {
                 readyGUI = gui.AddMovie("InstructionsGameDesigner.swf");
                 hudGUI = gui.AddMovie("In_GameHUD.swf");
             } else {
                 readyGUI = gui.AddMovie("InstructionsRobot.swf");
             }
             currentState++;
             break;
         case (int)NetworkState.ready0:
             if(GameObject.Find(player.name+"(Clone)").GetComponent<MenuCamera>() != null) {
                 readyGUI.ReadyChecked();
             }
             currentState++;
             break;
         case (int)NetworkState.ready1:
             readyGUI.Destroy();
             currentState++;
             break;
         case (int)NetworkState.playing:
             if(playerSpline == null) {
                 playerSpline = GameObject.Find(player.name+"(Clone)").GetComponent<SplineAnimator>();
             }
             if(Network.isClient) {
                 playerSpline.paused = false;
             }
             if(playerSpline.passedTime>=1) {
                 hudGUI.Destroy();
                 gui.AddMovie("Robot_WinAndLooseScreens.swf");
             }
             break;
     }
 }
 static SplineCameraTrigger.SplineAnimatorTweak FindTweak(SplineCameraSequencer seq, SplineAnimator target,
                                                          out SplineCameraTrigger trigger)
 {
     trigger = seq.activeTrigger;
     if (!trigger)
     {
         return(null);
     }
     if (trigger.tweaks == null)
     {
         return(null);
     }
     foreach (var tweak in trigger.tweaks)
     {
         if (tweak != null && tweak.target == target)
         {
             return(tweak);
         }
     }
     trigger = null;
     return(null);
 }