Ejemplo n.º 1
0
        public static VO_Page CreatePage(Enums.EventType CurrentEvent, int PageNumber, Guid objectId)
        {
            VO_Page NewPage = new VO_Page(new Guid());

            NewPage.PageNumber    = PageNumber;
            NewPage.PageEventType = CurrentEvent;

            VO_Script Script = null;

            switch (CurrentEvent)
            {
            case Enums.EventType.Animation:
                Script = ObjectsFactory.CreateScript(Enums.ScriptType.AnimationEvents);
                NewPage.AnimationFrequency = GlobalConstants.ANIMATION_NORMAL_FREQUENCY;
                break;

            case Enums.EventType.Character:
                Script = ObjectsFactory.CreateScript(Enums.ScriptType.CharacterEvents);
                VO_Character character = GameCore.Instance.GetCharacterById(objectId);
                NewPage.CharacterAnimationFrequency = GlobalConstants.ANIMATION_NORMAL_FREQUENCY;
                NewPage.CharacterDirection          = Enums.Movement.Down;
                NewPage.CharacterSpeed        = GlobalConstants.CHARACTERS_NORMAL_SPEED;
                NewPage.CharacterStandingType = character.StandingAnim;
                NewPage.CharacterWalkingType  = character.WalkingAnim;
                NewPage.CharacterTalkingType  = character.TalkingAnim;
                break;

            case Enums.EventType.Event:
                Script = ObjectsFactory.CreateScript(Enums.ScriptType.Events);
                break;
            }

            NewPage.Script = Script;
            return(NewPage);
        }
Ejemplo n.º 2
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     Script            = scriptManager1.Script;
     this.scriptManager1.DisableDrawManager();
     this.Close();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Insère un event
        /// </summary>
        /// <returns></returns>
        public static VO_Event CreateEvent(Enums.EventType currentEvent, Guid objectId)
        {
            VO_Event newItem = new VO_Event();

            newItem.PageList = new List <VO_Page>();
            VO_Page FirstPage = CreatePage(currentEvent, 0, objectId);

            FirstPage.PageEventType = currentEvent;
            FirstPage.PageNumber    = newItem.PageList.Count + 1;

            VO_Script Script = null;

            switch (currentEvent)
            {
            case Enums.EventType.Animation:
                Script = ObjectsFactory.CreateScript(Enums.ScriptType.AnimationEvents);
                break;

            case Enums.EventType.Character:
                Script = ObjectsFactory.CreateScript(Enums.ScriptType.CharacterEvents);
                break;

            case Enums.EventType.Event:
                Script = ObjectsFactory.CreateScript(Enums.ScriptType.Events);
                break;
            }


            FirstPage.Script = Script;

            newItem.PageList.Add(FirstPage);
            return(newItem);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Détruit un interactionScript
        /// </summary>
        /// <param name="id"></param>
        public void RemoveInteractionScriptById(Guid id)
        {
            VO_Script script = Game.InteractionScripts.Find(p => p.Id == id);

            if (script != null)
            {
                Game.InteractionScripts.Remove(script);
            }
        }
        /// <summary>
        /// Chargement des items
        /// </summary>
        /// <param name="item1"></param>
        /// <param name="item2"></param>
        private void LoadItem(Guid item1, Guid item2)
        {
            Cursor.Current = Cursors.WaitCursor;

            //Code de chargement
            if (item1 != new Guid())
            {
                CurrentItem1 = GameCore.Instance.GetItemById(item1);
            }
            if (item2 != new Guid())
            {
                CurrentItem2 = GameCore.Instance.GetItemById(item2);
            }

            if (CurrentItem1.Id != new Guid() && CurrentItem2.Id != new Guid() && CurrentItem1.Id != CurrentItem2.Id)
            {
                //Afficher les groupes
                grpCommands.Visible = true;

                //Récupération des données du script ou création si nécessaire.
                VO_Script          script          = null;
                VO_ItemInteraction itemInteraction = CurrentItem1.ItemInteraction.Find(p => p.AssociatedItem == CurrentItem2.Id);
                if (itemInteraction == null)
                {
                    script = ObjectsFactory.CreateScript(true, Enums.ScriptType.ItemEvents);
                    VO_ItemInteraction itemInteraction1 = new VO_ItemInteraction();
                    itemInteraction1.AssociatedItem = CurrentItem2.Id;
                    itemInteraction1.Script         = script.Id;
                    CurrentItem1.ItemInteraction.Add(itemInteraction1);
                    VO_ItemInteraction itemInteraction2 = new VO_ItemInteraction();
                    itemInteraction2.AssociatedItem = CurrentItem1.Id;
                    itemInteraction2.Script         = script.Id;
                    CurrentItem2.ItemInteraction.Add(itemInteraction2);
                }
                else
                {
                    script = GameCore.Instance.GetInteractionScriptsById(itemInteraction.Script);

                    if (script == null)
                    {
                        script = ObjectsFactory.CreateScript(true, Enums.ScriptType.ItemEvents);
                        itemInteraction.Script = script.Id;
                        VO_ItemInteraction itemInteraction2 = CurrentItem2.ItemInteraction.Find(p => p.AssociatedItem == CurrentItem1.Id);
                        itemInteraction2.Script = script.Id;
                    }
                }
                //Chargement du script
                _LoadedScript = script;
                ScriptManager.LoadScript(script);
            }
            else
            {
                grpCommands.Visible = false;
            }

            Cursor.Current = DefaultCursor;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Test et gère les scripts
        /// </summary>
        /// <param name="stageObject"></param>
        /// <param name="IsProcess"></param>
        /// <returns></returns>
        public bool TestScript(VO_StageObject stageObject, Enums.TriggerEventConditionType type)
        {
            VO_Event eventSpot = stageObject.Event;
            VO_Page  _page     = null;

            //Activer l'event
            foreach (VO_Page page in eventSpot.PageList)
            {
                if (page.TriggerCondition == type && IsActivePage(page) && IsExecutablePage(page))
                {
                    _page = page;
                    break;
                }
            }

            //Bad Interactions
            if (type == Enums.TriggerEventConditionType.ClickEvent)
            {
                if (_page == null && eventSpot != null && stageObject.ClassId != Guid.Empty)
                {
                    VO_Dialog dialog = FindBadInteraction(eventSpot, stageObject.ClassId);
                    if (dialog != null)
                    {
                        VO_Script dynamicScript = new VO_Script(Guid.NewGuid());
                        dynamicScript.Lines = new List <VO_Line>();
                        VO_Script_Message scriptMessage = new VO_Script_Message();
                        scriptMessage.Id     = Guid.NewGuid();
                        scriptMessage.Dialog = dialog;
                        dynamicScript.Lines.Add(scriptMessage);
                        LaunchScript(stageObject, dynamicScript, type);
                        return(true);
                    }
                }
            }

            if (_page == null)
            {
                return(false);
            }

            #region Execute le script
            LaunchScript(stageObject, _page.Script, type);
            return(true);

            #endregion
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Insère un script
        /// </summary>
        /// <returns></returns>
        public static VO_Script CreateScript(bool interactionScript, Enums.ScriptType type)
        {
            //Création de l'objet
            VO_Script newScript = new VO_Script(Guid.NewGuid())
            {
                Lines = new List <VO_Line>()
            };

            //Insertion de l'objet
            if (interactionScript)
            {
                GameCore.Instance.Game.InteractionScripts.Add(newScript);
            }

            newScript.Lines      = new List <VO_Line>();
            newScript.ScriptType = type;
            return(newScript);
        }
Ejemplo n.º 8
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            VO_Script script = value as VO_Script;

            if (svc != null && script != null)
            {
                using (ScriptManagerContainer form = new ScriptManagerContainer())
                {
                    form.LoadScript(script);
                    if (svc.ShowDialog(form) == DialogResult.OK)
                    {
                        script = form.Script; // update object
                    }
                }
            }
            return(value); // can also replace the wrapper object here
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Lance un script
        /// </summary>
        /// <param name="hotSpot"></param>
        /// <param name="script"></param>
        private void LaunchScript(VO_StageObject hotSpot, VO_Script script, Enums.TriggerEventConditionType type)
        {
            if (type == Enums.TriggerEventConditionType.ClickEvent && hotSpot.PlayerMustMove)
            {
                VO_RunningScript newScript = new VO_RunningScript();
                newScript.Id         = Guid.NewGuid();
                newScript.Lines      = new List <VO_Line>();
                newScript.ScriptType = Enums.ScriptType.Dynamic;
                VO_Script_MovePlayer moveScript = new VO_Script_MovePlayer();
                moveScript.Id     = Guid.NewGuid();
                moveScript.Coords = hotSpot.PlayerPositionPoint;
                newScript.Lines.Add(moveScript);
                VO_Script_ChangePlayerDirection playerDirection = new VO_Script_ChangePlayerDirection();
                playerDirection.Id        = Guid.NewGuid();
                playerDirection.Direction = hotSpot.PlayerMoveEndDirection;
                newScript.Lines.Add(playerDirection);
                VO_Script_CallScript callScript = new VO_Script_CallScript();
                callScript.Id     = Guid.NewGuid();
                callScript.Script = script;
                newScript.Lines.Add(callScript);
                ScriptManager.AddParallelScript(newScript);
            }
            else
            {
                VO_RunningScript runningScript = new VO_RunningScript();
                runningScript.Id    = script.Id;
                runningScript.Lines = script.Lines;
                switch (type)
                {
                case Enums.TriggerEventConditionType.Automatic:
                case Enums.TriggerEventConditionType.ClickEvent:
                case Enums.TriggerEventConditionType.ContactEvent:
                    if (ScriptManager.CurrentScript == null)
                    {
                        ScriptManager.CurrentScript = runningScript;
                    }
                    break;

                case Enums.TriggerEventConditionType.ParallelProcess:
                    ScriptManager.AddParallelScript(runningScript);
                    break;
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Charger un script
 /// </summary>
 /// <param name="script">Objet script</param>
 public void LoadScript(VO_Script script)
 {
     if (script != null)
     {
         Script = script;
         Manager.SuspendLayout();
         Manager.Nodes.Clear();
         foreach (IScriptable line in Script.Lines)
         {
             line.Valid = line.IsScriptValid();
             List <TreeNode> nodes = line.RenderInScriptManager(string.Empty);
             foreach (TreeNode node in nodes)
             {
                 Manager.Nodes.Add(node);
             }
         }
         Manager.Nodes.Add(string.Empty, "...");
         Manager.ExpandAll();
         Manager.ResumeLayout();
     }
 }
Ejemplo n.º 11
0
        public static bool EventScriptIntegrity(VO_Script CurrentScript)
        {
            if (CurrentScript == null || CurrentScript.Lines.Count <= 0)
            {
                return(true);
            }

            bool IsValid = true;

            foreach (IScriptable CurrentLine in CurrentScript.Lines)
            {
                if (EventScriptIntegritySublinesCheck(CurrentLine as VO_Line) == false)
                {
                    IsValid = false;
                }
                CurrentLine.Valid = CurrentLine.IsScriptValid();
                if (CurrentLine.Valid == false)
                {
                    IsValid = false;
                }
            }

            return(IsValid);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Charge le projet
 /// </summary>
 /// <param name="script"></param>
 public void LoadScript(VO_Script script)
 {
     scriptManager1.LoadScript(script);
 }
Ejemplo n.º 13
0
        public void MousePress(MouseState e)
        {
            if (e.LeftButton == ButtonState.Pressed)
            {
                #region Quitter l'inventaire
                //Click en dehors de l'inventaire
                if (!_Service.MouseIsInGrid(new Point(e.X, e.Y), new Point(_MenuData.InventoryCoords.X, _MenuData.InventoryCoords.Y), _MenuData.GridWidth, _MenuData.GridHeight, _MenuData.ItemWidth, _MenuData.ItemHeight))
                {
                    Opened = false;
                    return;
                }

                //Click sur le bouton de l'inventaire
                if (GetInventoryButtonEvent(new Point(e.X, e.Y)))
                {
                    SwitchInventory();
                }
                #endregion

                VO_InventoryItem item = GetInventoryItemEvent(new Point(e.X, e.Y));
                if (ActionManager.ItemAsAction && item != null)
                {
                    VO_InventoryItem item2 = _Service.GetItemFromGrid(ActionManager.CurrentLinkedItem.Id, _MenuData.GridWidth, _MenuData.GridHeight);
                    if (item.ItemId != Guid.Empty && item2.ItemId != Guid.Empty && item2.ItemId != item.ItemId)
                    {
                        //Interaction d'objets
                        VO_Item            itemObj         = GameCore.Instance.GetItemById(item.ItemId);
                        VO_ItemInteraction itemInteraction = itemObj.ItemInteraction.Find(p => p.AssociatedItem == item2.ItemId);
                        if (itemInteraction != null)
                        {
                            VO_Script        scriptObj = GameCore.Instance.GetInteractionScriptsById(itemInteraction.Script);
                            VO_RunningScript script    = new VO_RunningScript();
                            script.Id    = scriptObj.Id;
                            script.Lines = scriptObj.Lines;

                            ScriptManager.CurrentScript = script;
                        }
                    }
                    else
                    {
                        _Service.SwitchItemPlaces(item, item2);
                        _ItemDragDrop = null;
                        ActionManager.UnloadItem();
                    }
                }
                else if (item != null && item.ItemId != Guid.Empty)
                {
                    if (ActionManager.CurrentActionIsGo())
                    {
                        _ItemDragDrop = item;
                        ActionManager.SetCurrentItem(item.ItemId);
                    }
                    else
                    {
                        //Script sur action
                        VO_Item itemObj = GameCore.Instance.GetItemById(item.ItemId);
                        VO_ActionOnItemScript actionScript = itemObj.Scripts.Find(p => p.Id == ActionManager.CurrentAction.Id);
                        if (actionScript != null)
                        {
                            VO_RunningScript script = new VO_RunningScript();
                            script.Id    = actionScript.Script.Id;
                            script.Lines = actionScript.Script.Lines;
                            ScriptManager.CurrentScript = script;
                        }
                    }
                }
            }
            else if (e.RightButton == ButtonState.Pressed)
            {
                PlayableCharactersManager.CurrentPlayerCharacter.ChangeNextAction();
            }
        }
Ejemplo n.º 14
0
        public static bool CheckCurrentProjectIntegrity()
        {
            #region Check Event Stage Integrity

            ProjectValid = true;
            ErrorList    = new List <string>();

            #region Verification des nécessités de démarrage
            VO_Project           project   = GameCore.Instance.Game.Project;
            VO_PlayableCharacter character = GameCore.Instance.GetPlayableCharacterById(project.StartingCharacter);
            if (character == null)
            {
                ProjectValid = false;
                string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STARTING_CHARACTER_NEEDED);
                ErrorList.Add(FormatedResult);
            }
            else
            {
                VO_Stage stage = GameCore.Instance.GetStageById(character.CoordsCharacter.Map);
                if (stage == null)
                {
                    ProjectValid = false;
                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STARTING_STAGE_NEEDED);
                    ErrorList.Add(FormatedResult);
                }
            }
            if (string.IsNullOrEmpty(project.GuiResource))
            {
                ProjectValid = false;
                string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.GUI_SYSTEM_NEEDED);
                ErrorList.Add(FormatedResult);
            }
            #endregion

            #region Verification des GlobalEvents

            ErrorList.Add(Culture.Language.ProjectIntegrity.INTEGRITY_DATABASEZONE + "\r\n\r\n");

            foreach (VO_GlobalEvent CurrentEvent in GameCore.Instance.Game.GlobalEvents)
            {
                #region Verification des pages

                if (CurrentEvent.Script != null)
                {
                    if (EventScriptIntegrity(CurrentEvent.Script) == false)
                    {
                        ProjectValid = false;
                        string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_GLOBALEVENT, CurrentEvent.Title);
                        ErrorList.Add(FormatedResult);
                    }
                }

                #endregion
            }

            #endregion

            #region Verification de GameOver

            VO_Script GameOverScript = project.GameOver;
            if (EventScriptIntegrity(GameOverScript) == false)
            {
                ProjectValid = false;
                string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_GAMEOVER);
                ErrorList.Add(FormatedResult);
            }

            #endregion

            #region Verification des Items

            foreach (VO_Item CurrentItem in GameCore.Instance.Game.Items)
            {
                #region Verification des Action sur Item

                if (CurrentItem.Scripts != null)
                {
                    foreach (VO_ActionOnItemScript CurrentItemScript in CurrentItem.Scripts)
                    {
                        if (EventScriptIntegrity(CurrentItemScript.Script) == false)
                        {
                            VO_Action CurrentAction = GameCore.Instance.GetActionById(CurrentItemScript.Id);
                            ProjectValid = false;
                            string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_ITEM, CurrentItem.Title, CurrentAction.Title);
                            ErrorList.Add(FormatedResult);
                        }
                    }
                }

                #endregion
            }

            #endregion

            #region Verification des ItemsInteraction

            foreach (VO_Script CurrentItemInteraction in GameCore.Instance.Game.InteractionScripts)
            {
                #region Verification de l'ItemInteraction

                if (CurrentItemInteraction != null)
                {
                    if (EventScriptIntegrity(CurrentItemInteraction) == false)
                    {
                        ProjectValid = false;
                        int            FoundItem       = 0;
                        List <VO_Item> AssociatedItems = new List <VO_Item>();
                        foreach (VO_Item CurrentItem in GameCore.Instance.Game.Items)
                        {
                            if (CurrentItem.ItemInteraction.Find(p => p.Script == CurrentItemInteraction.Id) != null)
                            {
                                AssociatedItems.Add(CurrentItem);
                                if (FoundItem == 2)
                                {
                                    break;
                                }
                                else
                                {
                                    FoundItem = FoundItem + 1;
                                }
                            }
                        }
                        string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_ITEMINTERACTION, AssociatedItems[0].Title, AssociatedItems[1].Title);
                        ErrorList.Add(FormatedResult);
                    }
                }
                #endregion
            }

            #endregion

            #region Verification des Personnages de la Database

            List <VO_PlayableCharacter> PlayableCharacterList = GameCore.Instance.Game.PlayableCharacters;

            foreach (VO_PlayableCharacter CurrentPlayableCharacter in PlayableCharacterList)
            {
                if (ValidationTools.CheckMapExistence(CurrentPlayableCharacter.CoordsCharacter) == false)
                {
                    ProjectValid = false;
                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.CHECK_PLAYABLECHARACTER_MAP, CurrentPlayableCharacter.Title);
                    ErrorList.Add(FormatedResult);
                }
            }

            #endregion

            ErrorList.Add("\r\n\r\n" + Culture.Language.ProjectIntegrity.INTEGRITY_STAGE + "\r\n\r\n");

            List <VO_Base> StageList = GameCore.Instance.GetStages();
            foreach (VO_Stage CurrentStage in StageList)
            {
                #region Verification du Script de démarrage (Premiere fois)

                if (EventScriptIntegrity(CurrentStage.StartingFirstScript) == false)
                {
                    ProjectValid = false;
                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_START_FIRST, CurrentStage.Title);
                    ErrorList.Add(FormatedResult);
                }

                #endregion

                #region Verification du Script de démarrage

                if (EventScriptIntegrity(CurrentStage.StartingScript) == false)
                {
                    ProjectValid = false;
                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_START, CurrentStage.Title);
                    ErrorList.Add(FormatedResult);
                }

                #endregion

                #region Verification du Script de fin (Premiere fois)

                if (EventScriptIntegrity(CurrentStage.EndingFirstScript) == false)
                {
                    ProjectValid = false;
                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_END_FIRST, CurrentStage.Title);
                    ErrorList.Add(FormatedResult);
                }

                #endregion

                #region Verification du Script de fin

                if (EventScriptIntegrity(CurrentStage.EndingScript) == false)
                {
                    ProjectValid = false;
                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_END, CurrentStage.Title);
                    ErrorList.Add(FormatedResult);
                }

                #endregion

                #region Verification des Hotspot

                foreach (VO_StageHotSpot CurrentHotSpot in CurrentStage.ListHotSpots)
                {
                    #region Verification des pages

                    if (CurrentHotSpot.Event != null)
                    {
                        foreach (VO_Page CurrentPage in CurrentHotSpot.Event.PageList)
                        {
                            #region Verification du Script Courant

                            if (EventScriptIntegrity(CurrentPage.Script) == false)
                            {
                                ProjectValid = false;
                                string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_HOTSPOT, CurrentStage.Title, CurrentHotSpot.Title, CurrentPage.PageNumber + 1);
                                ErrorList.Add(FormatedResult);
                            }

                            #endregion
                        }
                    }

                    #endregion
                }

                #endregion

                #region Verification des Personnages

                foreach (VO_StageCharacter CurrentCharacter in CurrentStage.ListCharacters)
                {
                    #region Verification des pages

                    if (CurrentCharacter.Event != null)
                    {
                        foreach (VO_Page CurrentPage in CurrentCharacter.Event.PageList)
                        {
                            #region Verification du Script Courant

                            if (EventScriptIntegrity(CurrentPage.Script) == false)
                            {
                                ProjectValid = false;
                                string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_CHARACTER, CurrentStage.Title, CurrentCharacter.Title, CurrentPage.PageNumber + 1);
                                ErrorList.Add(FormatedResult);
                            }

                            #endregion
                        }
                    }

                    #endregion
                }

                #endregion

                #region Verification des Animation

                foreach (VO_Layer CurrentLayer in CurrentStage.ListLayers)
                {
                    #region Verification des pages

                    List <VO_StageAnimation> StageAnimationList = CurrentLayer.ListAnimations;

                    if (StageAnimationList != null)
                    {
                        foreach (VO_StageAnimation CurrentStageAnimation in StageAnimationList)
                        {
                            foreach (VO_Page CurrentPage in CurrentStageAnimation.Event.PageList)
                            {
                                #region Verification du Script Courant

                                if (EventScriptIntegrity(CurrentPage.Script) == false)
                                {
                                    ProjectValid = false;
                                    string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_ANIMATION, CurrentStage.Title, CurrentLayer.Title, CurrentStageAnimation.Title, CurrentPage.PageNumber);
                                    ErrorList.Add(FormatedResult);
                                }

                                #endregion
                            }
                        }
                    }

                    #endregion
                }

                #endregion
            }

            #endregion

            return(ProjectValid);
        }