public cPickupAble(cGameScene scene, cSpatialGrid grid, Vector2f pos, Vector2f emit_direction) : base(scene, pos) { this.grid = grid; this.pickedUp = pulling = false; this.heading = emit_direction; this.bounds = new cAABB(); this.bounds.SetDims(new Vector2f(16.0f, 22.0f)); this.bounds.SetPosByCenter(pos); this.HitCollisionRect = bounds; this.MaxSpeed = EMIT_SPEED * 2; this.mass = 100.0f; this.velocity.X = this.heading.X * EMIT_SPEED; this.velocity.Y = this.heading.Y * EMIT_SPEED; orientation = cAppMath.GetAngleOfVector(heading); this.sprite = new Sprite(cAssetManager.GetTexture("pickups")); pickup = PickupEffects.getWeighted(); //.get(PickupType.HEALTH); this.sprite.TextureRect = pickup.TextureRect; //this.sprite.Scale = new Vector2f(0.5f, 0.5f); //this.sprite.Rotation = (float)cAppMath.RadianToDegress(this.orientation); this.sprite.Origin = new Vector2f(12.0f, 12.0f); }
private void CleanUp() { cAnimationAssets.ClearAll(); gameWorld.ClearAll(); lightMap.RemoveAll(); this.entityPool.RemoveAll(); BulletBreed.Cleanup(); PickupEffects.Cleanup(); resourceAssets.ClearResources(); }
/// <summary> /// If pickup type is unknown (not specified), generate one by weights /// </summary> /// <param name="scene"></param> /// <param name="grid"></param> /// <param name="pos"></param> /// <param name="emit_direction"></param> public cPickupAble(GameScene scene, Vector2f pos, Vector2f emit_direction, PickupType type = PickupType.UNKNOWN) : base(scene, pos) { pickup = type == PickupType.UNKNOWN ? PickupEffects.getWeighted() : PickupEffects.get(type); this.init(pos, emit_direction); }
public override void Enter() { this.resourceAssets.LoadResources(Constants.FONT_NAMES, Constants.TEXTURES_NAMES, Constants.SOUND_NAMES); cAnimationAssets.LoadAnimations(this.resourceAssets); BulletBreed.Init(this.resourceAssets); PickupEffects.InitPickupEffects(this.resourceAssets); camera = new Camera(new View(new Vector2f(appControllerRef.WindowSize.X / 2.0f, appControllerRef.WindowSize.Y / 2.0f), appControllerRef.WindowSize)); camera.Zoom = 0.6f; // 0.6f; appControllerRef.MainWindow.SetView(camera.View); /* * Vector2f viewSize = new Vector2f(appController.MainWindow.Size.X, appController.MainWindow.Size.Y); * * m_View.Size = new Vector2f(viewSize.X, viewSize.Y); * m_View.Center = new Vector2f(viewSize.X / 2.0f, viewSize.Y / 2.0f); * m_View.Viewport = new FloatRect(0.0f, 0.0f, 1.0f, 1.0f); * m_View.Zoom(0.6f); //0.6f * * viewRect = new AABB(); * viewRect.SetDims(m_View.Size); */ worldEnvironment = new cEnvironment(); // Constants.LIGHTMAP_COLOR lightMap = new cLightSystem(Constants.LIGHTMAP_COLOR, this.resourceAssets); //((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y, Constants.LIGHTMAP_COLOR); gameWorld = new cWorld(this, appControllerRef.MainWindow.Size); gameWorld.InitLevel(); //lightMap.Create((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y); lightMap.Create(appControllerRef.MainWindow.Size.X, appControllerRef.MainWindow.Size.Y); lightMap.loadLightsFromTmxMap(gameWorld.CurrentLevel.GetTmxMap()); this.staticTexture = new RenderTexture((uint)gameWorld.WorldBounds.dims.X, (uint)gameWorld.WorldBounds.dims.Y); this.staticTexture.SetActive(true); this.staticTexture.Clear(new Color(0, 0, 0, 0)); //this.staticTexture.SetView(m_View); Vector2f playerStart = new Vector2f(gameWorld.LevelStartRegion.center.X, gameWorld.LevelStartRegion.rightBottom.Y); playerStart.X -= Constants.CHAR_FRAME_WIDTH / 2.0f; playerStart.Y -= Constants.CHAR_FRAME_HEIGHT; player = new cPlayer(this, playerStart); entityPool = new GameObjectGrid(this, gameWorld.WorldBounds.dims, player); entityPool.InitLevelEntites(World.CurrentLevel); //vizekhez adunk fényt /* * List<cWaterBlock> waterBlocks = m_World.GetWaterBlocks(); * * foreach (cWaterBlock wb in waterBlocks) * { * cLight waterLight = new cLight(); //víz blokkokhoz adunk fényt, mert jól néz ki * waterLight.Pos = new Vector2f(wb.Area.center.X, wb.Area.topLeft.Y+Constants.TILE_SIZE/2.0f); * waterLight.Radius = (wb.Area.dims.X + wb.Area.dims.Y) * 0.8f; * waterLight.Bleed = 0.00001f; // 0.00001f; * waterLight.LinearizeFactor = 0.95f; * waterLight.Color = new Color(41,174,232); // 96,156,164 * lightMap.AddStaticLight(waterLight); * } * * //háttér, környezeti tárgyak megjelenítése * worldEnvironment.SetWaterBlocks(waterBlocks); */ this.particleManager = new cParticleManager(this); this.effectSystem = new EffectSystem(); // lightMap.renderStaticLightsToTexture(); gameActions = new Queue <Action>(50); Listener.GlobalVolume = 80; Listener.Direction = new Vector3f(1.0f, 0.0f, 0.0f); ShakeScreen.Init(camera.ActualPosition); //Pálya idő start levelTimer.Start(); }