예제 #1
0
        public override bool MatchAction(Reflex reflex, out object param)
        {
            param = null;

            GUIButton button = GUIButtonManager.GetButton(color);

            bool clicked = (null != button) && button.Clicked;


            if (reflex.Sensor is MouseSensor)
            {
                clicked &= button.MouseControlled;

                MouseFilter mouseFilter = reflex.Data.GetFilterByType(typeof(MouseFilter)) as MouseFilter;
                if (null != mouseFilter)
                {
                    switch (mouseFilter.type)
                    {
                    case MouseFilterType.LeftButton:
                        clicked &= button.MouseLeftClick;
                        break;

                    case MouseFilterType.RightButton:
                        clicked &= !button.MouseLeftClick;
                        break;

                    case MouseFilterType.Hover:
                        clicked = button.MouseOver;
                        break;

                    default:
                        clicked = false;
                        break;
                    }
                }
            }
            else
            {
                clicked &= !button.MouseControlled;
            }

            return(clicked);
        }
예제 #2
0
        /// <summary>
        /// This function will Register any objects that should be registered when used by a reflex.
        ///
        /// This is used by things like the scores and GUI buttons which only appear onscreen
        /// when used in an actor's kode.
        /// </summary>
        internal void RegisterReflexSupportedObject()
        {
            for (int i = 0; i < tasks.Count; ++i)
            {
                Task task = tasks[i];

                for (int j = 0; j < task.reflexes.Count; ++j)
                {
                    Reflex reflex = task.reflexes[j] as Reflex;

                    //Register Score Bucket
                    if (reflex.Actuator != null && reflex.Actuator.Categories.Get((int)BrainCategories.DoSetScore))
                    {
                        ScoreBucket bucket = Modifier.ScoreBucketFromModifierSet(reflex.Modifiers);
                        if (bucket != ScoreBucket.NotApplicable)
                        {
                            Scoreboard.Activate(bucket);
                        }
                    }

                    //Register Color Touch Button
                    foreach (Filter filter in reflex.Filters)
                    {
                        if (filter is GUIButtonFilter)
                        {
                            Classification.Colors eColor = (filter as GUIButtonFilter).color;

                            if (eColor >= (Classification.Colors)Classification.ColorInfo.First &&
                                eColor <= (Classification.Colors)Classification.ColorInfo.Last)
                            {
                                Debug.Assert(null != GUIButtonManager.GetButton(eColor));
                                GUIButtonManager.GetButton(eColor).Active = true;
                            }
                        }
                    }
                }
            }
        }