Ejemplo n.º 1
0
 public Main()
 {
     Instance = this;
     AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
     Updateables.Add(CoopClient.Instance);
     Updateables.Add(GameLoopRunner.Instance);
 }
Ejemplo n.º 2
0
    private void OnTargetSelect(EventInfo pInfo)
    {
        CameraTargetSelectEventInfo info = pInfo as CameraTargetSelectEventInfo;

        if (info != null)
        {
            //If the next and previous points are identical, keep the next but set the previous to the camera's current postion
            //Useful on start since the camera has not yet focused a roomset before
            info.FocalA.position = info.FocalA.position == info.FocalB.position  ? cam.transform.position : info.FocalA.position;
            Vector3[] list = new Vector3[] { info.FocalA.position, info.FocalB.position, info.FocalB.position };

            for (int i = 0; i < targetList.Length; i++)
            {
                float zoom = i < targetList.Length - 1 ? Settings.VAL_CAMERA_ZOOM_DISTANCE : 0.0f;
                Debug.Log("Setting zoom for pos " + i + " to: " + zoom);
                SetTargetList(i, list[i], zoom);
            }

            handler += MoveToTarget;
        }
        else
        {
            //Notifies the user that this event is not being acted upon correctly since the EventInfo cannot be cast and lists the current method and class for easy back-searching
            Debug.Log(
                System.String.Format(EventSystem.STR_INCORRECT_EVENT_TYPE_CAST, System.Reflection.MethodBase.GetCurrentMethod().Name, GetType().FullName));
        }
    }
Ejemplo n.º 3
0
        private void Update(int bufferIndex, TimeSpan elapsed)
        {
            //resourceUpdateHandle.WaitOne();

            Updateables.ApplyChanges();
            Parallel.ForEach(Updateables, updateable => updateable.Update(bufferIndex, elapsed));
        }
Ejemplo n.º 4
0
 private void BeginPlot(object sender, EventArgs e)
 {
     progressOutput.color = swatch[1];
     progressOutput.text  = "Running...";
     EventQueue.QueueEvent(EventQueue.EventType.Plot_Start, this, new EventArgs());
     UpdateablesHandler += SpinLoadingIcon;
 }
Ejemplo n.º 5
0
 private void MoveToTarget()
 {
     cam.transform.position = Vector3.MoveTowards(cam.transform.position, targetList[currentTargetIndex], Settings.VAL_CAMERA_MOVEMENT_SPEED);
     if (cam.transform.position == targetList[currentTargetIndex])
     {
         if (currentTargetIndex < targetList.Length - 1)
         {
             Debug.Log("reached target " + currentTargetIndex + " and incremnting to " + (currentTargetIndex + 1));
             currentTargetIndex++;
         }
         else
         {
             currentTargetIndex = 0;
             handler           -= MoveToTarget;
         }
     }
 }
Ejemplo n.º 6
0
 public void Add <T>(T component) where T : Component
 {
     Remove <T>();
     component.GameObject = this;
     component.Transform  = Transform;
     Components.Add(typeof(T), component);
     if (component is IUpdateable)
     {
         Updateables.Add(component as IUpdateable);
     }
     if (component is IRenderable)
     {
         Renderables.Add(component as IRenderable);
     }
     if (component is IDrawable)
     {
         Drawables.Add(component as IDrawable);
     }
 }
Ejemplo n.º 7
0
 public void Remove <T>() where T : Component
 {
     if (Components.ContainsKey(typeof(T)))
     {
         Component component = Components[typeof(T)];
         Components.Remove(typeof(T));
         if (component is IUpdateable)
         {
             Updateables.Remove(component as IUpdateable);
         }
         if (component is IRenderable)
         {
             Renderables.Remove(component as IRenderable);
         }
         if (component is IDrawable)
         {
             Drawables.Remove(component as IDrawable);
         }
     }
 }
Ejemplo n.º 8
0
        public T Add <T>() where T : Component, new()
        {
            Remove <T>();
            T component = new T();

            component.GameObject = this;
            Components.Add(typeof(T), component);
            if (component is IUpdateable)
            {
                Updateables.Add(component as IUpdateable);
            }
            if (component is IRenderable)
            {
                Renderables.Add(component as IRenderable);
            }
            if (component is IDrawable)
            {
                Drawables.Add(component as IDrawable);
            }
            return(component);
        }
Ejemplo n.º 9
0
    private void EndPlot(object sender, EventArgs e)
    {
        progressOutput.color = swatch[2];
        progressOutput.text  = "Completed.";
        UpdateablesHandler  -= SpinLoadingIcon;

        //Formats text for second or millisecond display
        const int MILLISECONDS      = 1000;
        float     timeDisplay       = TimeLogger.Elapsed;
        string    timeDisplayFormat = "ms";

        if (timeDisplay > MILLISECONDS)
        {
            timeDisplay      /= MILLISECONDS;
            timeDisplay       = Decimal.RoundToFactorOf(timeDisplay, 2.0f);
            timeDisplayFormat = "s";
        }
        string formattedDisplay = timeDisplay.ToString().Replace(',', '.') + timeDisplayFormat;
        string timeText         = TimeLogger.Elapsed < 15 ? "in < one frame." : "in " + formattedDisplay;

        timeOutput.text = timeText;
    }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds a given component to the system. If the component is a renderable it adds it to the scenes
 /// renderables, which in turn are picked up by the renderer, to render during draw calls.
 /// </summary>
 /// <param name="component">The component to add to the systems.</param>
 public void AddComponentToSystems(IComponent component)
 {
     // Could be an IRenderable
     if (component is IRenderable renderable)
     {
         if (Renderables == null)
         {
             Renderables = new List <IRenderable>();
         }
         Renderables.Add(renderable);
     }
     // Could also be an IUpdateable TOO!
     // Some components can implement both IRenderable and IUpdateable so check for both.
     // TODO Optimize? If we only add components at the start of the scene it probably doesn't matter.
     // Updateables probably wants to become some kind of type map though.
     if (component is IUpdateable updateable)
     {
         if (Updateables == null)
         {
             Updateables = new List <IUpdateable>();
         }
         Updateables.Add(updateable);
     }
 }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     registerAllListeners();
     cam      = Camera.main;
     handler += NullUpdate;
 }