public Player SpawnPlayer(AbstractMarioPower pw = null) { Player p = new Player(pw); owner.AddEntity(p, position.X * Block.BLOCK_WIDTH, position.Y * Block.BLOCK_HEIGHT); return(p); }
public void StartChangeWorld(int target_world, int target_level, AbstractMarioPower power = null) { player.MakeStatic(); for (int i = 0; i < dynamicEntityList.Count; i++) { if (dynamicEntityList[i] != player) { dynamicEntityList[i].KillLater(); } } Explode(); AddDelayedAction( (int)(LEVEL_END_ANIMATION_DURATION + 30), (() => { player.Explode(); player.KillLater(); } )); AddDelayedAction( (int)(LEVEL_END_ANIMATION_DURATION + 120), (() => ChangeWorld(target_world, target_level, power))); }
public GameWorld ChangeWorld(int world, int level, AbstractMarioPower power, HUDModel hud) { GameWorld g; SetModel(g = new GameWorld(world, level)); g.Init(power, hud); return(g); }
public void ChangeWorld(int world, int level, AbstractMarioPower power = null) { Console.Out.WriteLine("Change World to {0}:{1}", world, level); if (power == null) { power = new StandardMarioPower(); } GameWorld neww = ownerView.ChangeWorld(world, level, power, HUD); }
public override void Init(AbstractMarioPower p, HUDModel hmod) { base.Init(p, hmod); if (hmod == null) { HUD = new StandardGameHUD(this); } else { HUD = hmod; } LoadMapFromResources(p); }
public Player(AbstractMarioPower pw = null) : base() { direction = Direction.RIGHT; distance = Entity.DISTANCE_PLAYER; width = PLAYER_WIDTH * PLAYER_SCALE; height = PLAYER_HEIGHT * PLAYER_SCALE; if (pw == null) { ChangePower(new StandardMarioPower()); } else { ChangePower(pw); } AddController(new DefaultPlayerController(this)); }
private void DoDeath(bool direct = false) { if (!isAlive) { return; } if ((invincTime == 0 || direct) && !Program.debugViewSwitch.Value) { AbstractMarioPower sub = power.GetSubPower(); if (sub == null || direct) { (owner as GameWorld).OnPlayerDeath(); } else { ChangePower(sub); invincTime = INVINCIBLE_TIME; } } }
public virtual void Init(AbstractMarioPower p, HUDModel hmod) { entityCache = new EntityCache(); HUD = hmod; }
public void ChangePower(AbstractMarioPower p) { power = p; UpdateHeight(); atexture = p.GetTexture(); }
public void AddTriggerFromMapData(AddTriggerType triggertype, Color c, int x, int y, AbstractMarioPower p) { double px = x * Block.BLOCK_WIDTH; double py = y * Block.BLOCK_HEIGHT; if (triggertype == AddTriggerType.PLAYER_SPAWN_POSITION || triggertype == AddTriggerType.PLAYER_INITIAL_SPAWN_POSITION) { PlayerSpawnZone zone = new PlayerSpawnZone(new Vec2i(x, y)); AddTrigger(zone, x, y); if (triggertype == AddTriggerType.PLAYER_INITIAL_SPAWN_POSITION) { (HUD as StandardGameHUD).Reset(); player = zone.SpawnPlayer(); } else { player = zone.SpawnPlayer(p); } } else if (triggertype == AddTriggerType.DEATH_ZONE) { AddTrigger(new DeathZone(new Vec2i(x, y)), x, y); } else if (triggertype == AddTriggerType.LEVEL_WRAP) { AddTrigger(new LevelWrapZone(new Vec2i(x, y), c.B), x, y); } else if (triggertype == AddTriggerType.BRIDGE_DESTROY) { AddTrigger(new BridgeDestroyZone(new Vec2i(x, y)), x, y); } else if (triggertype == AddTriggerType.BEANSTALK_SPAWN) { AddTrigger(new BeanStalkSpawnZone(new Vec2i(x, y)), x, y); } else if (triggertype == AddTriggerType.TELEPORT_ENTRY) { AddTrigger(new TeleportEntryZone(new Vec2i(x, y), c.R), x, y); } else if (triggertype == AddTriggerType.TELEPORT_EXIT) { AddTrigger(new TeleportExitZone(new Vec2i(x, y), c.R), x, y); } else if (triggertype == AddTriggerType.TEXTURE_CHANGE) { AddTrigger(new TextureChangeZone(new Vec2i(x, y), c.G), x, y); } else if (triggertype == AddTriggerType.SPAWN_LOGO) { AddTrigger(new SpawnLogoZone(new Vec2i(x, y)), x, y); } else if (triggertype == AddTriggerType.SWITCH_ZOOM) { AddTrigger(new SwitchZoomZone(new Vec2i(x, y)), x, y); } else if (triggertype == AddTriggerType.PLAYER_GROW) { AddTrigger(new GrowPlayerZone(new Vec2i(x, y)), x, y); } }
public void LoadMapFromResources(AbstractMarioPower p) { ImageMapParser parser = new ImageMapParser(new OpenRasterImage(ResourceAccessor.GetMap(mapWorld, mapLevel))); setSize(parser.GetWidth(), parser.GetHeight()); for (int x = 0; x < parser.GetWidth(); x++) { for (int y = 0; y < parser.GetHeight(); y++) { int imgX = x; int imgY = parser.GetHeight() - (1 + y); Color col_b = parser.map.GetColor(ImageMapParser.LAYER_BLOCKS, imgX, imgY); Color col_e = parser.map.GetColor(ImageMapParser.LAYER_ENTITIES, imgX, imgY); Color col_t = parser.map.GetColor(ImageMapParser.LAYER_TRIGGER, imgX, imgY); Color col_p = parser.map.GetColor(ImageMapParser.LAYER_PIPEZONES, imgX, imgY); Color col_v = parser.map.GetColor(ImageMapParser.LAYER_PLAYERVISION, imgX, imgY); Block block = parser.GetBlock(imgX, imgY); EntityTypeWrapper set = parser.GetEntity(imgX, imgY); AddTriggerType att = parser.GetTrigger(imgX, imgY); PipeZoneTypeWrapper pzt = parser.GetPipeZone(imgX, imgY); if (block == null) { throw new NotSupportedException(String.Format("Could not parse Block-Color in Map: {0} ({1}|{2})", col_b, x, y)); } else { AddBlock(block, x, y); } if (set == null) { } // No Entity else if (!set.IsSet()) { throw new NotSupportedException(String.Format("Could not parse SpawnEntity-Color in Map: {0} ({1}|{2})", col_e, x, y)); } else { SpawnEntityFromMapData(set, col_e, x, y); } if (att == AddTriggerType.UNKNOWN_TRIGGER) { throw new NotSupportedException(String.Format("Could not parse Trigger-Color in Map: {0} ({1}|{2})", col_t, x, y)); } else if (att != AddTriggerType.NO_TRIGGER) { AddTriggerFromMapData(att, col_t, x, y, p); } if (pzt == null) { } // No Zone else if (!pzt.IsSet()) { throw new NotSupportedException(String.Format("Could not parse PipeZone-Color in Map: {0} ({1}|{2})", col_p, x, y)); } else { AddPipeZoneFromMapData(pzt, x, y); } } } offset.AddVisionBoxes(parser.GetVisionZones()); //############# //AFTER MAP GEN //############# offset.Calculate(player.GetPosition(), viewPortWidth, viewPortHeight, mapRealWidth, mapRealHeight, false, false); foreach (DynamicEntity e in dynamicEntityList) { e.OnAfterMapGen(); } foreach (Trigger t in triggerList) { t.OnAfterMapGen(); } }