Beispiel #1
0
        /// <summary>
        /// Prépare un perso à être dessiné.
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public VO_CharacterSprite DrawCharacter(VO_StageCharacter character)
        {
            int i = 0;

            foreach (VO_Page page in character.Event.PageList)
            {
                if (IsActivePage(page))
                {
                    VO_CharacterSprite characterSprite = GetCharacterSprite(character.Id);
                    if (characterSprite.CurrentExecutingPage != i)
                    {
                        characterSprite.Speed            = page.CharacterSpeed;
                        characterSprite.StandingAnim     = page.CharacterStandingType;
                        characterSprite.WalkingAnim      = page.CharacterWalkingType;
                        characterSprite.TalkingAnim      = page.CharacterTalkingType;
                        characterSprite.CurrentDirection = page.CharacterDirection;
                        characterSprite.SetCurrentAnimation(Enums.CharacterAnimationType.Standing, page.CharacterStandingType);
                        characterSprite.SetCurrentAnimationFrequency(page.CharacterAnimationFrequency);
                        characterSprite.CurrentExecutingPage = i;
                    }
                    return(characterSprite);
                }
                i++;
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Rafraichi les persos
        /// </summary>
        /// <param name="moveOrAnimation"></param>
        private void RefreshCharacters(int layerIndex, bool main, int playerIndex, bool moveOrAnimation)
        {
            bool playerDrawn = false;

            foreach (VO_StageCharacter item in _Stage.ListCharacters)
            {
                VO_CharacterSprite character = _Service.DrawCharacter(item);
                if (character != null)
                {
                    int characterIndex = _Service.GetLayerIndexFromCharacterLocation(character.Location);
                    if (characterIndex == 0 && main)
                    {
                        characterIndex = layerIndex;
                    }
                    if (playerIndex == 0 && main)
                    {
                        playerIndex = layerIndex;
                    }
                    if (layerIndex == characterIndex)
                    {
                        if (ScriptManager.IsPlayerVisible && !playerDrawn && PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite.Location.Y < character.Location.Y && playerIndex == layerIndex)
                        {
                            Draw(PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite, _Service.GetRatioFromMatrix(PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite.Location, _ProjectData.Resolution.MatrixPrecision), moveOrAnimation);
                            playerDrawn = true;
                        }
                    }
                    Draw(character, _Service.GetRatioFromMatrix(character.Location, _ProjectData.Resolution.MatrixPrecision), moveOrAnimation);
                }
            }
            if ((_Stage.ListCharacters.Count == 0 && (!playerDrawn && playerIndex == layerIndex && ScriptManager.IsPlayerVisible)) || (!playerDrawn && playerIndex == layerIndex && ScriptManager.IsPlayerVisible))
            {
                Draw(PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite, _Service.GetRatioFromMatrix(PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite.Location, _ProjectData.Resolution.MatrixPrecision), moveOrAnimation);
            }
        }
Beispiel #3
0
        // EVENT PREVU POUR CHARACTERS & EVENTS, les Anim ne sont pas supposées être cliquables
        public bool ExecuteClickedEvent(Point point, int matrixPrecision)
        {
            VO_StageObject hotSpot = null;

            #region Récupère le script
            //Gestion des characters
            foreach (VO_StageCharacter character in _CurrentStage.ListCharacters)
            {
                VO_CharacterSprite characterSprite = GetCharacterSprite(character.Id);
                if (characterSprite.PointIsInCharacter(point))
                {
                    //Activer l'event
                    foreach (VO_Page page in character.Event.PageList)
                    {
                        if (IsActivePage(page))
                        {
                            return(TestScript(character, Enums.TriggerEventConditionType.ClickEvent));
                        }
                    }
                }
            }

            //Gestion des events
            int eventIndex = MatrixManager.CurrentStage.EventsMatrix[point.X / matrixPrecision, point.Y / matrixPrecision] - 1;

            //Récupérer l'event associé
            if (eventIndex > -1)
            {
                hotSpot = _CurrentStage.ListHotSpots[eventIndex];
                return(TestScript(hotSpot, Enums.TriggerEventConditionType.ClickEvent));
            }
            #endregion

            return(false);
        }
        /// <summary>
        /// Prépare un perso à être dessiné.
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public VO_CharacterSprite DrawCharacter(VO_StageCharacter character)
        {
            VO_CharacterSprite characterSprite = null;

            RunServiceTask(delegate
            {
                characterSprite = _Business.DrawCharacter(character);
            }, ViewerErrors.STAGE_LOAD_MENU, false, character.ToString());

            return(characterSprite);
        }
        /// <summary>
        /// Récupère le CharacterSprite en fonction d'un characterId
        /// </summary>
        /// <param name="characterId"></param>
        /// <returns></returns>
        public VO_CharacterSprite GetCharacterSprite(Guid characterId)
        {
            VO_CharacterSprite character = null;

            RunServiceTask(delegate
            {
                character = _Business.GetCharacterSprite(characterId);
            }, ViewerErrors.STAGE_LOAD_MENU, characterId.ToString());

            return(character);
        }
Beispiel #6
0
 public virtual void Draw(VO_CharacterSprite characterToDraw, float scale, bool move)
 {
     Draw(characterToDraw.Sprites, move);
     if (move)
     {
         if (scale != characterToDraw.Scale.X)
         {
             characterToDraw.SetScale(new Vector2(scale, scale));
             characterToDraw.SetPosition(characterToDraw.Location.X, characterToDraw.Location.Y);
         }
         characterToDraw.GetNextPosition();
     }
 }
Beispiel #7
0
 /// <summary>
 /// Charge les PNJ
 /// </summary>
 /// <returns></returns>
 public static void LoadGamePNJ()
 {
     foreach (VO_GameStateCharacter character in State.CurrentStagePNJ)
     {
         VO_CharacterSprite characterSprite = _Service.GetCharacterSprite(character.Id);
         characterSprite.SetPosition(character.Coords.Location.X, character.Coords.Location.Y);
         characterSprite.CurrentDirection = character.CurrentDirection;
         characterSprite.Id                   = character.Id;
         characterSprite.CharacterId          = character.CharacterId;
         characterSprite.CurrentExecutingPage = character.CurrentExecutingPage;
         characterSprite.IsTalking            = character.IsTalking;
         characterSprite.CurrentPath          = character.CurrentPath;
         characterSprite.SetCurrentAnimation(characterSprite.CurrentCharacterAnimationType, character.CurrentAnim);
     }
 }
Beispiel #8
0
        /// <summary>
        /// Récupère et traite l'event
        /// </summary>
        /// <param name="point"></param>
        /// <param name="matrixPrecision"></param>
        public bool GetEventFromMatrix(Point point, int matrixPrecision)
        {
            //Gestion des characters
            foreach (VO_StageCharacter character in _CurrentStage.ListCharacters)
            {
                VO_CharacterSprite characterSprite = GetCharacterSprite(character.Id);
                if (characterSprite.PointIsInCharacter(point))
                {
                    //Activer l'event
                    foreach (VO_Page page in character.Event.PageList)
                    {
                        if (IsActivePage(page))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
            }

            //Gestion des events
            int eventIndex = MatrixManager.CurrentStage.EventsMatrix[point.X / matrixPrecision, point.Y / matrixPrecision] - 1;

            //Récupérer l'event associé
            if (eventIndex > -1)
            {
                VO_Event eventSpot = _CurrentStage.ListHotSpots[eventIndex].Event;

                //Activer l'event
                foreach (VO_Page page in eventSpot.PageList)
                {
                    if (IsActivePage(page) && page.TriggerCondition == Enums.TriggerEventConditionType.ClickEvent)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #9
0
        /// <summary>
        /// Sauvegarde une partie
        /// </summary>
        /// <param name="path"></param>
        public static void SaveGameState(string path)
        {
            //Enregistrement des personnages
            List <VO_Player> players = PlayableCharactersManager.GetPlayers();

            State.Players = new List <VO_GameStateCharacter>();
            foreach (VO_Player player in players)
            {
                VO_GameStateCharacter gameCharacter = new VO_GameStateCharacter();
                gameCharacter.Id                   = player.Id;
                gameCharacter.CharacterId          = player.CharacterSprite.CharacterId;
                gameCharacter.Coords               = new VO_Coords(new System.Drawing.Point(player.CharacterSprite.Location.X, player.CharacterSprite.Location.Y), player.CurrentStage);
                gameCharacter.CurrentAnim          = player.CharacterSprite.CurrentAnimationType;
                gameCharacter.CurrentDirection     = player.CharacterSprite.CurrentDirection;
                gameCharacter.Actions              = new List <Guid>();
                gameCharacter.Items                = new List <Guid>();
                gameCharacter.CurrentExecutingPage = player.CharacterSprite.CurrentExecutingPage;
                gameCharacter.IsTalking            = player.CharacterSprite.IsTalking;
                gameCharacter.CurrentPath          = player.CharacterSprite.CurrentPath;
                foreach (Guid action in player.Actions)
                {
                    gameCharacter.Actions.Add(action);
                }
                for (int i = 0; i < GameCore.Instance.Game.Menu.GridHeight; i++)
                {
                    for (int j = 0; j < GameCore.Instance.Game.Menu.GridWidth; j++)
                    {
                        if (player.Items[j, i] != Guid.Empty)
                        {
                            gameCharacter.Items.Add(player.Items[j, i]);
                        }
                    }
                }
                GameState.State.Players.Add(gameCharacter);
            }

            //Enregistrement de stages
            VO_Stage stage = GameCore.Instance.GetStageById(PlayableCharactersManager.CurrentPlayerCharacter.CurrentStage);

            State.CurrentStagePNJ = new List <VO_GameStateCharacter>();
            foreach (VO_StageCharacter character in stage.ListCharacters)
            {
                VO_CharacterSprite    characterSprite = _Service.GetCharacterSprite(character.Id);
                VO_GameStateCharacter gameCharacter   = new VO_GameStateCharacter();
                gameCharacter.Id                   = character.Id;
                gameCharacter.CharacterId          = character.CharacterId;
                gameCharacter.Coords               = new VO_Coords(new System.Drawing.Point(characterSprite.Location.X, character.Location.Y), Guid.Empty);
                gameCharacter.CurrentAnim          = characterSprite.CurrentAnimationType;
                gameCharacter.CurrentDirection     = characterSprite.CurrentDirection;
                gameCharacter.Actions              = new List <Guid>();
                gameCharacter.Items                = new List <Guid>();
                gameCharacter.CurrentExecutingPage = characterSprite.CurrentExecutingPage;
                gameCharacter.IsTalking            = characterSprite.IsTalking;
                gameCharacter.CurrentPath          = characterSprite.CurrentPath;
                GameState.State.CurrentStagePNJ.Add(gameCharacter);
            }

            //Enregistrement des Script courants
            if (ScriptManager.ParallelScripts != null)
            {
                foreach (VO_RunningScript runningScript in ScriptManager.ParallelScripts)
                {
                    VO_GameStateRunningScript runningScriptState = new VO_GameStateRunningScript();
                    runningScriptState.CurrentLine = runningScript.Id;
                    runningScriptState.ObjectState = runningScript.ObjectState;
                    runningScriptState.Script      = runningScript.Id;
                    runningScriptState.WaitFrames  = runningScript.WaitFrames;
                    State.RunningScripts.Add(runningScriptState);
                }
            }

            AppTools.SaveObjectToFile(GameState.State, GameCore.Instance.Game.Project.RootPath + "\\" + path);
        }
Beispiel #10
0
        /// <summary>
        /// Format Text
        /// </summary>
        /// <param name="message">VO_message du message</param>
        /// <returns>Sprite de texte</returns>
        public List <VO_String2D> FormatText(VO_Message message, VO_Size container, Point camera)
        {
            int cameraLeft = (int)camera.X;
            int cameraTop  = (int)camera.Y;
            VO_CharacterSprite character = null;
            List <VO_String2D> textes    = new List <VO_String2D>();

            if (message.Character == new Guid(GlobalConstants.CURRENT_PLAYER_ID))
            {
                character = PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite;
            }
            else
            {
                character = GetCharacterSprite(message.Character);
            }
            if (character != null && character.IsTalking)
            {
                //Calcul du Width idéal
                // Valeur idéale = ViewerConstants.MESS_MAXIMUM_WIDTH / en 640
                int idealValue = ViewerConstants.MESS_MAXIMUM_WIDTH * container.Width / 640;
                int miniValue  = ViewerConstants.MESS_MINIMUM_WIDTH * container.Width / 640;
                int xLeft      = character.Location.X - cameraLeft - idealValue / 2;
                int xRight     = character.Location.X - cameraLeft + idealValue / 2;

                //Cas où le texte mord sur la gauche
                if (xLeft < ViewerConstants.MESS_PADDING_BORDER)
                {
                    xLeft = ViewerConstants.MESS_PADDING_BORDER;
                    if (xRight - xLeft < miniValue)
                    {
                        xRight = miniValue;
                    }
                }
                //Cas où le texte mord sur la droite
                else if (xRight > container.Width - ViewerConstants.MESS_PADDING_BORDER)
                {
                    xRight = container.Width - 1 - ViewerConstants.MESS_PADDING_BORDER;
                    if (xRight - xLeft < miniValue)
                    {
                        xLeft = container.Width - miniValue - ViewerConstants.MESS_PADDING_BORDER;
                    }
                }

                //1 - On détermine la hauteur que devra prendre le texte
                int         lineWidth = xRight - xLeft;
                string[]    words     = message.Text.Split(" ".ToCharArray());
                string      finalMess = string.Empty;
                string      tempMess  = string.Empty;
                int         height    = ViewerConstants.MESS_PADDING_CHARACTER;
                VO_String2D text      = AddText(message.FontSize, character.DialogColor);
                foreach (string word in words)
                {
                    //On test si le texte ne dépasse pas le width
                    if (string.IsNullOrEmpty(tempMess))
                    {
                        tempMess = word;
                    }
                    else
                    {
                        tempMess = finalMess + " " + word;
                    }
                    text.Text = tempMess;

                    if ((int)text.Destination.Width > lineWidth)
                    {
                        text.Text = finalMess;
                        height   += (int)text.Destination.Height + ViewerConstants.MESS_PADDING_LINES;
                        textes.Add(text);

                        //New message
                        text      = AddText(message.FontSize, character.DialogColor);
                        finalMess = word;
                    }
                    else
                    {
                        finalMess = tempMess;
                    }
                }
                text.Text = finalMess;
                height   += (int)text.Destination.Height;
                textes.Add(text);

                int finalY = character.GetAnimPosition().Y - cameraTop - height;
                if (finalY < ViewerConstants.MESS_PADDING_BORDER)
                {
                    finalY = ViewerConstants.MESS_PADDING_BORDER;
                }
                Point pos = new Point(character.Location.X - cameraLeft, finalY);

                for (int i = 0; i < textes.Count; i++)
                {
                    int newX  = character.Location.X - cameraLeft - ((int)textes[i].Destination.Width / 2);
                    int newX2 = newX + (int)textes[i].Destination.Width;
                    if (newX < ViewerConstants.MESS_PADDING_BORDER)
                    {
                        newX = ViewerConstants.MESS_PADDING_BORDER;
                    }
                    else if (newX2 > container.Width - ViewerConstants.MESS_PADDING_BORDER)
                    {
                        newX -= newX2 - container.Width + ViewerConstants.MESS_PADDING_BORDER;
                    }
                    textes[i].Position = new Vector2(newX, finalY + i * ((int)text.Destination.Height + ViewerConstants.MESS_PADDING_LINES));
                }
            }

            return(textes);
        }
Beispiel #11
0
 public virtual void Draw(VO_CharacterSprite characterToDraw, float scale)
 {
     Draw(characterToDraw, scale, true);
 }