private EdgeState(Location location, Location location2, PuzzleColor color, PuzzleColor color2, bool isNot, bool isRotated) : base(location, isNot, isRotated) { this.Location2 = location2; this.Color = color; this.Color2 = color2; }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnInitialize() { this.color = Color; this.isRaised = (color == PuzzleColor.Blue); Dungeon dungeon = RoomControl.Dungeon; if (dungeon != null) this.isRaised = (dungeon.ColorSwitchColor == color); this.IsSolid = isRaised; // Set the sprite. if (isRaised) { if (color == PuzzleColor.Blue) Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_BLUE_RAISE); else Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_RED_RAISE); } else { if (color == PuzzleColor.Blue) Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_BLUE_LOWER); else Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_RED_LOWER); } Graphics.AnimationPlayer.SkipToEnd(); }
// 파티클 시간이 다하면 삭제(비활성화) public void RemoveParticle(string type, GameObject particle) { PuzzleColor color = (PuzzleColor)Enum.Parse(typeof(PuzzleColor), type); particle.transform.parent = transform; particles[color].ReturnObject(particle); particle.SetActive(false); }
// 필요한 곳에 파티클을 생성시킴(활성화) public void ShowParticle(PuzzleColor type, Transform parent) { GameObject particle = particles[type].GetObject(); particle.transform.parent = parent; particle.transform.localPosition = Vector3.zero; particle.SetActive(true); }
private void ButtonHandler(PuzzleColor color, bool state) { if (color != _puzzleColor) { return; } _buttonPressed = state; }
public Face(FaceName faceName, PuzzleColor color) : this( faceName, new PuzzleColor[Size, Size] { { color, color, color }, { color, color, color }, { color, color, color } }) { }
public Face Clone() { var colors = this.colors; var newColors = new PuzzleColor[Size, Size] { { colors[0, 0], colors[0, 1], colors[0, 2] }, { colors[1, 0], colors[1, 1], colors[1, 2] }, { colors[2, 0], colors[2, 1], colors[2, 2] } }; return(new Face(this.FaceName, newColors)); }
private void DrawFace(Face face, int faceX, int faceY, int transformX, int transformY) { var colors = new PuzzleColor[Face.Size, Face.Size]; for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { colors[x + 1, y + 1] = face[x * transformX, y *transformY]; } } this.DrawFace(faceX, faceY, colors); }
public override void SetSwitchState(bool switchState) { base.SetSwitchState(switchState); if (switchState) { color = PuzzleColor.Blue; Graphics.PlaySprite(GameData.SPR_TILE_COLOR_SWITCH_BLUE); } else { color = PuzzleColor.Red; Graphics.PlaySprite(GameData.SPR_TILE_COLOR_SWITCH_RED); } }
private CornerState( Location location, Location location2, Location location3, PuzzleColor color, PuzzleColor color2, PuzzleColor color3, bool isNot, bool isRotated) : base(location, isNot, isRotated) { this.Location2 = location2; this.Location3 = location3; this.Color = color; this.Color2 = color2; this.Color3 = color3; }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnInitialize() { // Set the sprite. PuzzleColor color = Color; if (color == PuzzleColor.Red) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_TILE_RED); } else if (color == PuzzleColor.Yellow) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_TILE_YELLOW); } else if (color == PuzzleColor.Blue) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_TILE_BLUE); } }
private static char GetColorCharacter(PuzzleColor color) { switch (color) { case PuzzleColor.Blue: return('B'); case PuzzleColor.Green: return('G'); case PuzzleColor.Orange: return('O'); case PuzzleColor.Red: return('R'); case PuzzleColor.White: return('W'); case PuzzleColor.Yellow: return('Y'); default: throw new InvalidOperationException(); } }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnInitialize() { PuzzleColor color = Color; if (color == PuzzleColor.Red) { flameAnimation = GameData.ANIM_EFFECT_COLOR_FLAME_RED; } else if (color == PuzzleColor.Blue) { flameAnimation = GameData.ANIM_EFFECT_COLOR_FLAME_BLUE; } else if (color == PuzzleColor.Yellow) { flameAnimation = GameData.ANIM_EFFECT_COLOR_FLAME_YELLOW; } else { flameAnimation = null; } }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnInitialize() { this.color = Color; this.isRaised = (color == PuzzleColor.Blue); Dungeon dungeon = RoomControl.Dungeon; if (dungeon != null) { this.isRaised = (dungeon.ColorSwitchColor == color); } this.IsSolid = isRaised; // Set the sprite. if (isRaised) { if (color == PuzzleColor.Blue) { Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_BLUE_RAISE); } else { Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_RED_RAISE); } } else { if (color == PuzzleColor.Blue) { Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_BLUE_LOWER); } else { Graphics.PlayAnimation(GameData.ANIM_TILE_COLOR_BARRIER_RED_LOWER); } } Graphics.AnimationPlayer.SkipToEnd(); }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnInitialize() { // Set the sprite. PuzzleColor color = (PuzzleColor)Properties.Get("color", (int)PuzzleColor.Red); if (color == PuzzleColor.Red) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_JUMP_PAD_RED); } else if (color == PuzzleColor.Yellow) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_JUMP_PAD_YELLOW); } else if (color == PuzzleColor.Blue) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_JUMP_PAD_BLUE); } // NOTE: The player automaticlly nullifies his events upon leaving the room. RoomControl.Player.EventJump += OnPlayerJump; RoomControl.Player.EventLand += OnPlayerLand; }
//----------------------------------------------------------------------------- // Color Methods //----------------------------------------------------------------------------- private void CycleColor() { // Cycle the color (red -> yellow -> blue) PuzzleColor color = (PuzzleColor)Properties.Get("color", (int)PuzzleColor.Red); if (color == PuzzleColor.Red) { color = PuzzleColor.Yellow; } else if (color == PuzzleColor.Yellow) { color = PuzzleColor.Blue; } else if (color == PuzzleColor.Blue) { color = PuzzleColor.Red; } // Set the color property. Properties.Set("color", (int)color); // Set the sprite. if (color == PuzzleColor.Red) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_JUMP_PAD_RED); } else if (color == PuzzleColor.Yellow) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_JUMP_PAD_YELLOW); } else if (color == PuzzleColor.Blue) { Graphics.PlaySprite(GameData.SPR_TILE_COLOR_JUMP_PAD_BLUE); } AudioSystem.PlaySound(GameData.SOUND_GET_ITEM); GameControl.FireEvent(this, "event_color_change", this, ((ZeldaAPI.ColorJumpPad) this).Color); }
private SingleColorState(Location location, PuzzleColor color, bool isNot, bool isRotated) : base(location, isNot, isRotated) { this.Color = color; }
public static PuzzleColor UpdateColorIfTemplated(PuzzleColor currentColor, PuzzleColor[] templateColors) => currentColor > PuzzleColor.TemplateColors ? templateColors[currentColor - PuzzleColor.TemplateColors - 1] : currentColor;
//----------------------------------------------------------------------------- // Contsants //----------------------------------------------------------------------------- /*private const int PLAYER_EXIT_WALK_DISTANCE = 15; private const int SCREEN_SHAKE_DURATION = 4; private const int SCREEN_SHAKE_MAGNITUDE = 3; private const int BEFORE_TURN_DELAY = 15; private const int AFTER_TURN_DELAY = 7; private static float[] PLAYER_ROTATE_OFFSETS = { 12, 10, 8, 2, 0 }; private const int PLAYER_ROTATE_OFFSET_INTERVAL = 4;*/ //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public RoomStateColorBarrier(PuzzleColor raiseColor) { this.raiseColor = raiseColor; this.updateRoom = false; this.animateRoom = true; }
//----------------------------------------------------------------------------- // Contsants //----------------------------------------------------------------------------- /*private const int PLAYER_EXIT_WALK_DISTANCE = 15; * private const int SCREEN_SHAKE_DURATION = 4; * private const int SCREEN_SHAKE_MAGNITUDE = 3; * private const int BEFORE_TURN_DELAY = 15; * private const int AFTER_TURN_DELAY = 7; * private static float[] PLAYER_ROTATE_OFFSETS = { 12, 10, 8, 2, 0 }; * private const int PLAYER_ROTATE_OFFSET_INTERVAL = 4;*/ //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public RoomStateColorBarrier(PuzzleColor raiseColor) { this.raiseColor = raiseColor; this.updateRoom = false; this.animateRoom = true; }
private PuzzlePiece CombinePieces(PuzzlePiece moving, PuzzlePiece movingInto) { int movingAmount = GetTotalPieces(moving); int moveToAmount = GetTotalPieces(movingInto); int combined = movingAmount + moveToAmount; if (movingAmount != moveToAmount) { int t = (int)movingInto + movingAmount; //combined + (int)moving; return((PuzzlePiece)t); } combined--; PuzzleColor movingCol = GetColor(moving); PuzzleColor movingIntoCol = GetColor(movingInto); switch (movingCol) { case PuzzleColor.Red: switch (movingIntoCol) { case PuzzleColor.Red: return(PuzzlePiece.RedSingle + combined); case PuzzleColor.Blue: return(PuzzlePiece.GreenSingle + combined); case PuzzleColor.Green: return(PuzzlePiece.BlueSingle + combined); } break; case PuzzleColor.Blue: switch (movingIntoCol) { case PuzzleColor.Red: return(PuzzlePiece.GreenSingle + combined); case PuzzleColor.Blue: return(PuzzlePiece.BlueSingle + combined); case PuzzleColor.Green: return(PuzzlePiece.RedSingle + combined); } break; case PuzzleColor.Green: switch (movingIntoCol) { case PuzzleColor.Red: return(PuzzlePiece.BlueSingle + combined); case PuzzleColor.Blue: return(PuzzlePiece.RedSingle + combined); case PuzzleColor.Green: return(PuzzlePiece.GreenSingle + combined); } break; } return(moving); }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- // Draw a tile. private void DrawTile(Graphics2D g, TileDataInstance tile, Point2I position, Color drawColor) { Sprite sprite = null; Animation animation = null; float playbackTime = editorControl.Ticks; int substripIndex = tile.Properties.GetInteger("substrip_index", 0); //----------------------------------------------------------------------------- // Platform. if (tile.Type == typeof(TilePlatform)) { if (!tile.CurrentSprite.IsNull) { // Draw the tile once per point within its size. for (int y = 0; y < tile.Size.Y; y++) { for (int x = 0; x < tile.Size.X; x++) { Point2I drawPos = position + (new Point2I(x, y) * GameSettings.TILE_SIZE); g.DrawAnimation(tile.CurrentSprite, tile.Room.Zone.ImageVariantID, editorControl.Ticks, position, drawColor); } } } return; } //----------------------------------------------------------------------------- // Color Jump Pad. else if (tile.Type == typeof(TileColorJumpPad)) { PuzzleColor tileColor = (PuzzleColor)tile.Properties.GetInteger("color", 0); if (tileColor == PuzzleColor.Red) { sprite = GameData.SPR_TILE_COLOR_JUMP_PAD_RED; } else if (tileColor == PuzzleColor.Yellow) { sprite = GameData.SPR_TILE_COLOR_JUMP_PAD_YELLOW; } else if (tileColor == PuzzleColor.Blue) { sprite = GameData.SPR_TILE_COLOR_JUMP_PAD_BLUE; } } //----------------------------------------------------------------------------- // Color Cube else if (tile.Type == typeof(TileColorCube)) { int orientationIndex = tile.Properties.GetInteger("orientation", 0); sprite = GameData.SPR_COLOR_CUBE_ORIENTATIONS[orientationIndex]; } //----------------------------------------------------------------------------- // Crossing Gate. else if (tile.Type == typeof(TileCrossingGate)) { if (tile.Properties.GetBoolean("raised", false)) { animation = GameData.ANIM_TILE_CROSSING_GATE_LOWER; } else { animation = GameData.ANIM_TILE_CROSSING_GATE_RAISE; } substripIndex = (tile.Properties.GetBoolean("face_left", false) ? 1 : 0); playbackTime = 0.0f; } //----------------------------------------------------------------------------- // Lantern. else if (tile.Type == typeof(TileLantern)) { if (tile.Properties.GetBoolean("lit", true)) { animation = GameData.ANIM_TILE_LANTERN; } else { sprite = GameData.SPR_TILE_LANTERN_UNLIT; } } //----------------------------------------------------------------------------- // Chest. else if (tile.Type == typeof(TileChest)) { bool isLooted = tile.Properties.GetBoolean("looted", false); sprite = tile.SpriteList[isLooted ? 1 : 0].Sprite; } //----------------------------------------------------------------------------- // Color Lantern. /*else if (tile.Type == typeof(TileColorLantern)) { * PuzzleColor color = (PuzzleColor) tile.Properties.GetInteger("color", -1); * if (color == PuzzleColor.Red) * animation = GameData.ANIM_EFFECT_COLOR_FLAME_RED; * else if (color == PuzzleColor.Yellow) * animation = GameData.ANIM_EFFECT_COLOR_FLAME_YELLOW; * else if (color == PuzzleColor.Blue) * animation = GameData.ANIM_EFFECT_COLOR_FLAME_BLUE; * }*/ //----------------------------------------------------------------------------- if (animation == null && sprite == null && tile.CurrentSprite.IsAnimation) { animation = tile.CurrentSprite.Animation; } if (animation == null && sprite == null && tile.CurrentSprite.IsSprite) { sprite = tile.CurrentSprite.Sprite; } // Draw the custom sprite/animation if (animation != null) { g.DrawAnimation(animation.GetSubstrip(substripIndex), tile.Room.Zone.ImageVariantID, playbackTime, position, drawColor); } else if (sprite != null) { g.DrawSprite(sprite, tile.Room.Zone.ImageVariantID, position, drawColor); } /*else if (!tile.CurrentSprite.IsNull) { * g.DrawAnimation(tile.CurrentSprite, * tile.Room.Zone.ImageVariantID, editorControl.Ticks, position, drawColor); * }*/ // Draw rewards. if (editorControl.ShowRewards && tile.Properties.Exists("reward") && editorControl.RewardManager.HasReward(tile.Properties.GetString("reward"))) { Animation anim = editorControl.RewardManager.GetReward(tile.Properties.GetString("reward")).Animation; g.DrawAnimation(anim, editorControl.Ticks, position, drawColor); } }
public static void UpdateRoomDebugKeys() { if (Keyboard.IsKeyPressed(Keys.P)) { RoomControl.IsSideScrolling = !RoomControl.IsSideScrolling; } // C: Change color barrier color. if (Keyboard.IsKeyPressed(Keys.C)) { if (RoomControl.Dungeon != null) { PuzzleColor c = (RoomControl.Dungeon.ColorSwitchColor == PuzzleColor.Blue ? PuzzleColor.Red : PuzzleColor.Blue); RoomControl.Dungeon.ColorSwitchColor = c; if (RoomControl.GetTilesOfType <TileColorBarrier>().Any()) { gameControl.PushRoomState(new RoomStateColorBarrier(c)); } } } // CTRL+R: Restart the game. if (Keyboard.IsKeyPressed(Keys.R) && Keyboard.IsKeyDown(Keys.LControl)) { GameManager.Restart(); } // F5: Pause gameplay. if (Keyboard.IsKeyPressed(Keys.F5)) { GameManager.IsGamePaused = !GameManager.IsGamePaused; } // F6: Step gameplay by one frame. if (Keyboard.IsKeyPressed(Keys.F6) && GameManager.IsGamePaused) { GameManager.NextFrame(); } // OPEN BRACKET: open all open doors. if (Keyboard.IsKeyPressed(Keys.OpenBracket)) { RoomControl.OpenAllDoors(); } // CLOSE BRACKET: close all doors. else if (Keyboard.IsKeyPressed(Keys.CloseBracket)) { RoomControl.CloseAllDoors(); } // G: Display a test message. if (Keyboard.IsKeyPressed(Keys.G)) { gameControl.DisplayMessage("I was a <red>hero<red> to broken robots 'cause I was one of them, but how can I sing about being damaged if I'm not?<p> That's like <green>Christina Aguilera<green> singing Spanish. Ooh, wait! That's it! I'll fake it!"); } // INSERT: Fill all ammo. if (Keyboard.IsKeyPressed(Keys.Insert)) { gameControl.Inventory.FillAllAmmo(); Dungeon dungeon = gameControl.RoomControl.Dungeon; if (dungeon != null) { dungeon.NumSmallKeys = Math.Min(dungeon.NumSmallKeys + 3, 9); dungeon.HasMap = true; dungeon.HasCompass = true; dungeon.HasBossKey = true; } } // DELETE: Empty all ammo. if (Keyboard.IsKeyPressed(Keys.Delete)) { gameControl.Inventory.EmptyAllAmmo(); } // HOME: Set the player's health to max. if (Keyboard.IsKeyPressed(Keys.Home)) { gameControl.Player.MaxHealth = 4 * 14; gameControl.Player.Health = gameControl.Player.MaxHealth; } // END: Set the player's health to 3 hearts. if (Keyboard.IsKeyPressed(Keys.End)) { gameControl.Player.Health = 4 * 3; } // T: Cycle which tunic the player is wearing. if (Keyboard.IsKeyPressed(Keys.T)) { switch (gameControl.Player.Tunic) { case PlayerTunics.GreenTunic: gameControl.Player.Tunic = PlayerTunics.RedTunic; break; case PlayerTunics.RedTunic: gameControl.Player.Tunic = PlayerTunics.BlueTunic; break; case PlayerTunics.BlueTunic: gameControl.Player.Tunic = PlayerTunics.GreenTunic; break; } } // H: Hurt the player in a random direction. if (Keyboard.IsKeyPressed(Keys.H)) { float angle = GRandom.NextFloat(GMath.FullAngle); Vector2F source = gameControl.Player.Center + new Vector2F(5.0f, angle, true); gameControl.Player.Hurt(new DamageInfo(0, source)); } // M: Play music. /*if (Keyboard.IsKeyPressed(Keys.M)) { * AudioSystem.PlaySong("overworld"); * } * // N: Set the volume to max. * if (Keyboard.IsKeyPressed(Keys.N)) { * AudioSystem.MasterVolume = 1.0f; * }*/ // N: Noclip mode. if (Keyboard.IsKeyPressed(Keys.N)) { RoomControl.Player.Physics.CollideWithEntities = !RoomControl.Player.Physics.CollideWithEntities; RoomControl.Player.Physics.CollideWithWorld = !RoomControl.Player.Physics.CollideWithWorld; } // Q: Spawn a random rupees collectible. if (Keyboard.IsKeyPressed(Keys.Q)) { int[] rupees = { 1, 5, 20, 100, 200 }; //, 5, 20, 100, 200 }; int rupee = GRandom.NextInt(rupees.Length); Collectible collectible = gameControl.RewardManager.SpawnCollectible("rupees_" + rupees[rupee].ToString()); collectible.Position = gameControl.Player.Position; collectible.ZPosition = 100; } // Y: Cycle entity debug info. if (Keyboard.IsKeyPressed(Keys.Y)) { EntityDebugInfoMode = (EntityDrawInfo)(((int)EntityDebugInfoMode + 1) % (int)EntityDrawInfo.Count); } // U: Cycle tile debug info. if (Keyboard.IsKeyPressed(Keys.U)) { TileDebugInfoMode = (TileDrawInfo)(((int)TileDebugInfoMode + 1) % (int)TileDrawInfo.Count); } // J: Spawn a heart collectible. if (Keyboard.IsKeyPressed(Keys.K)) { Collectible collectible = gameControl.RewardManager.SpawnCollectible("hearts_1"); collectible.Position = gameControl.Player.Position; collectible.ZPosition = 100; } // B: Spawn bomb collectibles. if (Keyboard.IsKeyPressed(Keys.B)) { Collectible collectible = gameControl.RewardManager.SpawnCollectible("ammo_bombs_5"); collectible.Position = gameControl.Player.Position; collectible.ZPosition = 100; } // J: Spawn arrow collectibles. if (Keyboard.IsKeyPressed(Keys.J)) { Collectible collectible = gameControl.RewardManager.SpawnCollectible("ammo_arrows_5"); collectible.Position = gameControl.Player.Position; collectible.ZPosition = 100; } // 0: Spawn a monster. if (Keyboard.IsKeyPressed(Keys.D0) || Keyboard.IsKeyPressed(Keys.Add)) { Monster monster = new TestMonster(); //Monster monster = new MonsterOctorok(); //Monster monster = new MonsterMoblin(); Vector2F position = new Vector2F(32, 32) + new Vector2F(8, 14); RoomControl.SpawnEntity(monster, position); } }