public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ChainCreator myScript = (ChainCreator)target;

        if (GUILayout.Button("Refresh Chains"))
        {
            Clear();
            CreateNewChains();
        }
        if (GUILayout.Button("Create new Chain"))
        {
            Clear();
            var logMount = GameObject.Instantiate(BuilderProperties.LogMountPrefab);
            var mount    = GameObject.Instantiate(BuilderProperties.MountPrefab);

            var log = myScript.Log.GetComponent <VampLamp.Core.Obstacles.Log>();
            logMount.GetComponent <FixedJoint2D>().connectedBody = log.LogRigidBody;

            logMount.transform.SetParent(log.transform);
            mount.transform.SetParent(myScript.transform);

            logMount.transform.localPosition = Vector3.zero + Vector3.up * 0.1f;
            logMount.transform.localScale    = Vector3.one;
            logMount.name = "LogMount" + (myScript.ObstacleMounts.Count + 1).ToString();
            mount.name    = "Mount" + (myScript.WallMounts.Count + 1).ToString();

            myScript.WallMounts.Add(mount);
            myScript.ObstacleMounts.Add(logMount);

            CreateNewChains();
        }
    }
    private void Clear()
    {
        ChainCreator myScript = (ChainCreator)target;

        foreach (GameObject chain in myScript.Chains)
        {
            DestroyImmediate(chain);
        }
        myScript.Chains.Clear();

        List <GameObject> tmpList = new List <GameObject>();

        foreach (GameObject mount in myScript.WallMounts)
        {
            if (mount != null)
            {
                tmpList.Add(mount);
            }
        }
        myScript.WallMounts = tmpList;

        tmpList = new List <GameObject>();
        foreach (GameObject mount in myScript.ObstacleMounts)
        {
            if (mount != null)
            {
                tmpList.Add(mount);
            }
        }
        myScript.ObstacleMounts = tmpList;
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ChainCreator creator = (ChainCreator)target;

        if (GUILayout.Button("Create Chain"))
        {
            creator.CreateChain();
        }
    }
Beispiel #4
0
        public void updateConfig(Config config)
        {
            ChainCreator chainCreator = new ChainCreator();

            try
            {
                modelsState.config = chainCreator.updateConfig(modelsState, config);
                notifyObservers();
            }
            catch (Exception ex)
            {
                ExceptionHandler.Concrete.ExceptionHandler.getInstance().processing(ex);
            }
        }
    private void CreateNewChains()
    {
        ChainCreator myScript = (ChainCreator)target;

        for (int i = 0; i < myScript.WallMounts.Count; i++)
        {
            GameObject root = new GameObject();
            ObstacleBuilder.CreateLogChain(root, myScript.WallMounts[i], myScript.ObstacleMounts[i]);
            ObstacleBuilder.AttachChain(root.GetComponent <VampLamp.Core.Obstacles.Chain.Chain>(),
                                        myScript.WallMounts[i], myScript.ObstacleMounts[i]);
            root.name = "Chain" + i.ToString();
            root.transform.SetParent(myScript.transform);
            myScript.Chains.Add(root);
        }
    }
Beispiel #6
0
        void Initialize()
        {
            smStopwatch = new StateMachine <States, Transitions, Signals>();
            creator     = new ChainCreator <States, Transitions, Signals>(smStopwatch);

            creator
            .CreateState(States.Active)
            .OnStateEnter(SActive_OnStateEnter)
            .OnStateLeave(SActive_OnStateLeave)
            .CreateInnerState(States.Stopped, States.Active)
            .OnStateEnter(SStopped_OnStateEnter)
            .OnStateLeave(SStopped_OnStateLeave)
            .CreateInnerState(States.Running, States.Active)
            .OnStateEnter(SRunning_OnStateEnter)
            .OnStateLeave(SRunning_OnStateLeave)
            .CreateTransition(Transitions.ActiveLoop, States.Active, States.Active)
            .CreateTransition(Transitions.Stopped2Runnig, States.Stopped, States.Running)
            .CreateTransition(Transitions.Running2Stopped, States.Running, States.Stopped)
            .CreateSignal(Signals.Reset, Transitions.ActiveLoop, out sigReset)
            .CreateSignal(Signals.StartStop, Transitions.Stopped2Runnig, out sigStartStop)
            .ConnectSignal(Signals.StartStop, Transitions.Running2Stopped)
            .SetInitialState(States.Active)
            .SetInitialInnerState(States.Stopped, States.Active);
        }
 public ChainCreatorTest()
 {
     mockDictionaryService = new Mock <IDictionaryService>();
     chainCreator          = new ChainCreator(mockDictionaryService.Object);
 }
Beispiel #8
0
        static void Main(string[] args)
        {
            List <Player> players = new List <Player>();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = "Server=(localdb)\\mssqllocaldb;" +
                                        "Database=aspnet-NumberGuesserWeb;" +
                                        "Trusted_Connection=True;MultipleActiveResultSets=true";
                conn.Open();
                SqlCommand command = new SqlCommand("SELECT * FROM dbo.AspNetUsers", conn);
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        players.Add(new Player
                        {
                            Login    = (string)reader[1],
                            Score    = (int)reader[17],
                            Wins     = (int)reader[18],
                            Loses    = (int)reader[16],
                            Birthday = (DateTime)reader[19]
                        });
                    }
                }
                // use the connection here
            }
            foreach (var player in players)
            {
                Console.WriteLine(player);
            }
            Console.WriteLine("**************");

            var builder        = new FilteredPropertyBuilder(typeof(Player));
            var chainCreator   = new ChainCreator(builder);
            var filteredFields = new List <IFilteredProperty>();

            filteredFields.Add(builder.Build(nameof(Player.Login)));
            filteredFields.Add(builder.Build(nameof(Player.Score)));
            filteredFields.Add(builder.Build(nameof(Player.Wins)));
            filteredFields.Add(builder.Build(nameof(Player.Loses)));
            filteredFields.Add(builder.Build(nameof(Player.Birthday)));

            var dynamicFilter = new DynamicFilter <Player>();

            while (true)
            {
                var prediction = new Prediction();
                for (int i = 0; i < filteredFields.Count; i++)
                {
                    Console.WriteLine($"{i}) {filteredFields[i].FieldName}");
                }
                Console.Write("Choose field (index) or -1 to end: ");
                var indexOfField = ReadObj <int>();
                if (indexOfField == -1)
                {
                    break;
                }
                var filteredField = filteredFields[indexOfField];
                var complex       = filteredField as IComplexFilteredProperty;
                if (complex != null)
                {
                    var properties = complex.GetProperties();
                    for (var i = 0; i < properties.Count; i++)
                    {
                        Console.WriteLine($"{i}) {properties[i].Name}");
                    }
                    Console.Write("Choose property (index): or -1 to continue ");
                    var index = ReadObj <int>();
                    if (index != -1)
                    {
                        chainCreator.CreateChain(prediction, filteredField, properties[index]);
                    }
                }

                prediction.PropertyName = filteredField.FieldName;

                for (int i = 0; i < filteredField.AvailableActions.Count; i++)
                {
                    Console.WriteLine($"{i}) {filteredField.AvailableActions[i]}");
                }
                Console.Write("Choose action (index): ");
                var indexOfAction = ReadObj <int>();
                prediction.CompareAction = filteredField.AvailableActions[indexOfAction];

                if (prediction.NeedRight())
                {
                    Console.Write("Set right part: ");
                    var rightPart = ReadObj(filteredField.FieldType);
                    prediction.RightValue = rightPart;
                }

                dynamicFilter.AddPredict(prediction);
            }

            Console.WriteLine($"lambda: {dynamicFilter.GetLambda()}");

            var filtered = dynamicFilter.Filter(players);

            foreach (var round in filtered)
            {
                Console.WriteLine(round);
            }

            Console.Read();
        }