Exemple #1
0
 public static bool CheckObjectExistence(VO_Coords CurrentValidation)
 {
     if (CurrentValidation == null || CurrentValidation.Location.X < 0 || CurrentValidation.Location.Y < 0)
     {
         return(false);
     }
     return(true);
 }
Exemple #2
0
        public static bool CheckMapExistence(VO_Coords CurrentValidation)
        {
            if (CurrentValidation.Map == Guid.Empty)
            {
                return(false);
            }
            VO_Stage CurrentStage = GameCore.Instance.GetStageById(CurrentValidation.Map);

            if (CurrentStage == null || CurrentStage.Id == Guid.Empty)
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Constructeur pour joueur
        /// </summary>
        public VO_CharacterSprite(VO_Character source, Enums.Movement startingPos, VO_Coords coords)
        {
            _AnimationsStanding = new List <VO_AnimatedSprite[]>();
            _AnimationsWalking  = new List <VO_AnimatedSprite[]>();
            _AnimationsTalking  = new List <VO_AnimatedSprite[]>();

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

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

            foreach (VO_Animation anim in source.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.Id, Enums.AnimationType.CharacterAnimation, 0, 0, Constants.ViewerEnums.ImageResourceType.Permanent, i);
                    animationsWalking[i]  = new VO_AnimatedSprite(anim.Id, source.Id, Enums.AnimationType.CharacterAnimation, 0, 0, Constants.ViewerEnums.ImageResourceType.Permanent, i);
                    animationsTalking[i]  = new VO_AnimatedSprite(anim.Id, source.Id, Enums.AnimationType.CharacterAnimation, 0, 0, Constants.ViewerEnums.ImageResourceType.Permanent, i);
                }
                _AnimationsStanding.Add(animationsStanding);
                _AnimationsWalking.Add(animationsWalking);
                _AnimationsTalking.Add(animationsTalking);
            }
            _Scale = new Vector2(1, 1);

            SetPosition(coords.Location.X, coords.Location.Y);
            CurrentExecutingPage = -1;
            CurrentDirection     = startingPos;
            SetCurrentAnimation(Enums.CharacterAnimationType.Standing, this.StandingAnim);
        }
Exemple #4
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            VO_Coords ct = value as VO_Coords;

            if (svc != null && ct != null)
            {
                using (CoordsManager form = new CoordsManager())
                {
                    form.SourceObject       = new System.Drawing.Rectangle(ct.Location, new System.Drawing.Size(0, 0));
                    form.UseStageBackground = true;
                    if (svc.ShowDialog(form) == DialogResult.OK)
                    {
                        ct    = form.DestinationObject; // update object
                        value = form.DestinationObject;
                    }
                }
            }
            return(value); // can also replace the wrapper object here
        }
Exemple #5
0
        /// <summary>
        /// Survient à l'ouverture de la fenetre
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //Maximiser l'écran
            this.WindowState = FormWindowState.Maximized;
            this.Stop();

            //Si UseStages, UseStageBackground doit être activé.
            if (UseStages)
            {
                UseStageBackground = true;
            }

            //Désactive les eventhandlers
            ddpX.ValueChanged -= new EventHandler(ddpX_ValueChanged);
            ddpY.ValueChanged -= new EventHandler(ddpY_ValueChanged);
            if (UseStages)
            {
                ddpMap.SelectedIndexChanged -= new EventHandler(ddpMap_SelectedIndexChanged);
            }

            //Adapter la preview à la taille de la resolution source
            DestinationObject = new VO_Coords();
            Guid ensuredMapGuid = Guid.Empty;

            if (UseStages)
            {
                LoadStages();
                DestinationObject = new VO_Coords(SourceFullObject.Location, SourceFullObject.Map);
                VO_Stage stage = GameCore.Instance.Game.Stages.Find(p => p.Id == SourceFullObject.Map);
                if (stage != null)
                {
                    ensuredMapGuid = stage.Id;
                }
                if (ensuredMapGuid != Guid.Empty)
                {
                    SourceResolution = GameCore.Instance.GetStageById(SourceFullObject.Map).Dimensions;
                }
                else
                {
                    SourceResolution = new Size(GameCore.Instance.Game.Project.Resolution.Width, GameCore.Instance.Game.Project.Resolution.Height);
                }
                SourceObject = new Rectangle(SourceFullObject.Location, new Size(SourceObject.Width, SourceObject.Height));
            }
            else if (UseStageBackground)
            {
                SourceResolution = EditorHelper.Instance.GetCurrentStageInstance().Dimensions;
            }
            this.Preview.Width  = SourceResolution.Width;
            this.Preview.Height = SourceResolution.Height;

            //Créer le décor
            if (_StageImage != null)
            {
                _StageImage.Dispose();
            }
            if (ensuredMapGuid != Guid.Empty)
            {
                _StageImage   = LoadMapDecors(ensuredMapGuid);
                Preview.Image = _StageImage;
            }
            else if (UseStageBackground && EditorHelper.Instance.CurrentStage != Guid.Empty)
            {
                _StageImage   = LoadMapDecors(EditorHelper.Instance.CurrentStage);
                Preview.Image = _StageImage;
            }
            else
            {
                Preview.Image = _Service.LoadBackground(new Size(this.Preview.Width, this.Preview.Height), false);
            }

            //Si Anim, on lance un timer
            if (UseAnimations)
            {
                _CurrentSprite.Width  = this.SourceAnim.SpriteWidth;
                _CurrentSprite.Height = this.SourceAnim.SpriteHeight;
                _CurrentSprite.X      = 0;
                _CurrentSprite.Y      = 0;
                this.Start();
            }

            //Gère map ou non
            if (UseStages)
            {
                grpMaps.Visible    = true;
                btnCancel.Location = new Point(97, 270);
                btnOK.Location     = new Point(13, 270);
            }
            else
            {
                grpMaps.Visible    = false;
                btnCancel.Location = new Point(97, 188);
                btnOK.Location     = new Point(13, 188);
            }

            //Destination = source
            if (SourceObject.X > SourceResolution.Width - 1 || SourceObject.Y > SourceResolution.Height - 1)
            {
                SourceObject = new Rectangle(0, 0, SourceObject.Width, SourceObject.Height);
            }
            DestinationObject.Location = new Point(SourceObject.X, SourceObject.Y);

            //Binding des infos
            ddpX.Minimum = 0;
            ddpY.Minimum = 0;
            ddpX.Maximum = SourceResolution.Width - 1;
            ddpY.Maximum = SourceResolution.Height - 1;
            ddpX.Value   = DestinationObject.Location.X;
            ddpY.Value   = DestinationObject.Location.Y;

            //Réactive les eventhandlers
            ddpX.ValueChanged += new EventHandler(ddpX_ValueChanged);
            ddpY.ValueChanged += new EventHandler(ddpY_ValueChanged);
            if (UseStages)
            {
                ddpMap.SelectedIndexChanged += new EventHandler(ddpMap_SelectedIndexChanged);
            }
        }