예제 #1
0
파일: Objects.cs 프로젝트: dav3ck/Game
        //------------------------------------------------------------

        public Objects(int _Xtile, int _Ytile, int ID)
        {
            SpriteSheetName = "Test_Animation_SpriteSheet";
            this.Xtile      = _Xtile;
            this.Ytile      = _Ytile;

            this.prologueContent = Game1.prologueContent;

            LoadObjectData(ID);

            this.chunck = Chunck.CurrentChunck(this.Ytile);

            this.FrontSpriteBatch = Game1.FrontSpriteBatch;
            Tuple <int, int> _Screencords = Screen.ScreenCords(this.Xtile, this.Ytile);

            this.Xcord = _Screencords.Item1;
            this.Ycord = _Screencords.Item2;

            if (this.Solid == true)
            {
                SolidTile.AllSolidTiles.Add(new SolidTile(Tuple.Create(Xtile, Ytile), chunck));
            }

            InitializeAnimation(SpriteSheetName, 0, 0);
            //ObjectList.Add(this);
        }
예제 #2
0
파일: Objects.cs 프로젝트: dav3ck/Game
        public static void RemoveObj(List <Tuple <int, int> > _ObjectTiles)
        {
            /*List<Objects> _RemoveObjects = new List<Objects>();
             *
             * foreach (Tuple<int,int> y in _ObjectTiles)
             * {
             *  Objects _object = Objects.ObjectList.Find(x => x.Xtile == y.Item1 && x.Ytile == y.Item2);
             *  if (_object != null)
             *  {
             *      _RemoveObjects.Add(_object);
             *  }
             * } */

            /*foreach (var z in _RemoveObjects)
             * {
             *  Objects.ObjectList.Remove(z);
             * }*/

            /*List<SolidTile> _temp = new List<SolidTile>();
             *
             * foreach(var z in _RemoveObjects)
             * {
             *  _temp = SolidTile.AllSolidTiles.FindAll(x => x.Cords.Equals(Tuple.Create(z.Xtile, z.Ytile)));
             *  _temp.ForEach(x => SolidTile.AllSolidTiles.Remove(x));
             * } */

            _ObjectTiles.ForEach(y => Objects.ObjectList.Remove(Objects.ObjectList.Find(x => x.Xtile == y.Item1 && x.Ytile == y.Item2)));
            _ObjectTiles.ForEach(y => SolidTile.AllSolidTiles.Remove(SolidTile.AllSolidTiles.Find(x => x.Cords.Equals(y))));

            Chunck.Update();
        }
예제 #3
0
파일: Player.cs 프로젝트: dav3ck/Game
        public Player(int _Xtile, int _Ytile, SpriteBatch FrontSpriteBatch, PrologueContent prologueContent, List <Tiles> Tilelist)
        {
            LoadJson();

            this.XTile = _Xtile;
            this.YTile = _Ytile;

            imgPlayer   = prologueContent.imgPlayer;
            this.Width  = 16 * this.Scale;
            this.Height = 30 * this.Scale;

            this.CenterCordsX = (int)(this.XTile * Screen.GridSize + Screen.GridSize / 2);
            this.CenterCordsY = (int)(this.YTile * Screen.GridSize + Screen.GridSize / 2);

            this.chunck = 0;



            this.FrontSpriteBatch = FrontSpriteBatch;
            this.Tilelist         = Map.Tilelist;

            this.HitboxSize        = this.Width / 2;
            this.HitboxWidthMargin = (this.Width - this.HitboxSize) / 2;
            this.HitboxHalf        = this.HitboxSize / 2;

            this.ImageCordsX = (int)(this.CenterCordsX - this.Width / 2);
            this.ImageCordsY = (int)(this.CenterCordsY + (this.HitboxHalf) - this.Height);

            Player1 = this;
            Chunck.Update();
            Update();
        }
예제 #4
0
파일: Player.cs 프로젝트: dav3ck/Game
        public void Update()
        {
            this.CenterCordsX += (int)Horizontal_Momentum;
            this.CenterCordsY += (int)Vertical_Momentum;

            this.Hitbox = GetRectangle(this.CenterCordsX, this.CenterCordsY, (int)this.HitboxSize);

            Tuple <int, int> GridCords = Screen.GridCords(this.CenterCordsX, this.CenterCordsY);

            if (XTile != GridCords.Item1 || YTile != GridCords.Item2)
            {
                Console.WriteLine(GridCords);
                PrevTile = Tuple.Create(XTile, YTile);

                this.XTile = GridCords.Item1;
                this.YTile = GridCords.Item2;

                foreach (NPC x in NPC.NPClist)
                {
                    if (x.Follow)
                    {
                        x.Follower();
                    }
                }
            }

            int Cur_Chunck = Chunck.CurrentChunck(this.YTile);

            if (this.chunck != Cur_Chunck)
            {
                this.chunck = Cur_Chunck;
                Chunck.Update();
            }


            EventZone.PlayerIntersection(this.YTile);

            //Screen.CameraMovement(this.CenterCordsX, this.CenterCordsY);

            Horizontal_Momentum = 0;
            Vertical_Momentum   = 0;

            this.ImageCordsX = (int)(this.CenterCordsX - this.Width / 2);
            this.ImageCordsY = (int)(this.CenterCordsY + (this.HitboxHalf) - this.Height);



            foreach (Objects x in SolidTile.LoadedObjects)
            {
                x.Update(this.Hitbox);
            }

            Player1 = this;
        }
예제 #5
0
파일: Tiles.cs 프로젝트: dav3ck/Game
        public Tiles(int X, int Y, int ID, float Xcord, float Ycord, Texture2D tileimage, SpriteBatch spriteBatch, PrologueContent prologueContent)
        {
            this.prologueContent = prologueContent;

            GetTileData(ID);

            this.X = X;
            this.Y = Y;

            this.chunck = Chunck.CurrentChunck(this.Y);

            this.Xcord       = Xcord;
            this.Ycord       = Ycord;
            this.spriteBatch = spriteBatch;

            this.TileCords = Tuple.Create(X, Y);

            if (this.Solid == true)
            {
                SolidTile.AllSolidTiles.Add(new SolidTile(this.TileCords, this.chunck));
            }
        }
예제 #6
0
파일: Objects.cs 프로젝트: dav3ck/Game
 public static void CreateObj(List <int[]> _objects)
 {
     _objects.ForEach(x => Objects.ObjectList.Add(new Objects(x[0], x[1], x[2])));
     Chunck.Update();
 }