void OpenedStateInit(string previous) { TaskScheduler.AddTask(() => { GameObjectManager.AddObject( new Explosion( this.transform.position + new Vector2( 8 + (float)GameManager.random.NextDouble() * 8 - 4, 8 + (float)GameManager.random.NextDouble() * 8 - 4))); ((Camera)GameObjectManager.FindObjectWithTag("camera"))?.AddShake(0.1); }, 0.3, 1.8, this.id ); TaskScheduler.AddTask(() => { done = true; for (int i = 0; i < 4; i += 1) { GameObjectManager.AddObject( new Explosion( this.transform.position + new Vector2( 8 + (float)GameManager.random.NextDouble() * 8 - 4, 8 + (float)GameManager.random.NextDouble() * 8 - 4))); } ((Camera)GameObjectManager.FindObjectWithTag("camera"))?.AddShake(0.4); // // Remove map cell. // var celPos = util.CorrespondingCelIndex(this.transform.position); GameManager.pico8.Memory.Mset((int)celPos.X, (int)celPos.Y, 0); }, 2, 2, this.id ); }
public override void OnCollisionEnter(GameObject other) { base.OnCollisionEnter(other); if (other is Player) { var player = (Player)other; // Kill the boots and give player run abillity player.EnableRunning(); // Destroy and give seconds. done = true; TimePiece.SpawnParticles(_timeToGive, collisionBox == null ? transform.position : collisionBox.middle, GameObjectManager.playerInstance); // Instantiate Dialogue Box var dialogueBox = new DialogueBox(new List <string>() { "you've got the running boots! \n\npress [ RT / SHIFT ]\nto activate.", "it will drain your time faster \nthough, so use carefully!" }); dialogueBox.SetEndAction(() => GameObjectManager.ResumeEveryone(null)); GameObjectManager.AddObject(dialogueBox); GameObjectManager.PauseEveryone(new List <GameObject>() { dialogueBox }); } }
public override void OnCollisionEnter(GameObject other) { base.OnCollisionEnter(other); if (other.tags.Contains("player") && currentState != "Following") { InitState("Following"); } if (other is Gate) { GameObjectManager.AddObject(new Explosion(this.collisionBox.middle)); done = true; } }
public override void OnCollisionEnter(GameObject other) { base.OnCollisionEnter(other); GameObjectManager.AddObject(new ScreenTransition(1, () => GameManager.ResetOverworld(), ScreenTransition.TransitionEffect.FadeOut)); var p = GameObjectManager.FindObjectOfType <Player>(); if (p != null) { p.isPaused = true; } }
public static List <TimePiece> SpawnParticles(int amount, Vector2 position, GameObject follow = null, byte col = 9) { List <TimePiece> l = new List <TimePiece>(); for (int i = 0; i < amount; ++i) { var angle = GameManager.random.NextDouble() * Math.PI + Math.PI / 2; var dir = new Vector2((float)Math.Sin(angle), (float)Math.Cos(angle)); var tp = new TimePiece(position, dir, 1, follow, col); l.Add((TimePiece)GameObjectManager.AddObject(tp)); } return(l); }
public override void Interact() { base.Interact(); // Instantiate Dialogue Box var dialogueBox = new DialogueBox(_messages); dialogueBox.SetEndAction(() => GameObjectManager.ResumeEveryone(null)); GameObjectManager.AddObject(dialogueBox); GameObjectManager.PauseEveryone(new List <GameObject>() { dialogueBox }); }
public Altar(Vector2 position) : base(position) { _key = new Key(position + new Vector2(4, -2)); GameObjectManager.AddObject(_key); TaskScheduler.AddTask(() => { var smoke = new Smoke(position + new Vector2(4 + (float)GameManager.random.NextDouble() * 8, 8)); smoke.SetColor(9); smoke.SetRadius(1, 1.5f); ParticleManager.AddParticle(smoke); }, 0.1f, -1, this.id); AddComponent(new P8Sprite(78, 2, 2)); depth = -1000; }
void OverworldInit(GameStates previous) { GameObjectManager.RemoveAllObjects(); ParticleManager.RemoveAllParticles(); GameManager.pico8.CartridgeLoader.Load("untitled1bitgame.p8"); Vector2 playerPosition = Map.FindPlayerInMapSheet(); GameObjectManager.AddObject(new Camera(playerPosition)); GameObjectManager.AddObject(new Map(playerPosition)); GameObjectManager.AddObject(new UI()); GameObjectManager.AddObject(new ScreenTransition(1, () => { }, ScreenTransition.TransitionEffect.FadeIn)); GameObjectManager.GlobalFillPattern = 0; }
public OldMan(Vector2 position, int spritePosition, List <string> messages) : base(position, new Box(position, new Vector2(8, 8)), spritePosition) { AddComponent(new TopDownPhysics(0, 0, 0.95f)); var graphics = new P8TopDownAnimator(P8TopDownAnimator.AnimationMode.SIDES_ONLY); AddComponent(graphics); graphics.RunLeft = new SpriteAnimation(new P8Sprite(0, 1, 1, true, false), 3, 0.4f); graphics.IdleLeft = graphics.RunLeft; graphics.RunRight = new SpriteAnimation(new P8Sprite(0, 1, 1, false, false), 3, 0.4f); graphics.IdleRight = graphics.RunRight; doesDamage = false; if (messages != null && messages.Count != 0) { var dialoguePos = position - new Vector2(8, 0); GameObjectManager.AddObject(new DialogueArea(dialoguePos, new Box(dialoguePos, new Vector2(24, 16)), this, messages)); } }
public static GameObject CreateGameObject(int spriteValue, Vector2 position) { switch (spriteValue) { case 32: return(GameObjectManager.InstantiatePlayer(position)); case 1: var messages = GlobalVars.GetMessageListAt((int)(position.X / 8), (int)(position.Y / 8)); List <string> messageList = new List <string>(); if (messages != null) { foreach (var m in messages) { messageList.Add((string)m.Value); } } return(GameObjectManager.AddObject( new OldMan(position, spriteValue, messageList) )); case 98: return(GameObjectManager.AddObject( new FirePit( position ) )); case 76: return(GameObjectManager.AddObject( new Chimney( position ) )); case 7: return(GameObjectManager.AddObject(new Blob(position, spriteValue))); case 55: return(GameObjectManager.AddObject(new Bat(position, spriteValue))); case 21: return(GameObjectManager.AddObject(new Tortuga(position, spriteValue))); case 122: return(GameObjectManager.AddObject(new Spike(position, spriteValue))); case 42: return(GameObjectManager.AddObject(new Goose(position, spriteValue))); case 11: return(GameObjectManager.AddObject(new Gate(position))); case 12: return(GameObjectManager.AddObject(new Gate(position, Gate.OpenCondition.NO_ENEMIES))); case 19: return(GameObjectManager.AddObject(new Snake(position, spriteValue))); case 105: return(GameObjectManager.AddObject(new Key(position))); case 78: return(GameObjectManager.AddObject(new Altar(position))); case 126: return(GameObjectManager.AddObject(new Stairs(position, spriteValue))); case 51: return(GameObjectManager.AddObject(new RunningBoots(position))); case 123: return(GameObjectManager.AddObject(new RunningBoots(position))); default: return(GameObjectManager.AddObject(new GameObject(position, new Graphics.P8Sprite(spriteValue)))); } }
void AttackingInit(PlayerStates previous) { if (!_player.CanAttack) { Init(PlayerStates.Walking); return; } // // Remove input so it can't move while atacking // _player.RemoveComponent <AInput>(); // // Stop player. // var physics = _player.GetComponent <TopDownPhysics>(); physics.velocity = Vector2.Zero; // // Figure out sword's direction. // Vector2 facingDir = _player.transform.direction == Vector2.Zero ? physics.facingDirection : _player.transform.direction; if (facingDir.X != 0) { facingDir.Y = 0; } if (facingDir != Vector2.Zero) { facingDir.Normalize(); } // // Reset player's direction so it doesn't keep moving to the previous set direction. // _player.transform.direction = Vector2.Zero; // // Instantiate sword. // _player.swordInstance = new Sword(_player.transform.position + 8 * facingDir, facingDir); GameObjectManager.AddObject(_player.swordInstance); var ratio = (_player.lifeTime / _player.initialLifetime); if (ratio < 0.2) { _player.swordInstance.timeGivenAdjustment = 1f; } else if (ratio < 0.8) { _player.swordInstance.timeGivenAdjustment = 1.7f; } else { _player.swordInstance.timeGivenAdjustment = 2.3f; } }