public AnimatedObject(string name, MonoGameDebugAnimator animator)
 {
     Animator = (MonoGameDebugAnimator)animator.Clone();
     Name     = name;
     Animator.AnimationFinished += AnimationFinished;
 }
예제 #2
0
 public MenuItem(string name, MonoGameDebugAnimator animator)
     : base(name, animator)
 {
     PlaySafely("idle");
 }
예제 #3
0
 public Robot(string name, MonoGameDebugAnimator animator)
     : base(name, animator)
 {
 }
        protected override void LoadContent()
        {
            Vector2 modelScale = new Vector2(_options.CurrentValue.ModelScale, _options.CurrentValue.ModelScale);

            _backgroundColor = Color.CornflowerBlue;
            Vector2 screenCenter = new Vector2(_options.CurrentValue.WindowWidth * 0.5f, _options.CurrentValue.WindowHeight * 0.5f);

            _spriteFont = Content.Load <SpriteFont>(_options.CurrentValue.FontName);

            DefaultProviderFactory <ISprite, SoundEffect> factory = new DefaultProviderFactory <ISprite, SoundEffect>(SpriterDemoOptions.Config, true);

            foreach (string scmlPath in _options.CurrentValue.RobotSprites)
            {
                SpriterDemoContentLoader loader = new SpriterDemoContentLoader(Content, scmlPath);
                loader.Fill(factory);

                Stack <SpriteDrawInfo> drawInfoPool = new Stack <SpriteDrawInfo>();

                foreach (SpriterEntity entity in loader.Spriter.Entities)
                {
                    var animator = new MonoGameDebugAnimator(entity, GraphicsDevice, factory, drawInfoPool);
                    _animators[Robot.Prefix + entity.Name] = animator;
                    //animator.Scale = modelScale;
                    //animator.Position = new Vector2(_options.CurrentValue.WindowWidth - (100 * modelScale.X), screenCenter.Y);
                    //animator.DrawBoxOutlines = true;
                    //animator.AnimationFinished += AnimatorFinished;
                }
            }

            foreach (string scmlPath in _options.CurrentValue.MenuSprites)
            {
                SpriterDemoContentLoader loader = new SpriterDemoContentLoader(Content, scmlPath);
                loader.Fill(factory);
                Stack <SpriteDrawInfo> drawInfoPool = new Stack <SpriteDrawInfo>();

                foreach (SpriterEntity entity in loader.Spriter.Entities)
                {
                    var menu = new MonoGameDebugAnimator(entity, GraphicsDevice, factory, drawInfoPool);
                    _animators[MenuItem.Prefix + entity.Name] = menu;
                }
            }

            var debugRobots = new List <string> {
                "offense_robot", "defense_robot", "utility_robot", "generic_robot"
            };

            foreach (var robotName in debugRobots)
            {
                string key = Robot.Prefix + robotName;
                if (_animators.ContainsKey(key))
                {
                    var robot = new Robot(robotName, _animators[key]);
                    robot.Animator.Position = new Vector2(250 * _robots.Count + 200, screenCenter.Y);
                    robot.Animator.Scale    = new Vector2(1f, 1f);
                    AddContextMenuItem(robot, "menu_tinker", MenuPosition.Left);
                    AddContextMenuItem(robot, "menu_attack", MenuPosition.Top);
                    AddContextMenuItem(robot, "menu_defend", MenuPosition.Right);

                    _robots[robot.Key] = robot;
                }
            }
            //_animator = _animators.First();
        }