示例#1
0
        /*
         * Private.
         */

        private GameObject CreateAgentsRoot()
        {
            var root = new GameObject("Agents");

            root.transform.SetParent(ContextView.As <Transform>());
            return(root);
        }
示例#2
0
    /// <summary>
    /// 向服务器发送请求
    /// </summary>
    /// <param name="url">URL.</param>
    public void Request(string url)
    {
        this.URL = url;
        MonoBehaviour root = ContextView.GetComponent <GameRoot>();

        root.StartCoroutine(GetMsg());
    }
示例#3
0
        /// Recurses through Transform.parent to find the GameObject to which ContextView is attached
        /// Has a loop limit of 100 levels.
        /// By default, raises an Exception if no Context is found.
        virtual protected void bubbleToContext(MonoBehaviour view, bool toAdd, bool finalTry)
        {
            const int LOOP_MAX    = 100;
            int       loopLimiter = 0;
            Transform trans       = view.gameObject.transform;

            while (trans.parent != null && loopLimiter < LOOP_MAX)
            {
                loopLimiter++;
                trans = trans.parent;
                if (trans.gameObject.GetComponent <ContextView>() != null)
                {
                    ContextView contextView = trans.gameObject.GetComponent <ContextView>() as ContextView;
                    AddViewToContext(view, toAdd, contextView);
                }
            }
            if (requiresContext && finalTry)
            {
                //last ditch. If there's a Context anywhere, we'll use it!
                if (Context.firstContext != null)
                {
                    Context.firstContext.AddView(view);
                    registeredWithContext = true;
                    return;
                }


                string msg = (loopLimiter == LOOP_MAX) ?
                             msg             = "A view couldn't find a context. Loop limit reached." :
                                         msg = "A view was added with no context. Views must be added into the hierarchy of their ContextView lest all hell break loose.";
                msg += "\nView: " + view.ToString();
                throw new MediationException(msg,
                                             MediationExceptionType.NO_CONTEXT);
            }
        }
示例#4
0
        private void bubbleToContext(MonoBehaviour view,
                                     BubbleType type,
                                     bool finalTry)
        {
            if (!_hasContextView)
            {
                _contextView = FindTheNearestContextView(view, out _hasContextView);
            }

            if (_hasContextView && _contextView.context != null)
            {
                var context = _contextView.context;

                switch (type)
                {
                case BubbleType.Add:
                    context.AddView(view);
                    registeredWithContext = true;
                    return;

                case BubbleType.Remove:
                    context.RemoveView(view);
                    return;

                case BubbleType.Enable:
                    context.EnableView(view);
                    return;

                case BubbleType.Disable:
                    context.DisableView(view);
                    return;

                default:
                    throw new ArgumentOutOfRangeException(type.ToString());
                }
            }

            if (finalTry && type == BubbleType.Add)
            {
                //last ditch. If there's a Context anywhere, we'll use it!
                if (Context.firstContext != null)
                {
                    Context.firstContext.AddView(view);
                    registeredWithContext = true;
                    return;
                }

                var msg =
                    "A view couldn't find a context. Loop limit reached. or " +
                    "A view was added with no context. Views must be added into the hierarchy of their ContextView lest all hell break loose.";
                msg += "\nView: " + view;
                throw new MediationException(
                          msg,
                          MediationExceptionType.NO_CONTEXT);
            }
        }
 /// <summary>
 ///     Fires after all injections satisifed.
 ///     Override and place your Actor/Director relationship initialization code here
 /// </summary>
 public virtual void OnRegister(IActor actor)
 {
     ///Beware, never try here to access other Director via Actor.GetDirectorComponent<T>() method, we're not sur
     /// other GameObject actor component have been awake (and bind to a Director) or not
     ///Example :  myItemDirector = Actor.GetDirectorComponent<IItemDirector>();
     Actor = actor;
     if (ContextView.hasAlreadyStart())
     {
         Start();
     }
 }
        protected void Start()
        {
            ContextView contextView = GetComponentInParent <ContextView>();
            IContext    context     = contextView?.context ?? Context.firstContext;

            if (context != null && context is CrossContext)
            {
                (contextView.context as CrossContext).injectionBinder.Bind <EventSource>().ToValue(this).ToSingleton().CrossContext();
            }

            CheckForEM();
        }
示例#7
0
        public ContextViewModel()
        {
            Title     = "Контекст";
            Name      = "ContextViewModel";
            ContentId = Guid.Parse("2d5213da-fdd3-43b9-9483-f3b699659c7a");
            CanClose  = true;
            IsClosed  = false;

            ContextView contextView = new ContextView();

            contextView.DataContext = this;
            UserInterface           = contextView;
        }
示例#8
0
 public void PostConstruct()
 {
     if (ContextView.hasAlreadyStart())
     {
         WarmUp();
         Start();
     }
     else
     {
         WarmupSignal.AddOnce(WarmUp);
         StartSignal.AddOnce(Start);
     }
 }
示例#9
0
        /// Recurses through Transform.parent to find the GameObject to which ContextView is attached
        /// Has a loop limit of 100 levels.
        /// By default, raises an Exception if no Context is found.
        virtual protected void bubbleToContext(MonoBehaviour view, bool toAdd, bool finalTry)
        {
            const int LOOP_MAX    = 100;
            int       loopLimiter = 0;
            Transform trans       = view.gameObject.transform;

            while (trans.parent != null && loopLimiter < LOOP_MAX)
            {
                loopLimiter++;
                trans = trans.parent;
                if (trans.gameObject.GetComponent <ContextView>() != null)
                {
                    ContextView contextView = trans.gameObject.GetComponent <ContextView>() as ContextView;
                    if (contextView.context != null)
                    {
                        IContext context = contextView.context;
                        if (toAdd)
                        {
                            context.AddView(view);
                            registeredWithContext = true;
                            return;
                        }
                        else
                        {
                            context.RemoveView(view);
                            return;
                        }
                    }
                }
            }
            if (requiresContext && finalTry)
            {
                //last ditch. If there's a Context anywhere, we'll use it!
                if (Context.firstContext != null)
                {
                    Context.firstContext.AddView(view);
                    registeredWithContext = true;
                    return;
                }
            }
            if (requiresContext && !finalTry && !toAdd)
            {
                //last ditch. If there's a Context anywhere, we'll use it!
                if (Context.firstContext != null)
                {
                    Context.firstContext.RemoveView(view);
                    return;
                }
            }
        }
        public IView Run()
        {
            var ctx        = AssemblyModel.GetContext(Context);
            var namespaces = AssemblyModel.ListNamespaces(Context);

            var view = new ContextView
            {
                Context    = ctx,
                Assemblies = ctx.Assemblies.Values.ToList(),
                Namespaces = namespaces
            };

            return(view);
        }
 public virtual void PostConstruct()
 {
     if (ContextView.hasAlreadyStart())
     {
         WarmUp();
         //Dans cette situation on n'execute le StartUp que sur la fin sur le onRegister pour permettre aux implementations
         // de StartUp de faire reference à l'acteur du directeur.
     }
     else
     {
         WarmupSignal.AddOnce(WarmUp);
         StartSignal.AddOnce(Start);
     }
 }
示例#12
0
 public override void OnObjectChanged()
 {
     foreach (var instance in m_instances)
     {
         Destroy(instance.gameObject);
     }
     m_instances.Clear();
     foreach (var @object in Object)
     {
         ContextView view = m_prefabs.FirstOrDefault(contextView => contextView.AcceptObject(@object));
         m_instances.Add(Instantiate(view, m_parent, false));
         m_instances.Last().SetObject(@object);
     }
 }
示例#13
0
 protected void AddViewToContext(MonoBehaviour view, bool toAdd, ContextView contextView)
 {
     if (contextView.context != null)
     {
         IContext context = contextView.context;
         if (toAdd)
         {
             context.AddView(view);
             registeredWithContext = true;
             return;
         }
         else
         {
             context.RemoveView(view);
             return;
         }
     }
 }
示例#14
0
        protected void Awake()
        {
            ContextView contextView = GetComponentInParent <ContextView>();
            IContext    context     = contextView?.context ?? Context.firstContext;

            if (context != null && context is CrossContext)
            {
                injectionBinder = (contextView.context as CrossContext).injectionBinder;
                injectionBinder.Bind <EntityManager>().ToValue(this).ToSingleton().CrossContext();
            }

            ES = GetComponent <EventSource>() ?? FindObjectOfType <EventSource>();
            if (ES == null)
            {
                throw new Exception("Unable to find active EventSource in scene");
            }

            Reset();

            Filters = new List <Action <IModifier, Action <IModifier> > >();
        }
示例#15
0
        /// Recurses through Transform.parent to find the GameObject to which ContextView is attached
        /// Has a loop limit of 100 levels.
        /// By default, raises an Exception if no Context is found.
        virtual protected void bubbleToContext(MonoBehaviour view, bool toAdd, bool finalTry)
        {
            const int LOOP_MAX    = 100;
            int       loopLimiter = 0;
            Transform trans       = view.gameObject.transform;

            while (trans.parent != null && loopLimiter < LOOP_MAX)
            {
                loopLimiter++;
                trans = trans.parent;
                if (trans.gameObject.GetComponent <ContextView>() != null)
                {
                    ContextView contextView = trans.gameObject.GetComponent <ContextView>() as ContextView;
                    if (contextView.context != null)
                    {
                        IContext context = contextView.context;
                        if (toAdd)
                        {
                            context.AddView(view);
                            registeredWithContext = true;
                            return;
                        }
                        else
                        {
                            context.RemoveView(view);
                            return;
                        }
                    }
                }
            }
            if (requiresContext && finalTry)
            {
                string msg = (loopLimiter == LOOP_MAX) ?
                             "A view couldn't find a context. Loop limit reached." :
                             "A view was added with no context. Views must be added into the hierarchy of their ContextView lest all hell break loose.";
                msg += "\nView: " + view;

                Debug.LogWarning(msg);
            }
        }
示例#16
0
        public void CanFilterBlockNodeByShaderStage()
        {
            GraphData graph = new GraphData();

            graph.AddContexts();

            var node = new BlockNode();

            node.Init(s_DescriptorA);

            var contextView = new ContextView("Test", graph.vertexContext, null);
            var methodInfo  = typeof(StackNode).GetMethod("AcceptsElement", BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(GraphElement), typeof(int).MakeByRefType(), typeof(int) }, null);

            Assert.IsNotNull(methodInfo);

            var acceptsElement = (bool)methodInfo.Invoke(contextView, new object[] { new MaterialNodeView()
                                                                                     {
                                                                                         userData = node
                                                                                     }, 0, 0 });

            Assert.IsFalse(acceptsElement);
        }
示例#17
0
        private async void ContextView_Clicked(Controls.MenuItem menu, ContextView sender)
        {
            var           id       = (long)sender.Identifier;
            VideoCategory category = UserData.VideoCategoryViews.Find(x => x.EntityId == id);

            switch (menu.Identifier)
            {
            case "Remove":
                var value = await Application.Current.MainPage.DisplayAlert("DeleteOperation".GetString(), "PlayListDelete".GetString(), "Yes".GetString(), "No".GetString());

                if (value)
                {
                    category.State = State.Removed;
                    await UserData.SaveCategory(category);
                }
                break;

            case "Edit":
                await UserData.CreateEditPlayList(category);

                break;
            }
        }
 public RestContext(ContextView contextView) : base(contextView)
 {
 }
示例#19
0
 public DeviceAuthenticationContext(ContextView contextView) : base(contextView)
 {
 }
 public PersistContext(ContextView contextView) : base(contextView)
 {
 }
 public SignalContext(ContextView contextView) : base(contextView)
 {
 }
示例#22
0
 public void PostConstruct()
 {
     Runner = ContextView.AddComponent <RoutineRunnerBehaviour> ();
 }
示例#23
0
 public MyContext(ContextView view) : base(view)
 {
 }
示例#24
0
 public ContextFactory(ContextView contextView, EntityNamespace entityNamespace)
 {
     this.contextView = contextView;
     this.nameSpace   = entityNamespace;
 }
示例#25
0
        /// Recurses through Transform.parent to find the GameObject to which ContextView is attached
        /// Has a loop limit of 100 levels.
        /// By default, raises an Exception if no Context is found.
        virtual protected void bubbleToContext(MonoBehaviour view, BubbleType type, bool finalTry)
        {
            const int LOOP_MAX    = 100;
            int       loopLimiter = 0;
            Transform trans       = view.gameObject.transform;

            while (trans.parent != null && loopLimiter < LOOP_MAX)
            {
                loopLimiter++;
                trans = trans.parent;
                if (trans.gameObject.GetComponent <ContextView>() != null)
                {
                    ContextView contextView = trans.gameObject.GetComponent <ContextView>() as ContextView;
                    if (contextView.context != null)
                    {
                        IContext context = contextView.context;
                        bool     success = true;

                        switch (type)
                        {
                        case BubbleType.Add:
                            context.AddView(view);
                            registeredWithContext = true;
                            break;

                        case BubbleType.Remove:
                            context.RemoveView(view);
                            break;

                        case BubbleType.Enable:
                            context.EnableView(view);
                            break;

                        case BubbleType.Disable:
                            context.DisableView(view);
                            break;

                        default:
                            success = false;
                            break;
                        }

                        if (success)
                        {
                            return;
                        }
                    }
                }
            }
            if (requiresContext && finalTry && type == BubbleType.Add)
            {
                //last ditch. If there's a Context anywhere, we'll use it!
                if (Context.firstContext != null)
                {
                    Context.firstContext.AddView(view);
                    registeredWithContext = true;
                    return;
                }

                string msg = (loopLimiter == LOOP_MAX) ?
                             msg             = "A view couldn't find a context. Loop limit reached." :
                                         msg = "A view was added with no context. Views must be added into the hierarchy of their ContextView lest all hell break loose.";
                msg += "\nView: " + view.ToString();
                throw new MediationException(msg,
                                             MediationExceptionType.NO_CONTEXT);
            }
        }
 public LogContext(ContextView contextView) : base(contextView)
 {
 }
示例#27
0
 public GameContext(ContextView contextView) : base(contextView)
 {
 }
示例#28
0
 public static Coroutine StartCoroutine(IEnumerator routine)
 {
     return(ContextView.StartCoroutine(routine));
 }
 public EchoContext(ContextView contextView) : base(contextView)
 {
 }