public void LoadContent() { #region Entity Textures AnimatedTextures.Add("Entity\\Bird", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_bird_animated.png")); AnimatedTextures.Add("Entity\\Paratroopa", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_paratroopa_animated.png")); Textures.Add("Entity\\Bird", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_bird.png")); Textures.Add("Entity\\DeadBird", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_bird_dead.png")); Textures.Add("Entity\\Boomba", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_boomba.png")); Textures.Add("Entity\\Bullet", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_bullet.png")); Textures.Add("Entity\\Paratroopa", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_paratroopa.png")); Textures.Add("Entity\\Pipe", ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_pipe.png")); #endregion #region UI Textures Textures.Add("UI\\Button", ParallaxBackground.GetFromPng("Content\\Textures\\Button\\flappy_button")); Textures.Add("UI\\ButtonExit", ParallaxBackground.GetFromPng("Content\\Textures\\Button\\flappy_button_exit")); Textures.Add("UI\\ButtonRestart", ParallaxBackground.GetFromPng("Content\\Textures\\Button\\flappy_button_restart")); Textures.Add("UI\\ButtonPipe", ParallaxBackground.GetFromPng("Content\\Textures\\Button\\flappy_level_pipes")); Textures.Add("UI\\ButtonBullet", ParallaxBackground.GetFromPng("Content\\Textures\\Button\\flappy_level_bullet")); Textures.Add("UI\\ButtonParatroopa", ParallaxBackground.GetFromPng("Content\\Textures\\Button\\flappy_level_paratroopa")); #endregion }
public Paratroopa(Type type, float speedModifier) : base(type) { this.DeadTexture = ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_paratroopa"); this.Position = new Vector2(Statics.GAME_WIDTH + this.DeadTexture.Width, Statics.GAME_RANDOM.Next(Statics.GAME_HEIGHT / 2, Statics.GAME_FLOOR)); this.Width = this.DeadTexture.Width; this.Height = this.DeadTexture.Height; this.EntityType = type; this.MoveSpeed = _baseSpeed + speedModifier + Statics.GAME_RANDOM.Next(0, 3); this.ColorData = new Color[this.Width * this.Height]; this.DeadTexture.GetData(ColorData); Texture2D animated_Texture = ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_paratroopa_animated"); _paratroopa_Sprite = new AnimatedSprite(); _paratroopa_Sprite.Initialize(animated_Texture, this.Position, this.Rotation, 128, 128, 4, 60, Color.White, this.Scale, true); _originPos = this.Position; _destinationPos = new Vector2(-this.Width, this.Position.Y); _dirAngle = Math.Atan2(_destinationPos.Y - _originPos.Y, _destinationPos.X - _originPos.X); _amp = Statics.GAME_RANDOM.Next(4, 8); _soundCounter = 0; _soundFrequency = 60; }
void Start() { S = this; if (parallaxCamera == null) parallaxCamera = Camera.main.GetComponent<ParallaxCamera>(); if (parallaxCamera != null) parallaxCamera.onCameraTranslate += Move; SetLayers(); }
public void Awake() { notwalking = false; mileNum = 1; milestone = 500; multiplier = 1.0f; M = FindObjectOfType <Monster>(); pb = FindObjectOfType <ParallaxBackground>(); }
public void Initialize() { parallax = new ParallaxBackground(new Vector2D(0, 0), new Vector2D(-0.5f, -0.3f)); parallax.AddLayer("layer_1"); parallax.AddLayer("layer_1", new Vector2D(-1, -0.6f), parallax.DefaultPosition); parallax.Scale(0.5f); }
public BackgroundPanel(Rectangle elementRectangle, GameSession gameSession) : base(elementRectangle) { this.gameSession = gameSession; Random random = new Random(); MapTexturePack texturePack = GameMap.MapTexturePacks[random.Next(0, GameMap.MapTexturePacks.Length)].Deploy(); parallaxBackground = new ParallaxBackground(texturePack.BackgroundImages); }
public static bool Prefix(xTile.Dimensions.Rectangle viewport, Background __instance) { if (__instance is ParallaxBackground) { ParallaxBackground bg = (__instance as ParallaxBackground); bg.update(viewport); return(false); } return(true); }
public static bool Prefix(SpriteBatch b, Background __instance) { if (__instance is ParallaxBackground) { ParallaxBackground bg = (__instance as ParallaxBackground); bg.draw(b); return(false); } return(true); }
void Awake() { level = GameObject.FindGameObjectWithTag("Level"); levelScript = level.GetComponent <Level> (); protagonist = GameObject.Find("Protagonist"); protagonistScript = protagonist.GetComponent <Protagonist> (); backgroundScript = GameObject.Find("Background").GetComponent <ParallaxBackground> (); symbolScript = GameObject.Find("Symbol").GetComponent <Symbol>(); }
public void Awake() { ContinuePlay = false; isDead = false; notwalking = inst_again = inst_again2 = false; mileNum = 1; milestone = 50; multiplier = 1.0f; M = FindObjectOfType <Monster>(); pb = FindObjectOfType <ParallaxBackground>(); }
public GameState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content, TextureManager textureManager, int lvl) : base(game, graphicsDevice, content, textureManager) { background = new ParallaxBackground(textureManager.backgroundTextures); background.Initialize(); level = new Level(content, textureManager.tileTexture, lvl); level.Initialize(); player = new Player(new KeyboardInput(), level.tiles); player.animationManager = new PlayerAnimationManager(textureManager.idleTextureR, textureManager.idleTextureL, textureManager.runTextureR, textureManager.runTextureL, textureManager.jumpTextureR, textureManager.jumpTextureL); }
void CallbackFunction() { foreach (object o in pbs) { ParallaxBackground pb = (ParallaxBackground)o; if (pb != null && SceneView.lastActiveSceneView != null) { pb.transform.position = pb.startPosition + (Vector3)(Vector2)(SceneView.lastActiveSceneView.camera.transform.position - pb.startPosition) * (1 - 1 / ((pb.distance / 10f) + 1)); } } }
public Pipe(Type type, float speedModifier) : base(type) { this.DeadTexture = ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_pipe"); this.Position = new Vector2(Statics.GAME_WIDTH, Statics.GAME_RANDOM.Next(Statics.GAME_HEIGHT / 4 - this.DeadTexture.Height / 2, Statics.GAME_HEIGHT / 4 - this.DeadTexture.Height / 4)); this.Width = this.DeadTexture.Width; this.Height = this.DeadTexture.Height; this.EntityType = type; this.MoveSpeed = _baseSpeed + speedModifier; this.ColorData = new Color[this.Width * this.Height]; this.DeadTexture.GetData(ColorData); }
public Bullet(Type type, float speedModifier) : base(type) { this.DeadTexture = ParallaxBackground.GetFromPng("Content\\Textures\\Entity\\flappy_bullet"); this.Position = new Vector2(Statics.GAME_WIDTH, Statics.GAME_RANDOM.Next((int)Statics.DEBUG_PLAYER.Y - (int)((this.DeadTexture.Height / 2) * this.Scale), (int)Statics.DEBUG_PLAYER.Y - (int)((this.DeadTexture.Height / 4) * this.Scale))); this.Width = this.DeadTexture.Width; this.Height = this.DeadTexture.Height; this.EntityType = type; this.MoveSpeed = _baseSpeed + speedModifier; this.ColorData = new Color[this.Width * this.Height]; this.DeadTexture.GetData(ColorData); }
private void Awake() { MM = FindObjectOfType <MonsterManager>(); An = GetComponent <Animator>(); if (Application.loadedLevelName == "StepCounter") { pb = FindObjectOfType <ParallaxBackground>(); } if (Application.loadedLevelName == "Battle") { BS = FindObjectOfType <BattleScript>(); } }
public GameMap(Random random, GraphicsDevice graphicsDevice, GameSession gameSession) { this.gameSession = gameSession; mapArchitecture = MapArchitectures[random.Next(0, MapArchitectures.Length)]; texturePack = MapTexturePacks[random.Next(0, MapTexturePacks.Length)].Deploy(); ReferenceMap = new CollisionReferenceMap <RigidBody>(MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE); ParticleReferenceMap = new CollisionReferenceMap <RigidBody>(MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE); NoCollideMap = new CollisionReferenceMap <RigidBody>(1, 1, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE); parallaxBackground = new ParallaxBackground(texturePack.BackgroundImages); camera = new Camera(this, graphicsDevice); AddArchitectureCollision(); }
void Start() { level = GameObject.FindGameObjectWithTag("Level"); levelScript = level.GetComponent <Level>(); symbolScript = GameObject.Find("Symbol").GetComponent <Symbol>(); goalScript = GameObject.Find("Goal").GetComponent <Goal>(); backgroundScript = GameObject.Find("Background").GetComponent <ParallaxBackground> (); getActions(); runningSprite = transform.GetChild(0).gameObject; slidingSprite = transform.GetChild(1).gameObject; if (GameObject.FindGameObjectWithTag("EndlessManager") != null) { endlessScript = GameObject.FindGameObjectWithTag("EndlessManager").GetComponent <EndlessManager>(); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); try //To check if anything loads incorrectly. { MCharacter = new MC(Content, GraphicsDevice); background = new ParallaxBackground(GraphicsDevice); title = Content.Load <Texture2D>("Images/Title"); lose = Content.Load <Texture2D>("Images/Lose"); how = Content.Load <Texture2D>("Images/How"); menuSong = Content.Load <SoundEffect>("Sounds/MainMusic"); menuBackSong = menuSong.CreateInstance(); menuBackSong.IsLooped = true; inGameSong = Content.Load <SoundEffect>("Sounds/InGameMusic"); inGameBackSong = inGameSong.CreateInstance(); inGameBackSong.IsLooped = true; startSound = Content.Load <SoundEffect>("Sounds/Start"); background.AddLayer(Content.Load <Texture2D>("Images/Background"), 0, -100); background.AddLayer(Content.Load <Texture2D>("Images/AsteroidBack"), 1, -100); background.StartMoving(); verdana = Content.Load <SpriteFont>("Fonts/Verdana"); metalTex = Content.Load <Texture2D>("Images/metal"); for (int i = 0; i < beginning.Length; i++) { beginning[i] = new Sprite(metalTex, new Vector2(i * metalTex.Width * 0.05f + 50, 400), new Vector2(5, 0), false, 0.0f, 0.05f, SpriteEffects.None, null); } SpawnPlatforms(); } catch (ContentLoadException e) { System.Windows.Forms.MessageBox.Show(e.Message + " Please contact the programmers.", e.GetType().ToString()); Exit(); } }
private void Awake() { MM = FindObjectOfType <MonsterManager>(); M = FindObjectOfType <Monster>(); SUI.StatusShown = false; SUI.tempHP = SUI.tempSTR = SUI.tempSPD = SUI.pointUsedTotal = SUI.pointUsedHP = SUI.pointUsedSTR = SUI.pointUsedSPD = 0; AS = FindObjectOfType <AudioScript>(); if (Application.loadedLevelName == "OpeningMenu") { IntroAlreadyHappen = PlayerPrefs.GetInt("Intro", 0); PlayOP(); } else if (Application.loadedLevelName == "GameScreen") { PlayGS(); } if (Application.loadedLevelName == "GameScreen") { tempPoint = ExpManager.instance.POINT; if (!PlayerPrefs.HasKey("isChosen")) { mainCanvas.SetActive(false); PreGame.SetActive(true); } else { PreGame.SetActive(false); } } if (Application.loadedLevelName == "StepCounter") { pb = FindObjectOfType <ParallaxBackground>(); sc = FindObjectOfType <StepCounter>(); } }
public override void OnLoad() { Update += OnUpdate; Paint += OnPaint; MouseDown += OnMouseDown; Unloaded += OnUnloaded; LayoutRecords = new LayoutRecord(HipsterEngine); LayoutTop = new LayoutTop(HipsterEngine); PlanetStart = new PlanetStart(HipsterEngine, Width / 2, Height / 4, Height / 8); PlanetStart.AngularVelocity = 0.04f; HipsterEngine.Particles.AddParticleSystem(new ParticlesControllerFire(HipsterEngine)); var triangleRadius = PlanetStart.Radius / 4; var y = PlanetStart.Transform.Y - PlanetStart.Radius - triangleRadius + 2; Triangle = new Triangle(HipsterEngine, Width / 2, y, triangleRadius); Triangle.SetPlanet(PlanetStart); HipsterEngine.Particles.AddParticleSystem(new TriangleParticlesController(HipsterEngine, Triangle)); HipsterEngine.Surface.Canvas.Camera.X = -Width / 2; HipsterEngine.Surface.Canvas.Camera.Y = Height / 2; HipsterEngine.Surface.Canvas.Camera.SetTarget(PlanetStart.Transform.X - Width / 2, PlanetStart.Transform.Y + Height / 4); var profile = LoadProfile(); Map = new MapPlanets(HipsterEngine, Triangle); Map.Generate(profile.Level); Map.EndGame += TriangleOnEndGame; AnimationEndGame = new AnimationFloat(); AnimationEndGame.Timer.Complated += tick => { HipsterEngine.Screens.SetScreen(new MenuScreen()); }; LayoutRecords.TextRecord = profile.Balls.ToString(); PlanetStart.Text = profile.Level.ToString(); Background = new ParallaxBackground(HipsterEngine, Triangle); }
void OnEnable() { pbs = targets; foreach (object o in pbs) { ParallaxBackground pb = (ParallaxBackground)o; if (pb.cam == null) { pb.startPosition = pb.transform.position; pb.distance = pb.transform.position.z; pb.cam = Camera.main; } if (pb.GetComponent <Renderer>() != null) { EditorUtility.SetSelectedWireframeHidden(pb.GetComponent <Renderer>(), true); } } EditorApplication.update -= CallbackFunction; EditorApplication.update += CallbackFunction; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here _world = new World(new Vector2(0, 9.81f)); _graphics.PreferredBackBufferWidth = 600; _graphics.PreferredBackBufferHeight = 480; ConvertUnits.SetDisplayUnitToSimUnitRatio(_graphics.PreferredBackBufferHeight); _graphics.ApplyChanges(); _width = GraphicsDevice.Viewport.Width * 2; _height = GraphicsDevice.Viewport.Height; _spriteBatch = new SpriteBatch(GraphicsDevice); _camera = new Camera(GraphicsDevice.Viewport) { Position = new Vector2(0, 0), Limits = new Rectangle(0, 0, _width, _height) }; _background = new ParallaxBackground(_world, _camera, _spriteBatch); base.Initialize(); }
/// <summary> Creates Parallax Background </summary> private void CreateParallaxBG() { // Background layers List <Texture2D> lst = new List <Texture2D>(); lst.Add(ScreenManager.Content.Load <Texture2D>("Backgrounds/dusky sky endless loop")); _background = new ParallaxBackground(lst, ParallaxDirection.Horizontal) { Height = ScreenManager.GraphicsDevice.Viewport.Height, Width = ScreenManager.GraphicsDevice.Viewport.Width, //Position = Vector2.Zero, //this._backgroundPosition }; // Cloud Layer lst = new List <Texture2D>(); lst.Add(ScreenManager.Content.Load <Texture2D>("Backgrounds/clouds_small")); _clouds = new ParallaxBackground(lst, ParallaxDirection.Horizontal) { Height = ScreenManager.GraphicsDevice.Viewport.Height, Width = ScreenManager.GraphicsDevice.Viewport.Width //Position = Vector2.Zero }; } // CreateParallaxBG()
TileInfo CloneLayer(int newIndex, TileInfo layerToClone, bool fromEditor) { // GameObject result = (GameObject)Instantiate( layerToClone.gameObject ); // if( fromEditor ) // DestroyImmediate( result.GetComponent<PolygonCollider2D>() ); // else // Destroy( result.GetComponent<PolygonCollider2D>() ); GameObject result = new GameObject(layerToClone.name + "_" + newIndex); // result.hideFlags = HideFlags.HideInHierarchy; result.AddComponent <MeshFilter>().sharedMesh = new Mesh(); result.AddComponent <MeshRenderer>().material = layerToClone.GetComponent <MeshRenderer>().sharedMaterial; TileInfo ti = result.AddComponent <TileInfo>(); ti.collisions = (TileInfo.CollisionType[])wallLayer.collisions.Clone(); ti.tileSize = wallLayer.tileSize; ti.spacing = wallLayer.spacing; //result.GetComponent<TileInfo>().positionAtLastEdit = pos; ti.mapWidth = chunkWidth; ti.mapHeight = chunkHeight; ti.tiles = new Tile[chunkWidth * chunkHeight]; ti.autoTileData = new List <Tile>(wallLayer.autoTileData); ti.autoTileEdgeMode = new List <TileInfo.AutoTileEdgeMode>(wallLayer.autoTileEdgeMode); ti.autoTileLinkMask = new List <int>(wallLayer.autoTileLinkMask); ti.autoTileNames = new List <string>(wallLayer.autoTileNames); ti.autoTileType = new List <TileInfo.AutoTileType>(wallLayer.autoTileType); ti.numberOfAutotiles = wallLayer.numberOfAutotiles; ti.showAutoTile = new List <bool>(wallLayer.showAutoTile); ti.pixelColliders = layerToClone.pixelColliders; for (int i = 0; i < ti.tiles.Length; i++) { ti.tiles[i] = Tile.empty; } if (layerToClone.GetComponent <MeshCollider>() != null) { result.AddComponent <MeshCollider>().sharedMesh = new Mesh(); } RandomPlatformer rp = CopyComponent <RandomPlatformer>(layerToClone.GetComponent <RandomPlatformer>(), result); if (layerToClone.GetComponent <TilePrefabs>() != null) { CopyComponent <TilePrefabs>(layerToClone.GetComponent <TilePrefabs>(), result); } rp.mainLayer = mainLayer; rp.wallLayer = ti; rp._backgroundLayers = null; rp._wallLayers = null; rp.randomAtGameStart = false; Vector3 newPos = mainLayer.transform.position; if (newIndex >= 0) { int x = newIndex % width; int y = newIndex / width; newPos.x += chunkWidth * x; newPos.y += chunkHeight * y; ti.update3DWalls = layerToClone.update3DWalls; } else { //else is a background layer newPos = layerToClone.transform.position; newPos.z += backgroundZOffset; result.transform.parent = layerToClone.transform; ti.update3DWalls = layerToClone.update3DWalls; if (parallaxDistance != 0) { ParallaxBackground pb = result.AddComponent <ParallaxBackground>(); pb.distance = parallaxDistance; pb.cam = Camera.main; Vector2 midPoint = new Vector2((width * chunkWidth) / 2 - chunkWidth / 2, (height * chunkHeight) / 2 - chunkHeight / 2) + (Vector2)mainLayer.transform.position; float ratio = parallaxDistance / 10; pb.startPosition = new Vector3(newPos.x + ratio * (newPos.x - midPoint.x), newPos.y + ratio * (newPos.y - midPoint.y), parallaxDistance); if (FindObjectOfType <PixelPerfectCamera>() != null) { pb.pixelSnap = true; } } } result.transform.position = newPos; MeshCollider mc = result.GetComponent <MeshCollider>(); if (mc != null) { mc.sharedMesh = result.GetComponent <MeshFilter>().sharedMesh; } return(ti); }
public void setBackground(ParallaxBackground b) { background = b; }
public void SetUp() { parallaxBackground = new ParallaxBackground(4, layerImageNames, layerScrollFactors); }
public override void LoadContent() { _cursor_Texture = ParallaxBackground.GetFromPng("Content\\Textures\\flappy_cursor"); base.LoadContent(); }
public override void LoadContent() { Statics.TEXTURE_PIXEL = ParallaxBackground.GetFromPng("Content\\Textures\\flappy_pixel"); base.LoadContent(); }
public void SetUp() { parallaxBackground = new ParallaxBackground(4, layerImageNames, layerScrollFactors); }
void Awake() { levelScript = GameObject.FindGameObjectWithTag("Level").GetComponent <Level> (); backgroundScript = GameObject.Find("Background").GetComponent <ParallaxBackground> (); heart = gameObject.transform.Find("Heart").gameObject; }
private void Start() { myCamera = Camera.GetComponent <ParallaxBackground>(); }
private void CreateNewCloud(GameObject[] clouds, Transform spawnOrigin, Transform parent, ParallaxBackground parallaxBackground) { float heightOffset = Random.Range(0 - cloudHeightOffset, cloudHeightOffset); int index = Random.Range(0, clouds.Length); GameObject cloudToSpawn = Instantiate(clouds[index], desiredSpawnPosition(spawnOrigin, heightOffset), Quaternion.identity); cloudToSpawn.transform.parent = parent; parallaxBackground.backgroundLayers.Add(cloudToSpawn.transform); }