Beispiel #1
0
        public Pair execute(State state)
        {
            //Debug.Log("RIGHT");


            //ja sabemos q podemos fazer
            int key = LearningCharacter.toKeyState(
                state.getHp() - 1,
                state.getEnergy() - 1,
                state.getCharacterPosition().z_index,
                state.getCharacterPosition().x_index + 1);

            if (!LearningCharacter.all_states.ContainsKey(key))
            {
                Debug.Log("error key not found: hp: " + (state.getHp() - 1) + "\n" +
                          "mp: " + (state.getEnergy() - 1) + "\n" +
                          "z: " + (state.getCharacterPosition().z_index) + "\n" +
                          "x: " + (state.getCharacterPosition().x_index + 1));
            }

            //new state
            State new_state = LearningCharacter.all_states[key];

            Pair pair = new Pair();

            pair.setNewState(new_state);
            pair.setReward(calculateReward(state));

            return(pair);
        }
        public Pair execute(State state)
        {
            //Debug.Log("REST");


            //MUDAR HP, ENERGY
            //ja sabemos q podemos fazer
            int key = LearningCharacter.toKeyState(
                Math.Max(state.getHp() - 1, 0),
                Math.Min(LearningCharacter.max_energy, state.getEnergy() + 2),
                state.getCharacterPosition().z_index,
                state.getCharacterPosition().x_index);

            if (!LearningCharacter.all_states.ContainsKey(key))
            {
                Debug.Log("error key not found: hp: " + Math.Max(state.getHp() - 1, 0) + "\n" +
                          "mp: " + (Math.Min(LearningCharacter.max_energy, state.getEnergy() + 2)) + "\n" +
                          "z: " + (state.getCharacterPosition().z_index) + "\n" +
                          "x: " + state.getCharacterPosition().x_index);
            }

            //new state
            State new_state = LearningCharacter.all_states[key];

            Pair pair = new Pair();

            pair.setNewState(new_state);
            pair.setReward(calculateReward(state));

            return(pair);
        }
Beispiel #3
0
        public void DisplayLearningDialog(Java.Lang.String chinese, Java.Lang.String pinyin, Java.Lang.String english)
        {
            LearningCharacter character = new LearningCharacter()
            {
                Chinese = (string)chinese,
                Pinyin  = (string)pinyin,
                English = (string)english
            };

            App.FUNCTIONS.ShowCharacterLearningDialog(context, character, webview);
        }
        public bool canExecute(State state)
        {
            Point new_point = new Point()
            {
                x_coord = this._characterPosition.x_position,
                z_coord = this._characterPosition.z_position
            };

            if (LearningCharacter.getObstacleType(new_point) == 3 && state.getEnergy() > 0)
            {
                return(true);
            }

            return(false);
        }
        public bool canExecute(State state)
        {
            if (this._characterPosition.z_index != 9 && state.getEnergy() > 0 && state.getHp() > 0)
            {
                Point new_point = new Point()
                {
                    x_coord = this._characterPosition.x_position,
                    z_coord = this._characterPosition.z_position - 10
                };

                if (LearningCharacter.getObstacleType(new_point) != 1)
                {
                    return(true);
                }
            }

            return(false);;
        }
Beispiel #6
0
        public void ShowCharacterLearningDialog(Context context, LearningCharacter character, WebView webview)
        {
            SQLiteConnection database = new SQLiteConnection(App.LearningCharactersPath);

            database.CreateTable <LearningCharacter>();

            var  table  = database.Table <LearningCharacter>();
            bool exists = table.Any(x => x.Chinese.Equals(character.Chinese) && x.Pinyin.Equals(character.Pinyin));

            string buttonTitle = (exists) ? "REMOVE" : "ADD";

            MaterialDialog.Builder popup = new MaterialDialog.Builder(context);
            popup.SetTitle(character.Chinese + " " + character.Pinyin);
            popup.SetContent(character.English);
            popup.SetPositiveText(buttonTitle, (o, e) =>
            {
                if (!exists)
                {
                    database.Insert(character);
                }
                if (exists)
                {
                    var query = (from c in table
                                 where (c.Chinese.ToLower().Equals(character.Chinese.ToLower()) && c.Pinyin.ToLower().Equals(character.Pinyin.ToLower()))
                                 select c).ToList().FirstOrDefault();

                    database.Delete(query);
                }
                string js = "javascript:ToggleEnglish();";
                webview.LoadUrl(js);
            });

            App.STATE.Activity.RunOnUiThread(() =>
            {
                popup.Show();
            });
        }
Beispiel #7
0
        public void Alert(Java.Lang.String text, Java.Lang.String annotation)
        {
            //ContextThemeWrapper wrapper = new ContextThemeWrapper(context, App.FUNCTIONS.GetDialogTheme());
            //StorehouseSuperDialog alert = new StorehouseSuperDialog(wrapper);

            //alert.SetTitleTextColor(Android.Graphics.Color.White);
            //alert.SetTitleBackgroundColor(Android.Resource.Color.Transparent);
            //alert.SetTitle((string)text);
            //alert.SetMessage((string)annotation);
            //alert.Show();

            string english = (string)annotation;
            string chinese = ((string)text).Split(' ')[0];
            string pinyin  = (string)text.Replace(chinese + " ", "");

            LearningCharacter character = new LearningCharacter()
            {
                Chinese = chinese,
                Pinyin  = pinyin,
                English = english
            };

            App.FUNCTIONS.ShowCharacterLearningDialog(context, character, webview);
        }