Ejemplo n.º 1
0
        public static void CreateCharacter(VO_Stage stage, Point position, Guid charId)
        {
            if (stage.ListCharacters.Count < GlobalConstants.PERF_MAX_CHARACTERS_PER_LAYERS)
            {
                VO_Character      character = GameCore.Instance.GetCharacterById(charId);
                VO_StageCharacter newChar   = new VO_StageCharacter();

                //Animation standing
                VO_Animation standingAnim = character.GetAnimationById(character.StandingAnim);
                newChar.AnimationId         = standingAnim.Id;
                newChar.Id                  = Guid.NewGuid();
                newChar.Title               = character.Title;
                newChar.Location            = position;
                newChar.Size                = new Size(standingAnim.SpriteWidth, standingAnim.SpriteHeight);
                newChar.CharacterId         = charId;
                newChar.ObjectType          = Enums.StageObjectType.Characters;
                newChar.Stage               = stage.Id;
                newChar.PlayerPositionPoint = new VO_Coords();
                newChar.Event               = CreateEvent(Enums.EventType.Character, character.Id);
                stage.ListCharacters.Add(newChar);
            }
            else
            {
                MessageBox.Show(string.Format(Errors.STAGE_MAX_CHARACTERS, GlobalConstants.PERF_MAX_CHARACTERS_PER_LAYERS), Errors.ERROR_BOX_TITLE);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Commande CharSay
        /// </summary>
        /// <param name="command"></param>
        private static void CommandCharSay(string[] command)
        {
            if (ScriptManager.CurrentScript == null)
            {
                string message = string.Join(" ", command, 3, command.Length - 3);

                string            characterName = command[1];
                VO_Stage          currentStage  = _Service.GetCurrentStage();
                VO_StageCharacter character     = currentStage.ListCharacters.Find(p => p.Title.ToLower() == characterName);

                if (character != null)
                {
                    VO_RunningScript runningScript = new VO_RunningScript();
                    runningScript.ScriptType = Enums.ScriptType.Events;
                    runningScript.Lines      = new List <VO_Line>();
                    VO_Script_Message messageScript = new VO_Script_Message();
                    messageScript.Dialog          = new VO_Dialog();
                    messageScript.Dialog.Messages = new List <VO_Message>();
                    messageScript.Dialog.Messages.Add(new VO_Message()
                    {
                        Character = character.Id, Duration = message.Length, FontSize = 14, Text = message
                    });
                    runningScript.Lines.Add(messageScript);
                    runningScript.CurrentLine   = runningScript.Lines[0];
                    ScriptManager.CurrentScript = runningScript;
                }
                else
                {
                    AddConsoleLine(string.Format("{0}: {1} not found", ConsoleConstants.C_SAY, command[1]));
                }
            }
        }
Ejemplo n.º 3
0
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
        {
            VO_StageCharacter character = Character;

            if (propertyValues["Title"] != null)
            {
                character.Title = propertyValues["Title"].ToString();
            }
            if (propertyValues["Location"] != null)
            {
                character.Location = (Point)propertyValues["Location"];
            }
            if (propertyValues["PlayerMustMove"] != null)
            {
                character.PlayerMustMove = (bool)propertyValues["PlayerMustMove"];
            }
            if (propertyValues["PlayerPositionPoint"] != null)
            {
                character.PlayerPositionPoint = (VO_Coords)propertyValues["PlayerPositionPoint"];
            }
            if (propertyValues["PlayerMoveEndDirection"] != null)
            {
                character.PlayerMoveEndDirection = (Enums.Movement)propertyValues["PlayerMoveEndDirection"];
            }
            if (propertyValues["ClassId"] != null && propertyValues["ClassId"] is Class)
            {
                character.ClassId = ((Class)propertyValues["ClassId"]).Id;
            }
            return(character);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection collection = new PropertyDescriptorCollection(null);

            Character  = (VO_StageCharacter)value;
            collection = Character.GetProperties();
            return(collection);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Commande CharSay
        /// </summary>
        /// <param name="command"></param>
        private static void CommandCharMove(string[] command)
        {
            if (ScriptManager.CurrentScript == null)
            {
                if (command.Length != 5)
                {
                    AddConsoleLine(string.Format("{0}: coords format is incorrect", ConsoleConstants.C_MOVE));
                }
                else
                {
                    int x = 0;
                    int y = 0;

                    try
                    {
                        x = Convert.ToInt32(command[3]);
                    }
                    catch
                    {
                        AddConsoleLine(string.Format("{0}: coords format is incorrect", ConsoleConstants.C_MOVE));
                        return;
                    }
                    try
                    {
                        y = Convert.ToInt32(command[4]);
                    }
                    catch
                    {
                        AddConsoleLine(string.Format("{0}: coords format is incorrect", ConsoleConstants.C_MOVE));
                        return;
                    }

                    string            characterName = command[1];
                    VO_Stage          currentStage  = _Service.GetCurrentStage();
                    VO_StageCharacter character     = currentStage.ListCharacters.Find(p => p.Title.ToLower() == characterName);

                    if (character != null)
                    {
                        VO_RunningScript runningScript = new VO_RunningScript();
                        runningScript.ScriptType = Enums.ScriptType.Events;
                        runningScript.Lines      = new List <VO_Line>();
                        VO_Script_MoveCharacter moveCharacter = new VO_Script_MoveCharacter();
                        moveCharacter.Character = character.Id;
                        moveCharacter.Coords    = new VO_Coords(new System.Drawing.Point(x, y), _Service.GetCurrentStage().Id);
                        runningScript.Lines.Add(moveCharacter);
                        runningScript.CurrentLine   = runningScript.Lines[0];
                        ScriptManager.CurrentScript = runningScript;
                    }
                    else
                    {
                        AddConsoleLine(string.Format("{0}: {1} not found", ConsoleConstants.C_MOVE, command[1]));
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <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);
        }
 private void ScriptCharacterMovement_Ok(object sender, EventArgs e)
 {
     if (cbxListCharacter.Items.Count <= 0)
     {
         MessageBox.Show(Culture.Language.Notifications.NO_CHARACTER_SELECTION);
     }
     else
     {
         CurrentCharacter  = (VO_StageCharacter)cbxListCharacter.SelectedItem;
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
Ejemplo n.º 9
0
        private void btnValidation(object sender, EventArgs e)
        {
            if (cmbCharacterList.Items.Count <= 0)
            {
                MessageBox.Show(Culture.Language.Notifications.NO_CHARACTER_SELECTION);
            }
            else
            {
                VO_StageCharacter CurrentStageCharacter = (VO_StageCharacter)cmbCharacterList.SelectedItem;

                CharacterId       = CurrentStageCharacter.Id;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
        /// <summary>
        /// Constructeur pour pnj
        /// </summary>
        public VO_CharacterSprite(VO_StageCharacter source)
        {
            _AnimationsStanding = new List <VO_AnimatedSprite[]>();
            _AnimationsWalking  = new List <VO_AnimatedSprite[]>();
            _AnimationsTalking  = new List <VO_AnimatedSprite[]>();
            VO_Character character = GameCore.Instance.GetCharacterById(source.CharacterId);

            this.Face        = character.Face;
            this.CharacterId = character.Id;
            this.Id          = source.Id;
            this.DialogColor = character.DialogColor;
            if (character.Face != Guid.Empty)
            {
                FaceAnim = new VO_AnimatedSprite(character.Face, Guid.Empty, Enums.AnimationType.CharacterFace, 0, 0, Constants.ViewerEnums.ImageResourceType.Screen);
            }
            this.Speed        = character.Speed;
            this.StandingAnim = character.StandingAnim;
            this.TalkingAnim  = character.TalkingAnim;
            this.Title        = source.Title;
            this.WalkingAnim  = character.WalkingAnim;

            _NbrDirections = GameCore.Instance.Game.Project.MovementDirections;

            foreach (VO_Animation anim in character.Animations)
            {
                VO_AnimatedSprite[] animationsStanding = new VO_AnimatedSprite[GameCore.Instance.Game.Project.MovementDirections];
                VO_AnimatedSprite[] animationsWalking  = new VO_AnimatedSprite[GameCore.Instance.Game.Project.MovementDirections];
                VO_AnimatedSprite[] animationsTalking  = new VO_AnimatedSprite[GameCore.Instance.Game.Project.MovementDirections];
                for (int i = 0; i < GameCore.Instance.Game.Project.MovementDirections; i++)
                {
                    animationsStanding[i] = new VO_AnimatedSprite(anim.Id, source.CharacterId, Enums.AnimationType.CharacterAnimation, 0, 0, Constants.ViewerEnums.ImageResourceType.Screen, i);
                    animationsWalking[i]  = new VO_AnimatedSprite(anim.Id, source.CharacterId, Enums.AnimationType.CharacterAnimation, 0, 0, Constants.ViewerEnums.ImageResourceType.Screen, i);
                    animationsTalking[i]  = new VO_AnimatedSprite(anim.Id, source.CharacterId, Enums.AnimationType.CharacterAnimation, 0, 0, Constants.ViewerEnums.ImageResourceType.Screen, i);
                }
                _AnimationsStanding.Add(animationsStanding);
                _AnimationsWalking.Add(animationsWalking);
                _AnimationsTalking.Add(animationsTalking);
            }
            _Scale = new Vector2(1, 1);

            CurrentExecutingPage = -1;

            VO_Animation anima = GameCore.Instance.GetCharAnimationById(this.CharacterId, this.StandingAnim);

            SetPosition(source.Location.X + anima.OriginPoint.X, source.Location.Y + anima.OriginPoint.Y);

            SetCurrentAnimation(Enums.CharacterAnimationType.Standing, this.StandingAnim);
        }
Ejemplo n.º 11
0
        private void OnLoad(object sender, EventArgs e)
        {
            cmbCharacterList.Items.Clear();
            VO_StageCharacter CurrentCharacter = null;

            foreach (VO_StageCharacter character in EditorHelper.Instance.GetCurrentStageInstance().ListCharacters)
            {
                cmbCharacterList.Items.Add(character);
                if (CharacterId == character.Id)
                {
                    CurrentCharacter = character;
                }
            }
            cmbCharacterList.DisplayMember = "Title";
            cmbCharacterList.ValueMember   = "Id";

            cmbCharacterList.Enabled = true;

            cmbAnimation.DataSource    = EnumHelper.ToList(typeof(Enums.CharacterAnimationType));
            cmbAnimation.DisplayMember = "Value";
            cmbAnimation.ValueMember   = "Key";

            if (IsAdd == true)
            {
                CharacterId   = Guid.Empty;
                AnimationType = Enums.CharacterAnimationType.Standing;
                cmbAnimation.SelectedIndex = 0;
                trkFrequency.Value         = GlobalConstants.PLAYER_NORMAL_SPEED;;
                Frequency          = GlobalConstants.PLAYER_NORMAL_SPEED;;
                prctFrequency.Text = Convert.ToString(GlobalConstants.PLAYER_NORMAL_SPEED) + "%";
                if (cmbCharacterList.Items.Count <= 0)
                {
                    cmbCharacterList.Enabled = false;
                    return;
                }
                cmbCharacterList.SelectedIndex = 0;
            }
            else
            {
                if (CurrentCharacter != null)
                {
                    cmbCharacterList.SelectedItem = CurrentCharacter;
                }
                cmbAnimation.SelectedValue = AnimationType;
                trkFrequency.Value         = Frequency;
                prctFrequency.Text         = Convert.ToString(Frequency) + "%";
            }
        }
Ejemplo n.º 12
0
        public VO_StageCharacter GetStageCharacter(Guid character)
        {
            foreach (VO_Stage item in Game.Stages)
            {
                VO_StageCharacter stageCharacter = item.ListCharacters.Find(i => i.Id == character);
                if (stageCharacter != null)
                {
                    return(stageCharacter);
                }
            }
            VO_StageCharacter NewStageCharacter = new VO_StageCharacter();

            NewStageCharacter.Id    = Guid.Empty;
            NewStageCharacter.Title = Culture.Language.NotFound.RESSOURCE_NOT_FOUND;
            return(NewStageCharacter);
        }
Ejemplo n.º 13
0
 private void ValidationButton_Click(object sender, EventArgs e)
 {
     if (cmbCharacterSelection.Items.Count <= 0)
     {
         MessageBox.Show(Culture.Language.Notifications.NO_CHARACTER_SELECTION);
     }
     else
     {
         VO_StageCharacter CtrlCharacter = (VO_StageCharacter)cmbCharacterSelection.SelectedItem;
         CurrentCharacterId = CtrlCharacter.Id;
         VO_ListItem CurrentMovement = (VO_ListItem)ddpMovements.SelectedItem;
         Direction         = (Enums.Movement)CurrentMovement.Id;
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
 }
Ejemplo n.º 14
0
        private void btnValidation(object sender, EventArgs e)
        {
            if (cmbCharacterList.Items.Count <= 0)
            {
                MessageBox.Show(Culture.Language.Notifications.NO_CHARACTER_SELECTION);
            }
            else
            {
                VO_StageCharacter CurrentStageCharacter = (VO_StageCharacter)cmbCharacterList.SelectedItem;

                CharacterId   = CurrentStageCharacter.Id;
                AnimationType = (Enums.CharacterAnimationType)((cmbAnimation.SelectedItem.GetType()).GetProperty("Key")).GetValue(cmbAnimation.SelectedItem, null);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
        private void OnLoad(object sender, EventArgs e)
        {
            cmbCharacterList.Items.Clear();
            VO_StageCharacter CurrentCharacter = null;

            foreach (VO_StageCharacter character in EditorHelper.Instance.GetCurrentStageInstance().ListCharacters)
            {
                cmbCharacterList.Items.Add(character);
                if (CharacterId == character.Id)
                {
                    CurrentCharacter = character;
                }
            }
            cmbCharacterList.DisplayMember = "Title";
            cmbCharacterList.ValueMember   = "Id";

            cmbAnimation.DataSource    = EnumHelper.ToList(typeof(Enums.CharacterAnimationType));
            cmbAnimation.DisplayMember = "Value";
            cmbAnimation.ValueMember   = "Key";

            cmbCharacterList.Enabled = true;

            if (IsAdd == true)
            {
                CharacterId   = Guid.Empty;
                AnimationType = Enums.CharacterAnimationType.Standing;
                cmbAnimation.SelectedIndex = 0;
                AllAnimation             = false;
                chxAllAnimations.Checked = false;
                if (cmbCharacterList.Items.Count <= 0)
                {
                    cmbCharacterList.Enabled = false;
                    return;
                }
                cmbCharacterList.SelectedIndex = 0;
            }
            else
            {
                if (CurrentCharacter != null)
                {
                    cmbCharacterList.SelectedItem = CurrentCharacter;
                }
                cmbAnimation.SelectedValue = AnimationType;
                chxAllAnimations.Checked   = AllAnimation;
            }
        }
Ejemplo n.º 16
0
        private void OnLoad(object sender, EventArgs e)
        {
            cmbCharacterList.Items.Clear();
            VO_StageCharacter CurrentCharacter = null;

            foreach (VO_StageCharacter character in EditorHelper.Instance.GetCurrentStageInstance().ListCharacters)
            {
                cmbCharacterList.Items.Add(character);
                if (CharacterId == character.Id)
                {
                    CurrentCharacter = character;
                }
            }
            cmbCharacterList.DisplayMember = "Title";
            cmbCharacterList.ValueMember   = "Id";

            cmbCharacterList.Enabled = true;

            if (IsAdd == true)
            {
                CharacterId = Guid.Empty;
                if (cmbCharacterList.Items.Count <= 0)
                {
                    cmbCharacterList.Enabled = false;
                    return;
                }
                cmbCharacterList.SelectedIndex = 0;
            }
            else
            {
                if (CurrentCharacter != null)
                {
                    cmbCharacterList.SelectedItem = CurrentCharacter;
                }
            }
        }