static int RegisterLevel(ILevel l, int lvs) { gen.current_lv++; gen.current_lv = (lvs != Int32.MinValue) ? lvs : gen.current_lv; gen.lv.Add(gen.current_lv, l); return gen.current_lv; }
public LevelView(ILevel level, ISpriteBatch spriteBatch, ITexture texture, ICamera camera) { _level = level; _spriteBatch = spriteBatch; _texture = texture; _camera = camera; }
//Constructor public Level(PyramidPanic game, int levelIndex) { this.game = game; this.levelIndex = levelIndex; /* System.IO.Stream stream = TitleContainer.OpenStream(@"Content\PlaySceneAssets\Levels\0.txt"); System.IO.StreamReader sreader = new System.IO.StreamReader(stream); // use StreamReader.ReadLine or other methods to read the file data Console.WriteLine("File Size: " + stream.Length); stream.Close(); */ this.levelPath = @"Content\PlaySceneAssets\Levels\" + levelIndex + ".txt"; this.stream = TitleContainer.OpenStream(this.levelPath); //this.levelPath = @"Content\PlaySceneAssets\Levels\0.txt"; //this.levelPath = @"Content\PlaySceneAssets\Levels\" + levelIndex + ".txt"; //eeee //IAsyncResult result = StorageDevice.BeginShowSelector( // PlayerIndex.One, null, null); //StorageDevice device = StorageDevice.EndShowSelector(result); //device.BeginOpenContainer. //eeeee this.LoadAssets(); ExplorerManager.Explorer = this.explorer; this.levelPause = new LevelPause(this); this.levelPlay = new LevelPlay(this); this.levelDoorOpen = new LevelDoorOpen(this); this.levelGameOver = new LevelGameOver(this); this.levelNextLevel = new LevelNextLevel(this); this.levelState = this.levelPlay; this.stream.Close(); }
public Player(Jump game, ILevel level, Rectangle rect) : base(game) { this.game = game; this.rect = rect; this.level = level; this.game.KeyboardEvent += KeyboardUpdate; }
public Enemy(Vector2 position, ISpawnLocation spawnLocation, string type, int maxHealth, int currentHealth, int speed, int hitCooldown, ILevel level) : base(position, type, maxHealth, currentHealth, speed, hitCooldown, level) { this.CanCollide = true; this.EquippedWeapon = new Unarmed(this.Position); this.SpawnLocation = spawnLocation; this.IsAggroed = false; }
protected virtual void SetupWithLevelObject(GameObject levelObject) { _level = levelObject; _levelInterfaceComponent = _level.GetRequiredComponent<ILevel>(); foreach (int playerIndex in Toolbox.GetInstance<IControllerPlayerInputManager>().AllPlayerIndexesWithDevices()) { GameObject player = _levelInterfaceComponent.SpawnPlayerFromTemplate(playerIndex, _playerTemplatePrefab); Toolbox.GetInstance<PlayerManager>().SetPlayer(playerIndex, player); } }
public Block(Jump game, ILevel level, Rectangle blockRect, Color color, int ySpeed) : base(game) { this.game = game; this.rect = blockRect; this.color = color; this.ySpeed = ySpeed == 0 ? 0 : (1000 / ySpeed); this.level = level; }
public static void Use(ILevel metadata) { string format = "Content/Map/level_{0}/map.csv"; string path = string.Format(format, metadata.Level); instance = new TileMatrix(path, metadata.Start) { Metadata = metadata }; }
protected BaseGameEngine(IMessageBus bus, IGraphicsEngine graphics, ILevel level, ITimer timer, IGameObjectFactory gameObjectFactory) { _graphics = graphics; _timer = timer; _gameObjectFactory = gameObjectFactory; Bus = bus; Level = level; _timer.Ticks.Subscribe(Update); }
public bool Remembers(ILevel level, Coordinate coordinate) { if (!this.tileMemory.ContainsKey(level)) { return false; } return this.tileMemory[level][coordinate.X, coordinate.Y] != null; }
/* Constructors */ public GraphicsObject(ILevel component_owner, PhysicalObject parent) : base(component_owner, 0.0f) { mParent = parent; mColour = Color.White; mRenderColour = Color.White; mScale = Vector2.One; mBlendState = BlendState.AlphaBlend; mSamplerState = SamplerState.AnisotropicClamp; }
protected Character(Vector2 position,string type, int maxHealth, int currentHealth, float speed, int hitCooldown, ILevel level) : base(position, type) { this.MaxHealth = maxHealth; this.CurrentHealth = currentHealth; this.Speed = speed; this.Level = level; this.CooldownTimer = hitCooldown; this.TimeAtLastHit = 0; }
public void SetUp() { stubLevel = MockRepository.GenerateStub<ILevel>(); stubPlayer = MockRepository.GenerateStub<IPlayer>(); stubPrimitiveDrawer = MockRepository.GenerateStub<IPrimitiveDrawer>(); visibilityView = new VisibilityView(stubLevel, stubPlayer, stubPrimitiveDrawer); List<LevelPiece> pieces = new List<LevelPiece>(); stubLevel.Stub(me => me.Pieces).Return(pieces); }
// Constructors public Animation(ILevel component_owner, PhysicalObject parent, string texture_name, float animation_timer) : base(component_owner, parent, texture_name) { // Retrieve the animation bounds Rectangle frame = Rectangle.Empty; component_owner.Game.Content.GetTexture(texture_name, out mAnimationBounds, out frame); Source = frame; // Setup the animation alarm mFrameAlarmMax = animation_timer; }
protected Player(string type, int maxHealth, int currentHealth, int speed, int hitCooldown, ILevel level) : base(DefaultStart, type, maxHealth, currentHealth, speed, hitCooldown, level) { // TODO: Implement weapon pickup and display it on the character. this.KillCount = 0; this.Inventory = new IPickable[InventoryCapacity]; this.EquippedWeapon = new Unarmed(this.Position); }
protected override void Initialize() { // Block block = new Block(this, new Rectangle(100, 500, 800, 200), Color.Blue, 20); // player = new Player(this, new Rectangle(512, 384, 32, 32)); // this.Components.Add(player); // this.Components.Add(block); // this.blocks.Add(block); this.level = new LevelM(this); this.lastLevel = this.level; this.level.Init(); base.Initialize(); }
public static void DrawLevel(SpriteBatch spriteBatch, ILevel level) { spriteBatch.Begin(); level.Assets.ForEach( asset => { // Make sure Items are always top layer. if (asset is IPickable) { spriteBatch.Draw( GetTexture(asset), asset.Position, null, null, null, 0, null, null, SpriteEffects.None, 0.1f); // Layer 0.1 since everything else is 0 } else { spriteBatch.Draw(GetTexture(asset), asset.Position); } }); spriteBatch.End(); DrawExistingEffects(spriteBatch); UpdateUniqueSprites(level.Enemies); foreach (var ememy in level.Enemies) { GetSprite(ememy).Draw(spriteBatch, ememy.Position); } GetSprite(level.Player).Draw( spriteBatch, level.Player.Position, level.Player.FacingAngle, level.Player.MovementAngle, GetTexture(level.Player.EquippedWeapon)); foreach (var projectile in level.Projectiles.ToList()) { GetSprite(projectile).Draw(spriteBatch, projectile.Position, projectile.Angle); if (projectile.Lifetime > projectile.Range) { level.Projectiles.Remove(projectile); } } }
protected static string message(ILevel level, string expected) { string msg = String.Format("Incorrect arguments. Expected `{0}`", expected); if(level.Type != LevelType.Method || level.Args == null) { return msg; } return String.Format("{0} -> Actual: ({1})", msg, String.Join(", ", level.Args.Select(a => a.type.ToString()))); }
public Layer_Grid(ILevel M2MLevel) { this.unitNumInWidth = M2MLevel.GetUnitNumInWidth(); this.unitNumInHeight = M2MLevel.GetUnitNumInHeight(); this.gridHeight = M2MLevel.GetGridHeight(); this.gridWidth = M2MLevel.GetGridWidth(); this.upperLeftX = M2MLevel.ConvertPartSequenceXToRealValue(0); this.upperLeftY = M2MLevel.ConvertPartSequenceYToRealValue(0); maxRect = GetMaxRect(); MainColor = Color.FromArgb(192, 192, 192); }
/// <summary> /// Clear all rendered and stored level data that we have. /// </summary> public void clearAll() { level = null; isLoaded = false; chunkControllerActivationQueue = null; foreach (UnityChunkController chunkController in chunkControllerPool) { if (chunkController != null) { Destroy(chunkController.gameObject); } } }
public InWorldInputPrompt(ILevel level, Camera camera, Font font, string str, TextAlignment alignment) : base(font, str, alignment) { m_level = level; m_camera = camera; m_position3D = Vector3.Zero; m_downArrow = new Image(Texture.Get("gui/arrows.png", true), new Quad(0.5f, 0.5f, 0.5f, 0.5f), ARROW_SIZE, ARROW_SIZE); m_downArrow.Colour = UIColours.White; m_usePosition3D = true; m_position3D = Vector3.Zero; m_position2D = Vector2.Zero; m_position2DAnchor = Anchor.TopLeft; }
protected static string message(ILevel level, string expected) { string msg = String.Format("Incorrect arguments. Expected `{0}`", expected); if (level.Type != LevelType.Method || level.Args == null) { return(msg); } return(String.Format("{0} -> Actual: ({1})", msg, String.Join(", ", level.Args.Select(a => a.type.ToString())))); }
public void SaveLevelAs(ILevel level) { var sav = new SaveFileDialog() { Filter = LevelFormatFilter, FileName = level.FilePath }; if (sav.ShowDialog() != DialogResult.OK) { return; } File.WriteAllBytes(sav.FileName, ((Level)level).SaveSzs(sav.FileName)); }
///// PUBLIC FUNCTIONS /// <summary> /// Initilize this chunk controller for it's provided level. /// </summary> public void initializeFor(ILevel level) { if (chunkObjectPrefab == null) { World.Debugger.logError("UnityLevelController Missing chunk prefab, can't work"); } else if (level == null) { World.Debugger.logError("No level provided to level controller"); } else { /// init this.level = level; chunksWaitingForAFreeController = new ConcurrentBag <IVoxelChunk>(); chunkControllerAssignmentWaitQueue = new List <IVoxelChunk>(); chunksWithNewlyGeneratedMeshes = new ConcurrentBag <ChunkController>(); chunksToMesh = new List <ChunkController>(); newlyActivatedChunks = new ConcurrentBag <Coordinate>(); chunksToActivate = new List <Coordinate>(); chunksWithOutOfFocusMeshes = new ConcurrentBag <ChunkController>(); chunksToDeMesh = new List <ChunkController>(); newlyDeactivatedChunks = new ConcurrentBag <Coordinate>(); chunksToDeactivate = new List <Coordinate>(); // build the controller pool based on the maxed meshed chunk area we should ever have: IChunkResolutionAperture meshResolutionAperture = level.getApetureForResolutionLayer(Level.FocusResolutionLayers.Meshed); chunkControllerPool = new ChunkController[meshResolutionAperture.managedChunkRadius * meshResolutionAperture.managedChunkRadius * level.chunkBounds.y * 2]; for (int index = 0; index < chunkControllerPool.Length; index++) { // for each chunk we want to be able to render at once, create a new pooled gameobject for it with the prefab that has a unitu chunk controller on it GameObject chunkObject = Instantiate(chunkObjectPrefab); chunkObject.transform.parent = gameObject.transform; ChunkController chunkController = chunkObject.GetComponent <ChunkController>(); if (chunkController == null) { //@TODO: make a queue for these maybe, just in case? World.Debugger.logError($"No chunk controller on {chunkObject.name}"); } else { chunkControllerPool[index] = chunkController; chunkController.levelController = this; chunkObject.SetActive(false); } } /// this controller is now loaded isLoaded = true; } }
public IState UpdateState(GameTime gameTime, Camera camera, ref GameSettings gameSettings, KeyboardState currentKey, KeyboardState prevKey, MouseState currentMouse, MouseState prevMouse) { if (this._currentSubMenu == null) { camera.ResetCamera(); if (currentKey.IsKeyDown(Keys.Up) && prevKey.IsKeyUp(Keys.Up)) { _selectedOption -= 1; this.HandleOptionChange(-1); } if (currentKey.IsKeyDown(Keys.Down) && prevKey.IsKeyUp(Keys.Down)) { _selectedOption += 1; this.HandleOptionChange(1); } if (currentKey.IsKeyDown(Keys.Enter) && prevKey.IsKeyUp(Keys.Enter)) { switch (_selectedOption) { case (int)Options.NEW_GAME: TestLevel level = new TestLevel(); return(new PlayingState(_content, camera, level, this)); case (int)Options.LOAD_GAME: break; case (int)Options.GAME_SETTINGS: this._currentSubMenu = new GameSettingsLevel(ref gameSettings); this._currentSubMenu.LoadLevel(this._content, camera); break; case (int)Options.QUIT: return(null); } } } else { ILevel previousSubMenu = _currentSubMenu; this._currentSubMenu = this._currentSubMenu.Update(gameTime, camera, ref gameSettings, currentKey, prevKey, currentMouse, prevMouse); if (this._currentSubMenu != previousSubMenu && this._currentSubMenu != null) { this._currentSubMenu.LoadLevel(this._content, camera); } } return(this); }
//------------------------------------------------------------------------------- #region Constructor //------------------------------------------------------------------------------- public WeaponAbilityInputCheckBox() { InitializeComponent(); int count = 0; int defHeight = pnlDisp.Height; Action <IAbility> addCombobox = ab => { int x = (count % 2 == 0) ? POINT_X_LEFT : POINT_X_RIGHT; int y = POINT_Y_FIRST + MARGIN_Y * (count / 2); var chb = new CheckBox() { Location = new Point(x, y), Text = ab.ToString(), Tag = ab, AutoSize = true }; pnlDisp.Controls.Add(chb); _checkboxes.Add(chb); }; foreach (var ability in Data.ALL_ABILITIES) { if (ability is ILevel) { ILevel ab_lv = ability as ILevel; foreach (var level in ab_lv.AllLevels()) { addCombobox(ab_lv.GetInstanceOfLv(level)); count++; } if (count % 2 != 0) { count++; } } else { addCombobox(ability); count++; } } vscrPanel.Maximum = pnlDisp.Height - defHeight; vscrPanel.LargeChange = defHeight - 11; vscrPanel.SmallChange = 11; }
// Start is called before the first frame update void Start() { //Setup GameData Singleton currentLevel = GameData.Instance.getCurrLvlData(); //Grab the map template from the Game Data this.mapTemplate = currentLevel.getMapTemplate(); //Make all the empty GameObjects for the tiles this.field = new GameObject[this.mapTemplate.GetLength(1), this.mapTemplate.GetLength(0)]; this.buildDictionary(); this.createMapObjects(); }
// Start is called before the first frame update void Start() { rocketName = PlayerPrefs.GetString("Selected"); prefabRocket = StaticPrefabs.rocketDictionary[rocketName]; //prefabRocket = Resources.Load($"Prefabs/{PlayerPrefs.GetString("Selected")}") as GameObject; rocket = Instantiate(prefabRocket, new Vector3(0, 0, 0), Quaternion.Euler(0, 0, 0)); // settings SetRocketSettings(); camera.GetComponent <CameraMoving>().rocket = rocket; level = null; rocket.GetComponent <RocketFly>().ChangeLevelEvent += NextLevelPlay; }
public bool CanPlaceOnSide(ILevel level, TileCoordinates coordinates, Direction direction) { var baseCoords = GetBase(level, coordinates); var baseTile = level.Tiles[baseCoords]; if (direction == Direction.Up && coordinates.Y != (baseCoords.Y + baseTile.Height - 1)) { return(false); // No placing inside blocks } else { return(baseTile.Behaviour.CanPlaceOnSide(level, baseCoords, direction)); } }
public Scene(ILevel level) { //Level = level; World = new World("new world", 20); Player = new Player(0, 0, 1); Animals = new List <IAnimals> { new Cow(20, 20), new Cow(40, 20), new Cow(20, 40), new Cow(50, 30), new Cow(-20, -20) }; }
/// <summary> /// Get all level files in the specified directory /// </summary> /// <returns> Dictionary of Levels </returns> private IDictionary <string, ILevel> GetLevels() { IDictionary <string, ILevel> _lvls = new Dictionary <string, ILevel>(); for (int i = 0; i < mLvlCount; i++) { int lvlid = i + 1; string LeveltoOpen = mLvlPath + lvlid; Type t = Type.GetType(LeveltoOpen, true); ILevel lvl = Activator.CreateInstance(t) as ILevel; _lvls.Add(lvl.LvlID, lvl); } return(_lvls); }
private void SetEntity(ILevel level, TileCoordinates coordinates, Entity entity) { var state = level.Tiles.GetState(coordinates); if (state.Entity != null) { level.Entities.Remove(state.Entity); } state.Entity = entity; if (state.Entity != null) { level.Entities.Add(state.Entity); } }
public override void OnRender(ILevel level, TileCoordinates coordinates, Geometry output, TextureAtlas textures) { if (level.InEditor) { // Draw adjoining faces only int facesDrawn = Render(level, coordinates, output, textures, false); // If tile is in isolation, draw all tiles if (facesDrawn == 0) { Render(level, coordinates, output, textures, true); } } }
public GameManager(List <IAGameObject> playerWeaponList, List <IAGameObject> enemyWeaponList, GameData gameData, GameEngine gameEngine, MunitionsFactory munitionsFactory, RenderPage renderer, ILevel level, Player player) { _level = level; _playerWeaponList = playerWeaponList; _enemyWeaponList = enemyWeaponList; _gameData = gameData; _gameEngine = gameEngine; _renderer = renderer; _munitionsFactory = munitionsFactory; _aiManager = new AiManager(_gameData, enemyWeaponList, _munitionsFactory); _player = player; _collisionDetector = new CollisionDetector(); _levelState = LevelState.Active; }
/// <summary> /// Exports the specified level to the specified file. If the file /// already exists, it will be deleted and a new file will be created. /// </summary> public void ExportLevel(ILevel level) { LevelWriter.WriteLine(string.Format("width={0}", level.Width)); LevelWriter.WriteLine(string.Format("height={0}", level.Height)); LevelWriter.WriteLine(string.Format("start={0},{1}", level.Start.X, level.Start.Y)); LevelWriter.WriteLine(string.Format("finish={0},{1}", level.Finish.X, level.Finish.Y)); foreach (KeyValuePair<Point, GridObject> pair in level.GridObjects) { LevelWriter.WriteLine(TileToString(pair.Key, pair.Value)); } LevelWriter.Close(); }
private void CreateLevel(object levelParams) { _levelCreator.CreateLevel(levelParams, (level) => { CurrentLevel = level; OnAfterLevelCreated.SafeInvoke(level); _levelStarter.StartLevel(CurrentLevel, () => { OnAfterLevelStarted.SafeInvoke(level); }); }); }
public void AddLevel(ILevel level) { int levelGroup = FindPlaceForLevel(level); // Добавление уровня в сетку if (groups.Count <= levelGroup) { groups.Add(levelGroup, new Dictionary <int, ILevel> ()); } groups[levelGroup].Add(groups[levelGroup].Count, level); LevelsCount++; // Перестроение потомков уровня MoveChildren(level, levelGroup); }
protected string dataClone(ILevel level, IPM pm) { if (level.Is(ArgumentType.StringDouble, ArgumentType.Integer)) { return(dataClone(pm.pinTo(1), (string)level.Args[0].data, (int)level.Args[1].data)); } if (level.Is(ArgumentType.StringDouble, ArgumentType.Integer, ArgumentType.Boolean)) { return(dataClone(pm.pinTo(1), (string)level.Args[0].data, (int)level.Args[1].data, (bool)level.Args[2].data)); } throw new ArgumentPMException(level, "data.clone(string name, integer count [, boolean forceEval])"); }
public static void Update(ILevel level, Game1 game) { int marioCheck = 0; int itemCheck = 0; Rectangle marioRect = game.MarioSprite.Area(); IMario mario = game.MarioSprite; MarioDetection(level, marioRect); BlockDetection(level, game, marioRect, marioCheck); EnemyDetection(level, game, marioRect); ItemDetection(level, itemCheck); FireballDetection(level); }
public void ChangeSet(int set) { level = new Level("Set_" + set); // Changing required Logic as per set changes var NumberOfObjects = GameObject.FindGameObjectsWithTag("RandMonster"); foreach (GameObject GO in NumberOfObjects) { Destroy(GO); } if (level.SceneName == "Set_7") { Application.Quit(); // Ending the game } }
//constructor public Level(PyramidPanic game, int levelIndex) { this.game = game; this.levelindex = levelindex; this.levelPath = @"Content\PlayScene\Levels\"+ levelIndex +".txt"; this.LoadAssets(); Playermanager.Player = this.Player; this.levelPause = new LevelPause(this); this.levelPlay = new LevelPlay(this); this.levelDoorOpen = new LevelDoorOpen(this); this.levelGameOver = new LevelGameOver(this); this.levelNextLevel = new LevelNextLevel(this); this.levelEndGame = new LevelEndGame(this); this.levelState = this.levelPlay; }
private void OnGetQueryPart(ILevel level, int levelSequence, IPart part) { lock (layers) { PositionSetEdit_ImplementByICollectionTemplate partSet = new PositionSetEdit_ImplementByICollectionTemplate(); partSet.AddPosition(part); Layer_M2MPartSetInSpecificLevel layer = new Layer_M2MPartSetInSpecificLevel(level, partSet); layer.MainColor = Color.FromArgb(255, 0, 0); layer.Active = true; layers.Add(layer); } flowControlerForm.BeginInvoke(Update); flowControlerForm.SuspendAndRecordWorkerThread(); }
public void SetUp() { ILevel level = Substitute.For <ILevel>(); ILerp lerp = Substitute.For <ILerp>(); ILerp hoistLerp = Substitute.For <ILerp>(); IAnimator animator = Substitute.For <IAnimator>(); GameObject player = getPlayer(); tc = player.GetComponent <ThunderboltCharacter>(); tc.Awake(); tc.level = level; tc.lerp = lerp; tc.hoistLerp = hoistLerp; tc.animator = animator; }
public void Start() { ConsoleSetup.SetupConsole(); int gameMode = this.ChooseGameMode(); for (int i = firstLevelIndex; i <= lastLevelIndex; i++) { ILevel currentLevel = LevelGenerator(i); this.GameStartPreparation(i); this.InitializeSnake(currentLevel); this.InitializeGamePoints(currentLevel); currentLevel.GenerateApple(currentLevel.Obstacles); this.ReadCommand(gameMode, currentLevel); } }
public static Point?FindPlayerPos(this ILevel level) { for (int x = 0; x < level.Width; ++x) { for (int y = 0; y < level.Height; ++y) { ElementType type = level.GetElement(x, y); if (ElementType.Man == type || ElementType.ManOnGoal == type) { return(new Point(x, y)); } } } return(null); }
public void Clear(ILevel level, TileCoordinates coordinates, bool notifyNeighbours = true) { if (IsExtension()) { var below = coordinates.Below(); level.Tiles[below].Clear(level, below, notifyNeighbours); } else { for (int i = 0; i < m_height; ++i) { level.Tiles.SetTile(coordinates.Move(Direction.Up, i), Tiles.Air, FlatDirection.North, notifyNeighbours); } } }
public bool TryParse(string input, IFormatProvider fp, NumberStyles style, out ILevel <T> result) { string number; string symbol; T value; Scale <T> scale = TryTokenize(input, Scales, out number, out symbol); if ((scale != null) && TryParseNumber(number, style, fp, out value)) { result = scale.Create(value); return(true); } result = null; return(false); }
/// <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 tileTextures = new ArrayList(); tileTextures.Insert(0, Content.Load<Texture2D>("blank")); level = new Level(this, "test.txt", tileTextures); int screenHeight = GraphicsDevice.Viewport.Height; Texture2D playerTexture = Content.Load<Texture2D>("Robro1.1"); player = new Player(playerTexture, 390, screenHeight - 52 - (screenHeight / 32)); base.Initialize(); }
//construction public Level(PyramidPanic game,int levelIndex) { this.game = game; this.levelPath = @"Content\PlaySceneAssets\Levels\"+PlayScene.LevelNumber+".txt"; this.loadAssets(); this.levelPlay = new LevelPlay(this); this.levelPause = new LevelPause(this); this.levelOpenDoor = new LevelOpenDoor(this); this.levelGameOver = new LevelGameOver(this); this.levelNextLevel = new LevelNextLevel(this); this.levelVictory = new LevelVictory(this); this.levelPaused = new LevelPaused(this); this.levelState = new LevelPlay(this); Score.Level = this; Score.initialize(); }
public TileCoordinates GetBase(ILevel level, TileCoordinates coordinates) { if (IsExtension()) { var below = coordinates.Below(); while (level.Tiles[below].IsExtension()) { below = below.Below(); } return(below); } else { return(coordinates); } }
public static void ProjectileReaction(Projectile projectile, ILevel level) { IEnumerable <IGameObject> collisionItems = level.Assets.Where(a => !(a is IPickable)).Concat(level.Enemies).ToList(); IGameObject collider = Collide(projectile, collisionItems); if (collider != null) { if (level.Player.EquippedWeapon is RangedWeapon) { level.Projectiles.Remove(projectile); } var enemy = collider as Enemy; enemy?.TakeDamage(projectile.Attacker); } }
/// <summary> /// Prepares signatures: /// check(file [, pwd]) /// </summary> /// <param name="level"></param> /// <param name="pm"></param> /// <returns></returns> protected string check(ILevel level, IPM pm) { // check(string file) if (level.Is(ArgumentType.StringDouble)) { return(stCheckMethod(pm, (string)level.Args[0].data)); } // check(string file, string pwd) if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { return(stCheckMethod(pm, (string)level.Args[0].data, (string)level.Args[1].data)); } throw new InvalidArgumentException("Incorrect arguments to `check(string file [, string pwd])`"); }
// Constructors public Parallax(ILevel component_owner, string texture_name, float depth, float speed, ScrollType scroll_type, Color colour) : base(component_owner, float.MaxValue) { // Copy some parameters mSpeed = speed; mDepth = depth; mScrollType = scroll_type; mColour = colour; // Load the texture mTexture = component_owner.Game.Content.GetTexture(texture_name, out mSource); mCentre = new Vector2(mSource.Width, mSource.Height) * 0.5f; // Calculate the scale mScale = new Vector2(component_owner.GraphicsDevice.Viewport.Width / (float)mSource.Width, component_owner.GraphicsDevice.Viewport.Height / (float)mSource.Height); }
// Constructors public Gravity(ILevel component_owner, Vector2 position, float power, float effective_range) : base(component_owner, 0.0f) { // Copy the defaults mPosition = position; mPower = power; // Generate the collision circle if (effective_range > 0.0f) { mEffectiveRange = new Circle(null, effective_range) { OnCollision = delegate(ICollisionObject me, ICollisionObject other) { ApplyGravity(other.Parent.Parent as PhysicalObject); } }; mEffectiveRange.AddCollideableType(typeof(PhysicalObject)); AddChild(mEffectiveRange); } }
private void NextLevel() { level = new Level(); level.MakePuzzle(PuzzleParams.GetPuzzleParamsByRank(rank++)); //level.MakePuzzle(new QuadValue[,] //{ // { QuadValue.Back, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front }, // { QuadValue.Back, QuadValue.Right | QuadValue.Down, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Down, QuadValue.Front }, // { QuadValue.Back, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front }, // { QuadValue.Back, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front }, // { QuadValue.Back, QuadValue.Right, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front }, // { QuadValue.Back, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front }, // { QuadValue.Back, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front, QuadValue.Front }, //}); level.puzzle.localPosition = new Vector3(0, 0, Style.PuzzleDepth); level.puzzle.AddEventListener(PuzzleEvent.SolveChange, SolveChangeHandler); GameObject puzzlego = new GameObject("Puzzle"); puzzleView = puzzlego.AddComponent<PuzzleView>(); puzzleView.data = level.puzzle; }
/// <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() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Services objectManager = new ObjectManager(this); collisionDetectionService = new CollisionDetectionService(this); _input = new InputManager(this); Services.AddService(typeof(ObjectManager), objectManager); Services.AddService(typeof(IManageCollisionsService), collisionDetectionService); Services.AddService(typeof(IInputService), _input); objectManager.SetSpritebatch(spriteBatch); levelManager = new LevelManager.LevelManager(); levelManager.Init(this, spriteBatch); curLevel = levelManager.NextLevel(); base.Initialize(); }
public void DrawScreen(ILevel level) { GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); GL.Ortho(0.0, level.Width, 0.0, level.Height, 0.0, 1.0); GL.MatrixMode(MatrixMode.Modelview); GL.Clear(ClearBufferMask.ColorBufferBit); GL.LoadIdentity(); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); spriteSheet.BeginUse(); GL.Color3(Color.White); for (int x = 0; x < level.Width; ++x) { for (int y = 0; y < level.Height; ++y) { spriteSheet.Draw((uint)level.GetElement(x, y), new Box2D(x, y, 1.0f, 1.0f)); } } spriteSheet.EndUse(); GL.Disable(EnableCap.Blend); }
public void LoadLevel(ILevel level) { throw new NotImplementedException(); }
/// <summary> /// Checks last level. /// </summary> /// <param name="level">Level for checking.</param> /// <returns>true value if selected is latest.</returns> protected bool isLastLevel(ILevel level) { switch(level.Type) { case LevelType.RightOperandColon: case LevelType.RightOperandStd: case LevelType.RightOperandEmpty: { return true; } } return false; }
public LevelController(ILevel level) { _level = level; }