Esempio n. 1
0
        private void OnGUI()
        {
            if (FieldController == null)
            {
                return;
            }

            GUILayout.BeginArea(new Rect(0, 0, 150, 300));

            if (GUILayout.Button("Инициализировать"))
            {
                FieldController.Initialize();
            }

            if (GUILayout.Button("Fire"))
            {
                FieldController.FireEntities();
            }

            if (GUILayout.Button("Fall"))
            {
                FieldController.FallEntities();
            }

            if (GUILayout.Button("Spawn"))
            {
                FieldController.SpawnEntities();
            }

            if (GUILayout.Button("Dump"))
            {
                Debug.Log(FieldController.FieldModel.DumpMap());
            }

            if (GUILayout.Button("Trurn auto mode"))
            {
                autoMode = !autoMode;
                if (autoMode)
                {
                    StartCoroutine(UpdateCoroutine());
                    StartCoroutine(SpawnCoroutine());
                }
                else
                {
                    StopAllCoroutines();
                }
            }

            if (GUILayout.Button("<<<") || Input.GetKeyUp(KeyCode.LeftArrow))
            {
                FieldController.MoveEntity(false);
            }

            if (GUILayout.Button(">>>") || Input.GetKeyUp(KeyCode.RightArrow))
            {
                FieldController.MoveEntity(true);
            }

            GUILayout.EndArea();
        }
Esempio n. 2
0
 private IEnumerator UpdateCoroutine()
 {
     while (autoMode)
     {
         FieldController.FireEntities();
         FieldController.FallEntities();
         yield return(new WaitForSeconds(updateInterval));
     }
 }