Exemple #1
0
 void Awake()
 {
     ballProperites   = Object.FindObjectOfType <BallProperites>();
     backgroundObject = Object.FindObjectOfType <BackgroundImages>();
     newLevel         = Object.FindObjectOfType <NewLevel>();
     BallRigidbody    = this.gameObject.GetComponent <Rigidbody>();
     IsGrounded       = false;
     DistanceX        = 0.5f;
     DistanceY        = 2f;
 }
Exemple #2
0
        public void HandleBackground()
        {
            for (int i = 0; i < 16; i++)
            {
                if (BackgroundImages.Count < i)
                {
                    Sprite s = new Sprite(Content.GetTexture("background1.png"));
                    s.Position = new Vector2f((float)(s.Texture.Size.X * (i - 1)) - MAPXOFFSET, 225 - MAPYOFFSET);
                    BackgroundImages.Add(s);
                }
            }
            for (int i = 0; i < 16; i++)
            {
                if (BackgroundImagesFar.Count < i)
                {
                    Sprite s = new Sprite(Content.GetTexture("background1Far.png"));
                    s.Position = new Vector2f((float)(s.Texture.Size.X * (i - 1)) - MAPXOFFSET, 300 - MAPYOFFSET);
                    BackgroundImagesFar.Add(s);
                }
            }
            for (int i = 0; i < 150; i++)
            {
                if (BackgroundTracks.Count < i)
                {
                    Sprite s = new Sprite(Content.GetTexture("tracksBlur.png"));
                    s.Position = new Vector2f((float)((s.Texture.Size.X) * (i - 1)) - MAPXOFFSET, 515 - MAPYOFFSET);
                    BackgroundTracks.Add(s);
                }
            }

            for (int i = 0; i < BackgroundImages.Count; i++) //Main Background
            {
                BackgroundImages[i].Position -= new Vector2f(1, 0);
                if (BackgroundImages[i].Position.X < -BackgroundImages[i].Texture.Size.X - MAPXOFFSET)
                {
                    BackgroundImages.RemoveAt(i);
                }
            }
            for (int i = 0; i < BackgroundImagesFar.Count; i++) //Far Background
            {
                BackgroundImagesFar[i].Position -= new Vector2f(.2f, 0);
                if (BackgroundImagesFar[i].Position.X < -BackgroundImagesFar[i].Texture.Size.X - MAPXOFFSET)
                {
                    BackgroundImagesFar.RemoveAt(i);
                }
            }
            for (int i = 0; i < BackgroundTracks.Count; i++) //Tracks
            {
                BackgroundTracks[i].Position -= new Vector2f(20, 0);
                if (BackgroundTracks[i].Position.X < -BackgroundTracks[i].Texture.Size.X - MAPXOFFSET)
                {
                    BackgroundTracks.RemoveAt(i);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Clears out all the map's contents.
        /// </summary>
        protected override void Clear()
        {
            _particleEffects.Clear();
            _refractionEffects.Clear();

            foreach (var light in Lights.ToArray())
            {
                RemoveLight(light);
            }

            foreach (var bgImage in BackgroundImages.ToArray())
            {
                RemoveBackgroundImage(bgImage);
            }

            base.Clear();
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(View("Error"));
            }
            BackgroundImages image = await _context.BackgroundImages.FindAsync(id);

            return(View(image));
        }
Exemple #5
0
        public async Task <IActionResult> EditPost(BackgroundImages image)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Xaiş olunur düzgün doldurun.");
                return(View(image));
            }

            BackgroundImages currentImages = await _context.BackgroundImages.FindAsync(image.Id);

            if (image.CupPhoto != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "images", currentImages.CupPhotoURL);
                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }
                if (image.CupPhoto.ContentType.Contains("image/"))
                {
                    string filename = await image.CupPhoto.SaveWithoutFolderAsync(_env.WebRootPath);

                    currentImages.CupPhotoURL = filename;
                }
            }
            if (image.HistoryPhoto != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "images", currentImages.HistoryPhotoURL);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                if (image.HistoryPhoto.ContentType.Contains("image/"))
                {
                    string filename = await image.HistoryPhoto.SaveWithoutFolderAsync(_env.WebRootPath);

                    currentImages.HistoryPhotoURL = filename;
                }
            }
            if (image.SquadPhoto != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "images", currentImages.SquadPhotoURL);
                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }
                if (image.SquadPhoto.ContentType.Contains("image/"))
                {
                    string filename = await image.SquadPhoto.SaveWithoutFolderAsync(_env.WebRootPath);

                    currentImages.SquadPhotoURL = filename;
                }
            }
            if (image.StadiumPhoto != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "images", currentImages.StadiumPhotoURL);
                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }
                if (image.StadiumPhoto.ContentType.Contains("image/"))
                {
                    string filename = await image.StadiumPhoto.SaveWithoutFolderAsync(_env.WebRootPath);

                    currentImages.StadiumPhotoURL = filename;
                }
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction("ImageIndex"));
        }
Exemple #6
0
        public override void Draw()
        {
            base.Draw();
            //MainGame.Camera.Center = player.Pos - new Vector2f(0,90);


            Vector2f focus = player.Core +
                             new Vector2f(Input.screenMousePos.X - MainGame.WindowSize.X / 2,
                                          Input.screenMousePos.Y - MainGame.WindowSize.Y / 2) * player.CrosshairCameraRatio;

            if (Helper.Distance(player.Core, focus) > PlayerAimSphereRadius)
            {
                focus = player.Core + Helper.PolarToVector2(PlayerAimSphereRadius, player.AimAngle, 1, 1);//player.Core + Helper.normalize(focus) * 100;
            }
            Helper.MoveCameraTo(MainGame.Camera, focus, .04f);

            if (MainGame.Camera.Center.Y > 180 - 90)
            {
                focus.Y = player.Pos.Y - 90;
                MainGame.Camera.Center = new Vector2f(MainGame.Camera.Center.X, 180 - 90);
            }

            //Camera2D.returnCamera(player.ActorCenter +
            //            new Vector2(Main.screenMousePos.X - Main.graphics.PreferredBackBufferWidth / 2,
            //                Main.screenMousePos.Y - Main.graphics.PreferredBackBufferHeight / 2) *
            //                Main.graphics.GraphicsDevice.Viewport.AspectRatio / player.currentWeapon.viewDistance);

            MainGame.window.SetView(MainGame.window.DefaultView);
            shader.Shader.SetParameter("offsetY", MainGame.Camera.Center.Y);
            RectangleShape rs = new RectangleShape
            {
                Size = new Vector2f(800, 600)
            };

            MainGame.window.Draw(rs, shader);
            MainGame.window.SetView(MainGame.Camera);

            //foreach (Sprite s in BackgroundImagesFar)
            //{
            //    s.Position = new Vector2f(s.Position.X, 280 - MAPYOFFSET + (player.Pos.Y / 15));
            //}

            BackgroundImagesFar.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            BackgroundImages.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            BackgroundGameObjects.ForEach(p => { p.Draw(); });
            BackgroundTracks.ForEach(p => { p.Draw(MainGame.window, RenderStates.Default); });
            HandleBackground();



            MainGame.window.Draw(new Sprite(Content.GetTexture("mapDecor.png")));
            int insideY = 65;

            if (player.Pos.Y > insideY)
            {
                //trainSoundExterior.volume = 1;
                trainSound = trainSoundExterior;
                // trainSoundInterior.volume = 0;
                interiorAlpha += (255f - interiorAlpha) * .1f;
            }
            else
            {
                //trainSoundInterior.volume = 0;
                interiorAlpha *= .95f;
                //trainSound = trainSoundInterior;
                //trainSoundExterior.volume = 0;
            }
            Render.Draw(Content.GetTexture("mapInterior.png"), new Vector2f(0, 0), new Color(255, 255, 255, (byte)interiorAlpha), new Vector2f(0, 0), 1, 0f);
            // MainGame.window.Draw(new Sprite(Content.GetTexture("mapInterior.png")));

            Players.ForEach(p => { p.Draw(); });
            Projectiles.ForEach(p => { p.Draw(); });
            GameObjects.ForEach(p => { p.Draw(); });



            if (player.Pos.Y < insideY)
            {
                Render.Draw(Content.GetTexture("mapDecor.png"), new Vector2f(0, 0), new Color(255, 255, 255, (byte)(255 - interiorAlpha)), new Vector2f(0, 0), 1, 0f);
            }
            //MainGame.window.Draw(mapSprite);
            Gui.Draw();
        }
Exemple #7
0
        public async Task <IActionResult> EditPost(BackgroundImages image)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.Hall   = _context.Halls;
                ViewBag.Active = "Site";

                ModelState.AddModelError("", "Xaiş olunur düzgün doldurun.");
                return(View(image));
            }

            BackgroundImages currentImages = await _context.BackgroundImages.FindAsync(image.Id);

            if (image.PhotoOne != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "img", currentImages.PhotoURLOne);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                if (image.PhotoOne.ContentType.Contains("image/"))
                {
                    string filename = await image.PhotoOne.SaveAsync(_env.WebRootPath);

                    currentImages.PhotoURLOne = filename;
                }
            }
            if (image.PhotoTwo != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "img", currentImages.PhotoURLTwo);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                if (image.PhotoTwo.ContentType.Contains("image/"))
                {
                    string filename = await image.PhotoTwo.SaveAsync(_env.WebRootPath);

                    currentImages.PhotoURLTwo = filename;
                }
            }
            if (image.PhotoThree != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "img", currentImages.PhotoURLThree);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                if (image.PhotoThree.ContentType.Contains("image/"))
                {
                    string filename = await image.PhotoThree.SaveAsync(_env.WebRootPath);

                    currentImages.PhotoURLThree = filename;
                }
            }
            if (image.PhotoFour != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "img", currentImages.PhotoURLFour);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                if (image.PhotoFour.ContentType.Contains("image/"))
                {
                    string filename = await image.PhotoFour.SaveAsync(_env.WebRootPath);

                    currentImages.PhotoURLFour = filename;
                }
            }
            if (image.PhotoFive != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "img", currentImages.PhotoURLFive);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                if (image.PhotoFive.ContentType.Contains("image/"))
                {
                    string filename = await image.PhotoFive.SaveAsync(_env.WebRootPath);

                    currentImages.PhotoURLFive = filename;
                }
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction("ImageIndex"));
        }