コード例 #1
0
        //private MovementModel SetMovementModelAnimationName(MovementModel movementModel, string animationName)
        //{
        //    if (!string.IsNullOrEmpty(animationName))
        //    {
        //        movementModel.AnimationName = animationName;
        //    }

        //    return movementModel;
        //}

        internal void MoveSprites(SpriteModel movementModel)
        {
            //movementModel.SpriteRenderM.transform.position = new Vector3(movementModel.CurrentX + 1f, movementModel.CurrentY + 1f);
            //spriteRenderM.material.SetFloat(spriteRenderM.name + switchmodel.X.ToString(), switchmodel.X);
            //GameObject.
            //movementModel.SpriteRenderM.
        }
コード例 #2
0
 public PickerModel(int Width, int Height, SpriteModel model)
 {
     this.model  = model;
     this.Width  = Width;
     this.Height = Height;
     colors      = new Color[Width, Height];
 }
コード例 #3
0
        public static SpriteVM Create(SpriteModel spriteModel)
        {
            var newSprite = new SpriteVM();

            newSprite.FromModel(spriteModel);
            return(newSprite);
        }
コード例 #4
0
 public PaletteMenu(int width, int height, SpriteModel spriteModel, PaletteModel paletteModel, Action brushChanged) : base(width, height)
 {
     this.spriteModel  = spriteModel;
     this.mouse        = new MouseWatch();
     this.paletteModel = paletteModel;
     this.brushChanged = brushChanged;
 }
コード例 #5
0
        private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!Keyboard.IsKeyDown(Key.N))
            {
                return;
            }

            startPoint = e.GetPosition(canvas);

            rect = new Rectangle
            {
                Stroke          = Brushes.LightBlue,
                StrokeThickness = 1
            };
            Canvas.SetLeft(rect, startPoint.X);
            Canvas.SetTop(rect, startPoint.X);
            // canvas.Children.Add(rect);

            //  var dc = (this.DataContext as AtlasModel);

            mNewDropElement           = new SpriteModel();
            mNewDropElement.Name      = "NewDroppedEle";
            mNewDropElement.Rectangle = rect;

            ((AtlasModel)this.DataContext).Rectangles.Add(rect);
            ((AtlasModel)this.DataContext).Items.Add(mNewDropElement);
        }
コード例 #6
0
 public SpriteCursor(SpriteModel sprite, int snapWidth = 1, int snapHeight = 1) : base(sprite.HotSpot)
 {
     _sprite     = sprite;
     _snapWidth  = snapWidth;
     _snapHeight = snapHeight;
     DrawOutline = false;
 }
コード例 #7
0
        public void Handle(string file, ILoadResult result)
        {
            switch (result)
            {
            case LoadBusy:
                Log($"[{file}]\nLoading...");
                hoveredFile = null;
                break;

            case LoadFailure f:
                Log($"[{file}]\n{f.message}");
                hoveredFile = null;
                break;

            case LoadSuccess s:
                Log($"[{file}]\nLoaded successfully");
                hoveredFile = s.preview;
                break;

            case LoadNonexistent s:
                Log($"[{file}]\nDoes not exist");
                hoveredFile = null;
                break;
            }
        }
コード例 #8
0
ファイル: SpriteModelViewModel.cs プロジェクト: vinczead/rpg
        public SpriteModelViewModel(SpriteModel spriteModel, SpriteModelsViewModel spriteModelsViewModel) : base()
        {
            SpriteModels = spriteModelsViewModel;
            if (spriteModel != null)
            {
                SpriteModel = spriteModel;
                Id          = spriteModel.Id;

                FrameWidth  = spriteModel.FrameSize.X;
                FrameHeight = spriteModel.FrameSize.Y;

                CollisionBoxX = spriteModel.CollisionBox.X;
                CollisionBoxY = spriteModel.CollisionBox.Y;

                CollisionBoxWidth  = spriteModel.CollisionBox.Width;
                CollisionBoxHeight = spriteModel.CollisionBox.Height;

                SpriteSheet = SpriteModels.MainViewModel.Textures.Items.FirstOrDefault(texture => texture.Id == spriteModel.SpriteSheet.Id);
                ReloadItems();
            }
            else
            {
                Items = new ObservableCollection <AnimationViewModel>();
            }

            SaveSpriteModel = new RelayCommand <Window>(ExecuteSaveSpriteModelCommand);
            ReloadItems();
        }
コード例 #9
0
 public PickerMenu(int width, int height, SpriteModel model, PickerModel colorGrid, Action colorPicked) : base(width, height)
 {
     this.model       = model;
     this.mouse       = new MouseWatch();
     this.colorPicker = colorGrid;
     this.colorPicked = colorPicked;
 }
コード例 #10
0
        public static void LoadSprites(GorillaModel gorilla, StreamReader sr, string line)
        {
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Contains("[Texture]") || line.Contains("[Font."))
                {
                    return;
                }

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var spriteTextData = line.Split(' ');

                SpriteModel newSprite = new SpriteModel();

                newSprite.Name   = spriteTextData[0];
                newSprite.posX   = convertToInt(spriteTextData[1]);
                newSprite.posY   = convertToInt(spriteTextData[2]);
                newSprite.width  = convertToInt(spriteTextData[3]);
                newSprite.height = convertToInt(spriteTextData[4]);

                gorilla.Sprites.Add(newSprite);
            }
        }
コード例 #11
0
 public ItemDefinition(ItemDefinition definition)
 {
     Id          = definition.Id;
     DisplayName = definition.DisplayName;
     Description = definition.Description;
     Icon        = definition.Icon;
     Rarity      = definition.Rarity;
 }
コード例 #12
0
        public static SpriteFromImageVM Create(SpriteModel spriteModel, Rectangle sourceRectangle)
        {
            var vm = new SpriteFromImageVM();

            vm.FromModel(spriteModel);
            vm.SourceRectangle = sourceRectangle;
            return(vm);
        }
コード例 #13
0
 protected void SetSprite(SpriteModel s)
 {
     _sprite       = s;
     _image.Width  = s.Width * Zoom;
     _image.Height = s.Height * Zoom;
     this.Width    = _image.Width;
     this.Height   = _image.Height;
 }
コード例 #14
0
ファイル: Movement.cs プロジェクト: RobinBradhe/GameProject
 void IMovement.MoveSprites(SpriteModel spriteModel)
 {
     _movementHelper.SetMovementModelKeyCode(spriteModel);
     if (spriteModel.SpriteRenderM != null)
     {
         //Movement of all sprites connected to SpritesMovingScript.
         _movementHelper.MoveSprites(spriteModel);
     }
 }
コード例 #15
0
ファイル: AtlasHelper.cs プロジェクト: blockspacer/FrankE
        public static void GenAtlas(MaxRectsBinPack binPack,
                                    ObservableCollection <System.Windows.UIElement> list,
                                    ObservableCollection <SpriteModel> oc,
                                    string pathToImageFolder,
                                    string searchFilext,
                                    SquareSize width,
                                    SquareSize height)
        {
            // MaxRectsBinPack test = new MaxRectsBinPack((int)width, (int)height, false);

            foreach (String imageFile in Directory.GetFiles(pathToImageFolder, searchFilext))
            {
                System.Drawing.Image image = System.Drawing.Image.FromFile(imageFile);
                Rect newPos = binPack.Insert(image.Width, image.Height, MaxRectsBinPack.FreeRectChoiceHeuristic.RectBestLongSideFit);

                Rectangle testRect = new Rectangle
                {
                    Stroke          = Brushes.LightBlue,
                    StrokeThickness = 0
                };

                ImageBrush  ib  = new ImageBrush();
                BitmapImage bmi = new BitmapImage(new Uri(imageFile, UriKind.Absolute));
                ib.ImageSource = bmi;
                testRect.Fill  = ib;

                testRect.Width  = newPos.Width;
                testRect.Height = newPos.Height;

                Canvas.SetLeft(testRect, newPos.Left);
                Canvas.SetTop(testRect, newPos.Top);

                list.Add(testRect);

                // canvas.Children.Add(testRect);

                SpriteModel newSprite = new SpriteModel()
                {
                    Path      = imageFile,
                    Rectangle = testRect,
                    Name      = System.IO.Path.GetFileName(imageFile),
                    posX      = (int)Math.Ceiling(newPos.Left),
                    posY      = (int)Math.Ceiling(newPos.Top),
                    width     = (int)Math.Ceiling(newPos.Width),
                    height    = (int)Math.Ceiling(newPos.Height)
                };

                //newSprite.Path = imageFile;
                //newSprite.Rectangle = testRect;

                oc.Add(newSprite);

                //pictureBox.Width = image.Width;
                //pictureBox.Height = image.Height;
                //pictureBox.Image = image;
            }
        }
コード例 #16
0
ファイル: ExecutionVisitor.cs プロジェクト: vinczead/rpg
 private void ClearState()
 {
     scope            = new Scope();
     errors           = new List <Error>();
     buildBreedOnly   = false;
     currentAnimation = null;
     currentBreed     = null;
     currentInstance  = null;
     currentModel     = null;
     currentRegion    = null;
 }
コード例 #17
0
        private void StageChanged(object sender, StageChangedEventArgs e)
        {
            _currentStage = e.Stage;

            if (_currentStage != null)
            {
                var player = _currentStage.Project.EntityByName("Player");
                if (player != null)
                {
                    _playerSprite = SpriteModel.ForEntity(player, _currentStage.Project);
                }
            }

            OnPropertyChanged("HasStage");
        }
コード例 #18
0
        public void UpdateIndexes(SpriteModel spriteModel)
        {
            var p = palette;

            foregroundIndex = p.IndexOf(spriteModel.brush.foreground);
            if (foregroundIndex == -1)
            {
                foregroundIndex = null;
            }

            backgroundIndex = p.IndexOf(spriteModel.brush.background);
            if (backgroundIndex == -1)
            {
                backgroundIndex = null;
            }
        }
コード例 #19
0
        public HistoryMenu(int width, int height, SpriteModel model) : base(width, height)
        {
            this.model = model;
            buttons    = new List <LabelButton>();
            scroll     = new ScrollVertical(height, historyLength, Scrolled)
            {
                Position = new Point(width - 1, 0)
            };
            this.Children.Add(scroll);
            mouse = new MouseWatch();

            void Scrolled()
            {
                lastScroll = DateTime.Now;
            }
        }
コード例 #20
0
        public Player(NetConnection netConn, Game gameInstance)
        {
            this.gameInstance = gameInstance;
            this.NetConn      = netConn;
            this.ID           = Player.GetUniqueId();

            if (netConn != null)
            {
                this.IP = netConn.RemoteEndpoint.Address.ToString();
            }

            if (gameInstance != null)
            {
                this.SpriteModel = new SpriteModel(gameInstance, 4);
                UpdateSpriteTexture();
                this.IdleAnimation = true;
            }
        }
コード例 #21
0
        public void Enter(Console console, string filepath)
        {
            var Width  = console.Width;
            var Height = console.Height;

            if (File.Exists(filepath))
            {
                try {
                    var sprite = ASECIILoader.DeserializeObject <SpriteModel>(File.ReadAllText(filepath));

                    if (sprite.filepath != filepath)
                    {
                        sprite.filepath = filepath;
                        File.WriteAllText($"{filepath}", ASECIILoader.SerializeObject(sprite));
                    }

                    sprite.OnLoad();
                    Game.Instance.Screen = new EditorMain(Width, Height, sprite);

                    Program.SaveState(new EditorState(filepath));
                } catch {
                    throw;
                }
            }
            else
            {
                var model = new SpriteModel(Width, Height)
                {
                    filepath = filepath
                };
                model.sprite.layers.Add(new Layer());

                File.WriteAllText(filepath, ASECIILoader.SerializeObject(model));
                console.Children.Add(new EditorMain(Width, Height, model));
            }
        }
コード例 #22
0
        public void UpdateIndexes(SpriteModel spriteModel)
        {
            var cell = spriteModel.brush.cell;

            brushIndex = tiles.FindIndex(t => t.cg.Matches(cell.cg));
        }
コード例 #23
0
 public TileMenu(int width, int height, SpriteModel spriteModel, TileModel tileModel, Action brushChanged) : base(width, height)
 {
     this.spriteModel  = spriteModel;
     this.tileModel    = tileModel;
     this.brushChanged = brushChanged;
 }
コード例 #24
0
    // Use this for initialization
    void Start()
    {
        fields = transform.Find("Fields/Viewport/Content/Text").GetComponent<Text>();
        background = transform.Find("Background").gameObject;
        spriteModel = GameObject.Find("StaticSpriteModel-Mono").GetComponent<SpriteModel>();
        billBoardRenderer = GameObject.Find("StaticSpriteModel-Mono/BillboardRenderer").GetComponent<BillBoardRenderer>();
        progressBar = transform.Find("ProgressBar").GetComponent<Slider>();

        frameSelector = transform.Find("FrameSelector").gameObject;
        frameButtons = new List<Button>();
        frameButtons.Add(frameSelector.transform.Find("Button").GetComponent<Button>());
        frameButtons[0].GetComponent<FrameButton>().Index = 0;
        Enable(false);

        isTestMode = GameObject.Find("TestMode") != null;
    }
コード例 #25
0
 public SpriteModelResourceContainer(SpriteModel spriteModel)
 {
     SpriteModel = spriteModel ?? throw new ArgumentNullException(nameof(spriteModel));
 }
コード例 #26
0
 public SpriteModelResourceContainer(Scene scene, SpriteModel spriteModel)
     : base(scene)
 {
     SpriteModel = spriteModel ?? throw new ArgumentNullException(nameof(spriteModel));
 }
コード例 #27
0
ファイル: SpriteModelViewModel.cs プロジェクト: vinczead/rpg
        public void ExecuteSaveSpriteModelCommand(Window window)
        {
            try
            {
                if (SpriteModel == null)
                {
                    if (World.Instance.Models.ContainsKey(Id))
                    {
                        throw new ArgumentException();
                    }
                    foreach (var animationVM in Items)
                    {
                        animationVM.Save();
                    }
                    var modelToAdd = new SpriteModel()
                    {
                        Id           = Id,
                        SpriteSheet  = SpriteSheet.Texture,
                        FrameSize    = new Microsoft.Xna.Framework.Vector2(FrameWidth, FrameHeight),
                        CollisionBox = new Microsoft.Xna.Framework.Rectangle(CollisionBoxX, CollisionBoxY, CollisionBoxWidth, CollisionBoxHeight),
                        Animations   = Items.Select(animation => animation.Animation).ToList()
                    };
                    SpriteModel = modelToAdd;

                    World.Instance.Models.Add(id, modelToAdd);
                    SpriteModels.Items.Add(this);
                }
                else
                {
                    if (SpriteModel.Id != Id && World.Instance.Models.ContainsKey(Id))
                    {
                        throw new ArgumentException();
                    }
                    World.Instance.Models.Remove(SpriteModel.Id);
                    var originalViewModel = SpriteModels.Items.First(item => item.Id == SpriteModel.Id);

                    SpriteModel.Id       = Id;
                    originalViewModel.Id = Id;

                    SpriteModel.FrameSize         = new Microsoft.Xna.Framework.Vector2(FrameWidth, FrameHeight);
                    originalViewModel.FrameHeight = FrameHeight;
                    originalViewModel.FrameWidth  = FrameWidth;

                    SpriteModel.CollisionBox             = new Microsoft.Xna.Framework.Rectangle(CollisionBoxX, CollisionBoxY, CollisionBoxWidth, CollisionBoxHeight);
                    originalViewModel.CollisionBoxHeight = CollisionBoxHeight;
                    originalViewModel.CollisionBoxWidth  = CollisionBoxWidth;
                    originalViewModel.CollisionBoxX      = CollisionBoxX;
                    originalViewModel.CollisionBoxY      = CollisionBoxY;

                    SpriteModel.SpriteSheet       = SpriteSheet.Texture;
                    originalViewModel.SpriteSheet = SpriteSheet;

                    originalViewModel.Items = Items;
                    foreach (var animationVM in Items)
                    {
                        animationVM.Save();
                    }
                    SpriteModel.Animations = Items.Select(animation => animation.Animation).ToList();

                    originalViewModel.NotifyReferencesOfChange();

                    World.Instance.Models.Add(id, SpriteModel);
                }
                window.Close();
            }
            catch
            {
                MessageBox.Show("Failed to add Sprite Model! A Sprite Model with the same id already exists!");
            }
        }
コード例 #28
0
ファイル: BillBoardRenderer.cs プロジェクト: fdu5526/LibViz
    void Awake()
    {
        model = transform.parent.GetComponent<SpriteModel> ();
        movie = GetComponent<AVProQuickTimeMovie> ();
        billboardRenderer = GetComponent<Renderer>();
        movie._folder = model.videoFolderPath;
        movie._filename = model.videoFileName;
        currentVideoType = VideoType.None;

        fullscreenSelectionUI = GameObject.Find("FullscreenSelectionUI").GetComponent<FullscreenSelectionUI>();
        prevFrameCount = 0;
        isPlaying = false;
        nextFrameTimer = new Timer(1f / 20f);
    }
コード例 #29
0
 // Start is called before the first frame update
 // Used like contructor.
 void Start()
 {
     _movement    = new Movement();
     _spriteModel = new SpriteModel();
     _spriteModel.SpriteRenderM = GetComponent <SpriteRenderer>();
 }
コード例 #30
0
 public SaveMode(SpriteModel model, Console renderer)
 {
     this.model    = model;
     this.renderer = renderer;
 }
コード例 #31
0
 public LoadSuccess(SpriteModel preview) => this.preview = preview;
コード例 #32
0
 public void MoveSprites(SpriteModel spriteModel)
 {
     _movement.MoveSprites(spriteModel);
 }