Inheritance: SRPGCKEditor
        public async Task CreationShouldReturnEntityInsertedWithId()
        {
            var idAssigned   = 1;
            var name         = "hahaha";
            var houseId      = "hehehe";
            var school       = "hihihi";
            var role         = "hohoho";
            var patronus     = "huhuhu";
            var characterDTO = new CharacterDTO
            {
                Name     = name,
                House    = houseId,
                School   = school,
                Role     = role,
                Patronus = patronus
            };
            var houseModel = new HouseModel
            {
                Id = houseId
            };
            var characterEntityMock = Mock.Of <Character>(c => c.Id == idAssigned && c.Name == name && c.House == houseId && c.School == school && c.Role == role && c.Patronus == patronus);

            var apiResult = Result <HouseModel> .Success(houseModel);

            var makeMagicApiClientMock = Mock.Of <MakeMagicApiClient>(mmac => mmac.GetHouse(houseId) == Task.FromResult(apiResult));
            var characterRepository    = Mock.Of <CharactersRepository>(cr =>
                                                                        cr.Insert(It.Is <Character>(c => c.Name == name && c.House == houseId && c.School == school && c.Role == role && c.Patronus == patronus)) == Task.FromResult(idAssigned) &&
                                                                        cr.Get(idAssigned) == Task.FromResult(characterEntityMock));

            var characterEditor = new CharacterEditor(makeMagicApiClientMock, characterRepository);
            var result          = await characterEditor.Create(characterDTO);

            Assert.False(result.Error);
            Assert.Equal(characterEntityMock, result.Value);
        }
        public async Task UpdateShouldAlterPropertiesOfEntity()
        {
            var name                = "hahaha";
            var houseId             = "hehehe";
            var school              = "hihihi";
            var role                = "hohoho";
            var patronus            = "huhuhu";
            var newCharacterInfoDTO = new CharacterDTO
            {
                Name     = name,
                House    = houseId,
                School   = school,
                Role     = role,
                Patronus = patronus
            };
            var houseModel = new HouseModel
            {
                Id = houseId
            };
            var characterEntityMock = new Mock <Character>();

            var apiResult = Result <HouseModel> .Success(houseModel);

            var makeMagicApiClientMock = Mock.Of <MakeMagicApiClient>(mmac => mmac.GetHouse(houseId) == Task.FromResult(apiResult));
            var characterRepository    = Mock.Of <CharactersRepository>(cr => cr.Update(characterEntityMock.Object) == Task.FromResult(true));

            var characterEditor = new CharacterEditor(makeMagicApiClientMock, characterRepository);
            var result          = await characterEditor.Update(characterEntityMock.Object, newCharacterInfoDTO);

            Assert.False(result.Error);
            Assert.Equal(characterEntityMock.Object, result.Value);
            characterEntityMock.Verify(c => c.Update(newCharacterInfoDTO.Name, newCharacterInfoDTO.Role, newCharacterInfoDTO.School, newCharacterInfoDTO.House, newCharacterInfoDTO.Patronus),
                                       Times.Once());
        }
 public UndoCharacterEditorExchangeColors(CharacterEditor Editor, ColorType Color1, ColorType Color2, List <int> AffectedChars)
 {
     this.Editor        = Editor;
     this.Color1        = Color1;
     this.Color2        = Color2;
     this.AffectedChars = AffectedChars;
 }
Esempio n. 4
0
 public UndoCharacterEditorSwapCategories(CharacterEditor Editor, CharsetProject Project, int CategoryIndex1, int CategoryIndex2)
 {
     this.Editor         = Editor;
     this.Project        = Project;
     this.CategoryIndex1 = CategoryIndex1;
     this.CategoryIndex2 = CategoryIndex2;
 }
Esempio n. 5
0
    public static void openWindow()
    {
        CharacterEditor window = (CharacterEditor)EditorWindow.GetWindow(typeof(CharacterEditor));

        window.titleContent = new GUIContent("Character");
        window.Show();
    }
        public UndoCharacterEditorValuesChange(CharacterEditor Editor, CharsetProject Project)
        {
            this.Editor  = Editor;
            this.Project = Project;
            Mode         = Project.Mode;

            Colors = new ColorSettings(Project.Colors);
        }
Esempio n. 7
0
        public UndoCharacterEditorPlaygroundCharChange(CharacterEditor Editor, CharsetProject Project, int X, int Y)
        {
            this.Editor  = Editor;
            this.Project = Project;
            this.X       = X;
            this.Y       = Y;

            Char = Project.PlaygroundChars[X + Y * Project.PlaygroundWidth];
        }
Esempio n. 8
0
        public UndoCharacterEditorValuesChange(CharacterEditor Editor, CharsetProject Project)
        {
            this.Editor  = Editor;
            this.Project = Project;

            BGColor     = Project.BackgroundColor;
            MultiColor1 = Project.MultiColor1;
            MultiColor2 = Project.MultiColor2;
            BGColor4    = Project.BGColor4;
        }
Esempio n. 9
0
 public static void Open(Color originalColor)
 {
     _originalColor   = Color = originalColor;
     _applyColor      = false;
     _characterEditor = _characterEditor ?? FindObjectOfType <CharacterEditor>();
     _window          = GetWindow(typeof(EditorGUIColorField), true, "Select color");
     _window.Show();
     _window.position = Rect.zero;
     _initialized     = false;
 }
        public async Task DeletionShouldPropagateOperationStatusFromDeletionInDB(bool successful)
        {
            var character = Mock.Of <Character>(c => c.Id == 1);

            var characterRepository = Mock.Of <CharactersRepository>(cr => cr.Delete(character) == Task.FromResult(successful));

            var characterEditor = new CharacterEditor(Mock.Of <MakeMagicApiClient>(), characterRepository);
            var result          = await characterEditor.Delete(character);

            Assert.NotEqual(successful, result.Error);
        }
        public UndoCharsetAddCategory(CharacterEditor Editor, CharsetProject Project, int CategoryIndex)
        {
            this.Editor        = Editor;
            this.Project       = Project;
            this.CategoryIndex = CategoryIndex;

            foreach (var charData in Project.Characters)
            {
                CharCategories.Add(charData.Category);
            }
        }
        public UndoCharacterEditorCharChange(CharacterEditor Editor, CharsetProject Project, int CharIndex)
        {
            this.Editor    = Editor;
            this.Project   = Project;
            this.CharIndex = CharIndex;

            Char          = new CharData();
            Char.Data     = new GR.Memory.ByteBuffer(Project.Characters[CharIndex].Data);
            Char.Color    = Project.Characters[CharIndex].Color;
            Char.Category = Project.Characters[CharIndex].Category;
            Char.Index    = CharIndex;
            Char.Mode     = Project.Characters[CharIndex].Mode;
        }
        public async Task CreationShouldPropagateApiCallErrorIfThereWasAny()
        {
            var houseId      = "hehehe";
            var characterDTO = Mock.Of <CharacterDTO>(c => c.House == houseId);

            var exceptedApiResult = Result <HouseModel> .Failed(ErrorLevel.UnrecoverableError, "Erro Api");

            var makeMagicApiClientMock = Mock.Of <MakeMagicApiClient>(mmac => mmac.GetHouse(houseId) == Task.FromResult(exceptedApiResult));

            var characterEditor = new CharacterEditor(makeMagicApiClientMock, Mock.Of <CharactersRepository>());
            var result          = await characterEditor.Create(characterDTO);

            Assert.True(result.Error);
            Assert.Equal(exceptedApiResult.ErrorLevel, result.ErrorLevel);
            Assert.Contains(exceptedApiResult.ErrorMessage, result.ErrorMessage);
        }
        public async Task CreationShouldFailWithRecoverableErrorIfHouseIsInvalid()
        {
            var houseId      = "hehehe";
            var characterDTO = Mock.Of <CharacterDTO>(c => c.House == houseId);

            var apiResult = Result <HouseModel> .Success(null);

            var makeMagicApiClientMock = Mock.Of <MakeMagicApiClient>(mmac => mmac.GetHouse(houseId) == Task.FromResult(apiResult));


            var characterEditor = new CharacterEditor(makeMagicApiClientMock, Mock.Of <CharactersRepository>());
            var result          = await characterEditor.Create(characterDTO);

            Assert.True(result.Error);
            Assert.Equal(ErrorLevel.RecoverableError, result.ErrorLevel);
            Assert.Contains("O id da casa da informado não corresponde a nenhuma casa conhecida.", result.ErrorMessage);
        }
        public UndoCharacterEditorCharChange(CharacterEditor Editor, CharsetProject Project, int CharIndex, int Count)
        {
            this.Editor    = Editor;
            this.Project   = Project;
            this.CharIndex = CharIndex;
            this.CharCount = Count;

            for (int i = 0; i < Count; ++i)
            {
                var charData = new CharData();
                charData.Tile.Data        = new GR.Memory.ByteBuffer(Project.Characters[CharIndex + i].Tile.Data);
                charData.Tile.CustomColor = Project.Characters[CharIndex + i].Tile.CustomColor;
                charData.Category         = Project.Characters[CharIndex + i].Category;
                charData.Index            = CharIndex + i;

                Chars.Add(charData);
            }
        }
Esempio n. 16
0
        private void RePopulateTreeView()
        {
            _guiController.ProjectTree.RemoveAllChildNodes(this, TOP_LEVEL_COMMAND_ID);
            _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID);
            foreach (Character item in _agsEditor.CurrentGame.Characters)
            {
                _guiController.ProjectTree.AddTreeLeaf(this, "Chr" + item.ID, item.ID.ToString() + ": " + item.ScriptName, "CharacterIcon");
            }

            if (_documents.ContainsValue(_guiController.ActivePane))
            {
                CharacterEditor editor = (CharacterEditor)_guiController.ActivePane.Control;
                _guiController.ProjectTree.SelectNode(this, "Chr" + editor.ItemToEdit.ID);
            }
            else if (_agsEditor.CurrentGame.Characters.Count > 0)
            {
                _guiController.ProjectTree.SelectNode(this, "Chr0");
            }
        }
Esempio n. 17
0
    /// <summary>
    /// Add listener to load config with index.
    /// </summary>
    public void SetSlotIndex(CharacterEditor editor, int index)
    {
        slotBtn.onClick.AddListener(() => editor.LoadConfig(index));

        slotText.text = (index + 1).ToString();
    }
Esempio n. 18
0
        /// <summary>
        /// The inspector graphic loop
        /// </summary>
        public override void OnInspectorGUI()
        {
            GUIHelper.Init();
            serializedObject.Update();
            GUILayout.BeginVertical(GUIHelper.windowStyle);

            if (characters.Count > 0)
            {
                if (TalkableId.stringValue != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Id: ");
                    EditorGUILayout.SelectableLabel(string.Format("{0}", TalkableId.stringValue));
                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Character: ");

                if (!Application.isPlaying)
                {
                    var selected = 0;

                    for (var i = 0; i < characters.Count; i++)
                    {
                        if (characters[i].Id == TalkableId.stringValue)
                        {
                            selected = i;
                            break;
                        }
                    }

                    var selectedBefore = selected;
                    selected = EditorGUILayout.Popup(selected, options.characterList);

                    for (var i = 0; i < characters.Count; i++)
                    {
                        if (selected == i)
                        {
                            TalkableId.stringValue             = characters[i].Id;
                            characters[selectedBefore].onScene = false;
                            if (GetTalkable() != null)
                            {
                                GetTalkable().onScene = true;
                            }
                            break;
                        }
                    }
                }

                else
                {
                    if (GetTalkable() != null)
                    {
                        GUILayout.Label(GetTalkable().name);
                    }
                }

                GUILayout.EndHorizontal();

                if (GUILayout.Button("Refresh", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_SMALL)))
                {
                    Refresh();
                }

                GUIHelper.Separator();

                var showInfluence = true;

                if (GetTalkable() != null)
                {
                    if (GetTalkable().name == options.playerCharacterName)
                    {
                        EditorGUILayout.HelpBox(
                            "\nThis character is the player, he doesn't influence himself, use his messages only in the case he speaks with himself.\n",
                            MessageType.Info);
                        showInfluence = false;
                    }
                }

                if (GUILayout.Button("Edit Character", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    CharacterEditor.Edit(Character.Find(Controller.Instance.Characters, TalkableId.stringValue));
                }

                if (GUILayout.Button("Edit Messages", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    TalkableMessagesEditor.OpenContextMenu(Character.Find(Controller.Instance.Characters,
                                                                          TalkableId.stringValue));
                }

                if (showInfluence)
                {
                    GUIHelper.labelStyle.alignment = TextAnchor.UpperCenter;
                    EditorGUILayout.Separator();

                    if (EditorGUIUtility.isProSkin)
                    {
                        GUIHelper.labelStyle.normal.textColor = GUIHelper.proTextColor;
                    }

                    else
                    {
                        GUIHelper.labelStyle.normal.textColor = GUIHelper.freeTextColor;
                    }

                    if (GetTalkable() != null)
                    {
                        if (GetTalkable().GetType() == typeof(Character))
                        {
                            GUILayout.Label("Influence: <b>" + GetTalkable().influence + "</b>", GUIHelper.labelStyle);
                        }
                    }
                }

                GUIHelper.Separator();
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Create Character", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_BIG)))
                {
                    CharacterEditor.OpenCreate();
                }

                EditorGUILayout.HelpBox("Create does not interfere in this character.", MessageType.Info);
                GUILayout.EndHorizontal();
            }

            else
            {
                if (GUILayout.Button("Create Character", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    CharacterEditor.OpenCreate();
                }
            }

            GUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 19
0
 void Start()
 {
     characterEditor = GameObject.Find("EditorManager").GetComponent <CharacterEditor>();
 }
 public UndoCharacterEditorExchangeMultiColors(CharacterEditor Editor, ExchangeMode Mode)
 {
     this.Editor = Editor;
     this.Mode   = Mode;
 }
Esempio n. 21
0
 public CharactersController(CharacterEditor characterEditor, CharactersRepository characterRepository)
 {
     _characterEditor     = characterEditor;
     _characterRepository = characterRepository;
 }
Esempio n. 22
0
        private void CharacterListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            CharacterEditor characterEditor = new CharacterEditor(DbModel.GetAccountByCharacterName(SelectedCharacter).Name, SelectedCharacter.Name);

            characterEditor.Show();
        }
Esempio n. 23
0
        private void CharacterManagerMenuItem_Click(object sender, RoutedEventArgs e)
        {
            CharacterEditor characterEditor = new CharacterEditor();

            characterEditor.Show();
        }
Esempio n. 24
0
 // Use this for initialization
 void Start()
 {
     Screen.lockCursor = false;
     this.ccontroller = this.GetComponent<CharacterController>();
     this.ceditor = this.GetComponent<CharacterEditor>();
     this.anim = this.GetComponent<Animator>();
     this.SkillPanelManager = GameObject.Find("BasicSkillPanel").GetComponent<BasicSkillPanelManager>();
     this.SwitchBomb(0);
     this.aimer = this.GetComponent<AimerControl>();
 }