Esempio n. 1
0
    private void GetChildren(GameObject parent)
    {
        if (LaunchedState.KillWhile)
        {
            return;
        }
        index++;

        bool isLoop       = false;
        bool Ifstate      = false;
        bool NotWithLogic = true;

        try
        {
            string parentName = LaunchedState.GetName(parent);
            if (parentName.Equals("stop"))
            {
                //  Debug.Log("StopAllCoroutines");
                LaunchedState.x = 0;
                LaunchedState.y = 0;
                LaunchedState.z = 0;
                return;
            }
            if (parentName.Equals("rotate"))
            {
                LaunchedState.Rotate(parent);
                return;
            }
            if (parentName.Equals("shoot"))
            {
                LaunchedState.Shot();
                return;
            }
            if (parentName.Equals("wait"))
            {
                LaunchedState.Wait(parent);
                //   Debug.Log("Miega"+ LaunchedState.Waittime);
                Thread.Sleep(1000 * LaunchedState.Waittime);
                //   Debug.Log("atsibunda");
                return;
            }
            if (parentName.Equals("Set"))
            {
                //  Debug.Log("IS in set");
                IsInVariablesList = false;
                LaunchedState.newVariablesValuesNames = new VariablesValuesNames();
                LaunchedState.SetVar(parent);// Set(parent);
                if (IsInVariablesList)
                {
                    for (int i = 0; i < LaunchedState.Variables.Count; i++)
                    {
                        if (LaunchedState.Variables[i].Name.Equals(LaunchedState.newVariablesValuesNames.Name))
                        {
                            LaunchedState.Variables[i].Value = LaunchedState.newVariablesValuesNames.Value;
                            break;
                        }
                    }
                }
                else
                {
                    LaunchedState.Variables.Add(LaunchedState.newVariablesValuesNames);
                }
                IsInVariablesList = false;
                return;
            }
            if (parentName.Equals("move"))
            {
                //  Debug.Log("MoveDirection");
                LaunchedState.LockDebug(parent);
                //  Debug.Log("Lock");
                LaunchedState.MoveRobot = true;
                LaunchedState.Move(parent);
                //  Debug.Log("after move parent");
            }
            //  LaunchedState.LockDebug(parent);--------------------------------------------------------------------------------------------------------------------------------
            LaunchedState.SinkIsWhile(parent);
            if (LaunchedState.IsWhileTemp)
            {
                NotWithLogic = false;
                LaunchedState.IsWhileTemp = false;

                isLoop = true;
            }
            LaunchedState.SinkIsIf(parent);

            if (LaunchedState.IsIfTemp)//parent.GetComponent<CodePart>().IsIF)
            {
                NotWithLogic           = false;
                LaunchedState.IsIfTemp = false;
                Ifstate = LaunchedState.FormatLogic(parent);
            }


            if (Ifstate || NotWithLogic)
            {
                GameObject[] thredchildrens = LockAndGetData(parent);
                for (int i = 0; i < thredchildrens.Length; i++)
                {
                    GameObject children = thredchildrens[i];
                    GetChildren(children);
                }
            }


            if (isLoop)//gets logic continue or brake loop
            {
                //  Debug.Log("________________Logic data = " + LaunchedState.FormatLogic(parent));
                // Debug.Log("LaunchedState.KillWhile" + LaunchedState.KillWhile);
                while (!LaunchedState.KillWhile && LaunchedState.FormatLogic(parent))//parent.GetComponent<CodePart>().FormatLogic(parent))
                {
                    //   Debug.Log("LaunchedState.KillWhile" + LaunchedState.KillWhile);

                    GameObject[] thredchildrens = LockAndGetData(parent);
                    for (int i = 0; i < thredchildrens.Length; i++)
                    {
                        GameObject children = thredchildrens[i];
                        GetChildren(children);
                    }
                }
                //    LaunchedState.IsLoaunched = false;
                //  Debug.Log("!!!!!!!!!!!!!!!!!!!!!!Steitas: " + LaunchedState.IsLoaunched);
                //       LaunchedState.IsLoaunched = false;
                isLoop = false;
            }
        }
        catch
        {
            GameObject[] thredchildrens = LockAndGetData(parent);

            for (int i = 0; i < thredchildrens.Length; i++)
            {
                GetChildren(thredchildrens[i]);
            }
        }
        index--;
    }
Esempio n. 2
0
        private void InitMachine()
        {
            Log.Info("InitMachine");
            //  if (saveLoadWinPos == null)
            //     saveLoadWinPos = new SaveLoadWinPos();


            // Create the states

            initial  = new InitialState("Init", _machine);
            settings = new SettingState("Settings", _machine);
            sequence = new SequenceState("Sequence", _machine);
            launch   = new LaunchState("Launch", _machine);
            launched = new LaunchedState("Launched", _machine);
            finish   = new KFSMState("Finish");

            // Add events to the states

            var go2Finish = new KFSMEvent("Finish")
            {
                GoToStateOnEvent = finish,
                updateMode       = KFSMUpdateMode.MANUAL_TRIGGER
            };

            var go2Settings = new KFSMEvent("Settings")
            {
                GoToStateOnEvent = settings, updateMode = KFSMUpdateMode.MANUAL_TRIGGER
            };

            initial.AddEvent(go2Settings);

            var go2Init = new KFSMEvent("Init")
            {
                GoToStateOnEvent = initial, updateMode = KFSMUpdateMode.MANUAL_TRIGGER
            };

            settings.AddEvent(go2Init);
            sequence.AddEvent(go2Init);
            finish.AddEvent(go2Init);

            var go2Sequence = new KFSMEvent("Sequence")
            {
                GoToStateOnEvent = sequence, updateMode = KFSMUpdateMode.MANUAL_TRIGGER
            };

            initial.AddEvent(go2Sequence);

            var go2Launch = new KFSMEvent("Launch")
            {
                GoToStateOnEvent = launch, updateMode = KFSMUpdateMode.MANUAL_TRIGGER
            };

            initial.AddEvent(go2Launch);
            launch.AddEvent(go2Init);
            launch.AddEvent(go2Finish);

            var go2Launched = new KFSMEvent("Launched")
            {
                GoToStateOnEvent = launched, updateMode = KFSMUpdateMode.MANUAL_TRIGGER
            };

            launch.AddEvent(go2Launched);

            initial.AddEvent(go2Finish);
            launched.AddEvent(go2Finish);

            // Add states to the state  machine

            _machine.AddState(initial);
            _machine.AddState(settings);
            _machine.AddState(sequence);
            _machine.AddState(launch);
            _machine.AddState(finish);
        }