public override void ReceiveMessage(Message msg) { if (msg.Type == MessageType.CollideWithEntity) { // Ignore this message! } else { base.ReceiveMessage(msg); } }
public void SendMessage(Message msg) { if (msg.SendTime == 0) { msg.Receiver.ReceiveMessage(msg); } else { m_messageList.Add(msg); } }
public override void ReceiveMessage(Message msg) { if (msg.Type == MessageType.CollideWithEntity) { EntityCollisionMsg collisionMsg = (EntityCollisionMsg) msg; ChangeZoneMsg changeRoomMsg = new ChangeZoneMsg(this, IvyGame.Get(), collisionMsg.EntityHit, DestZone, DestPosition, 0); MessageDispatcher.Get().SendMessage(changeRoomMsg); } }
public override void ReceiveMessage(Message msg) { if (msg.Type == MessageType.RidleyDead) { EscapeTimer.Paused = false; GetCurrentZone().SetEscapeMode(true); CameraGel = Content.Load<Texture2D>(@"art/bg_layer_redaura"); GelTint = new Color(1.0f, 0.0f, 0.0f, 0.0f); } else { base.ReceiveMessage(msg); } }
public override void HandleMessage(Entity entity, Message msg) { switch (msg.Type) { //case MessageType.CollideWithEnv: // Message newMsg = new Message(MessageType.Fall, entity, entity); // MessageDispatcher.Get().SendMessage(newMsg); //entity.ChangeState(EntityStateFall.Get()); // break; case MessageType.Fall: entity.ChangeState(EntityStateFall.Get()); break; default: // TODO: error! break; } }
public override void HandleMessage(Entity entity, Message msg) { switch (msg.Type) { case MessageType.Stand: entity.ChangeState(EntityStateStand.Get()); break; case MessageType.Jump: entity.ChangeState(EntityStateJump.Get()); break; case MessageType.Fall: entity.ChangeState(EntityStateFall.Get()); break; default: // TODO: error! break; } }
public override void HandleMessage(Entity entity, Message msg) { switch (msg.Type) { case MessageType.Land: if (entity.CurrentSpeed.X != 0f) { entity.ChangeState(EntityStateRun.Get()); } else { entity.ChangeState(EntityStateStand.Get()); } break; default: // TODO: error! break; } }
public virtual bool HandleMessage(Message msg) { bool handledMessage = true; if (m_nextNodesOnMessage.ContainsKey(msg.Type) == true) { m_graph.SetCurrentNode(m_nextNodesOnMessage[msg.Type]); m_nextNodeOnAnimEnd = m_defaultNextNodeOnAnimEnd; //IvyGame.Get().ConsoleStr += " Handled Message: " + msg.Type + " in " + Anim.Name + "\n"; } else if (m_altNextNodesOnAnimEnd.ContainsKey(msg.Type) == true) { m_nextNodeOnAnimEnd = m_altNextNodesOnAnimEnd[msg.Type]; //IvyGame.Get().ConsoleStr += " Handled Message: " + msg.Type + " in " + Anim.Name + "\n"; } else { handledMessage = false; } return handledMessage; }
public void ReceiveMessage(Message msg) { if (m_currentNode != null) { m_currentNode.HandleMessage(msg); } }
public override void ReceiveMessage(Message msg) { if (msg.Type == MessageType.CollideWithEntity) { EntityCollisionMsg entMsg = (EntityCollisionMsg) msg; TakeDamageMsg takeDamageMsg = new TakeDamageMsg(this, entMsg.EntityHit, Damage); MessageDispatcher.Get().SendMessage(takeDamageMsg); } else { base.ReceiveMessage(msg); } }
protected override bool OnKeyboardEvent(KeyboardEvent e) { bool ret = true; // Jump! if (e.Key == Keys.Space) { if (e.EventType == InputEventType.Pressed) { // start jump Message msg = new Message(MessageType.Jump, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else if (e.EventType == InputEventType.Released) { // end jump Message msg = new Message(MessageType.Fall, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } } else if ((e.Key == Keys.F) && (e.EventType == InputEventType.Pressed)) { // Fire Message msg = new Message(MessageType.FireWeapon, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else { ret = base.OnKeyboardEvent(e); } return ret; }
bool OnKeyboardDirectionEvent(KeyboardEvent e) { // TODO: design some way to map events to messages to avoid switch code like this // TODO: add some intelligence here to make sure that left and right keys are mutually exclusive if (e.Key == Keys.Left) { if (e.EventType == InputEventType.Pressed) { Message msg = new Message(MessageType.MoveLeft, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else if (e.EventType == InputEventType.Released) { Message msg = new Message(MessageType.Stand, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } } else if (e.Key == Keys.Right) { if (e.EventType == InputEventType.Pressed) { Message msg = new Message(MessageType.MoveRight, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else if (e.EventType == InputEventType.Released) { Message msg = new Message(MessageType.Stand, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } } return true; }
public virtual void ReceiveMessage(Message msg) { if (msg.Type == MessageType.ChangeZone) { ChangeZoneMsg czMsg = (ChangeZoneMsg)msg; Entity entity = czMsg.Entity; if (czMsg.DestZone == ZoneName) { AddEntity(entity, czMsg.DestPosition); } else { RemoveEntity(entity); } } }
public abstract void HandleMessage(Entity entity, Message msg);
public override void ReceiveMessage(Message msg) { base.ReceiveMessage(msg); m_animGraph.ReceiveMessage(msg); }
public override void ReceiveMessage(Message msg) { if (msg.Type == MessageType.CollideWithEntity) { EntityCollisionMsg collisionMsg = (EntityCollisionMsg)msg; if (collisionMsg.EntityHit != m_weaponOwner) { Explode(); TakeDamageMsg damageMsg = new TakeDamageMsg(this, collisionMsg.EntityHit, Damage); MessageDispatcher.Get().SendMessage(damageMsg); } } else { base.ReceiveMessage(msg); } }
public void HandleMessage(Message msg) { CurrentState.HandleMessage(m_owner, msg); }
protected virtual void HandleGameEndMsg(Message msg) { if (msg.Type == MessageType.EndGame) { State = GameState.GameOver; } }
bool OnGamePadDirectionEvent(GamePadButtonEvent e) { // TODO: design some way to map events to messages to avoid switch code like this if ((e.Button == Buttons.LeftThumbstickLeft) || (e.Button == Buttons.DPadLeft)) { if (e.EventType == InputEventType.Pressed) { Message msg = new Message(MessageType.MoveLeft, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else if ((e.EventType == InputEventType.Released) && (InputMgr.Get().GamePadState.IsButtonUp(Buttons.LeftThumbstickRight)) && (InputMgr.Get().GamePadState.IsButtonUp(Buttons.DPadRight))) { // TODO: need a better way of handling mutually exclusive button inputs Message msg = new Message(MessageType.Stand, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } } else if ((e.Button == Buttons.LeftThumbstickRight) || (e.Button == Buttons.DPadRight)) { if (e.EventType == InputEventType.Pressed) { Message msg = new Message(MessageType.MoveRight, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else if ((e.EventType == InputEventType.Released) && (InputMgr.Get().GamePadState.IsButtonUp(Buttons.LeftThumbstickLeft)) && (InputMgr.Get().GamePadState.IsButtonUp(Buttons.DPadLeft))) { // TODO: need a better way of handling mutually exclusive button inputs Message msg = new Message(MessageType.Stand, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } } return true; }
public virtual void ReceiveMessage(Message msg) { if (msg.Type == MessageType.ChangeZone) { HandleChangeZoneMsg((ChangeZoneMsg)msg); } else if (msg.Type == MessageType.PauseGame) { State = GameState.Pause; } else if (msg.Type == MessageType.PlayGame) { State = GameState.Play; } else if (msg.Type == MessageType.EndGame) { HandleGameEndMsg(msg);; } }
public override void ReceiveMessage(Message msg) { switch (msg.Type) { case MessageType.FireWeapon: FireWeapon(); break; default: base.ReceiveMessage(msg); break; } m_animGraph.ReceiveMessage(msg); if (msg.Type == MessageType.TakeDamage) { if (Energy <= 0) { MessageDispatcher.Get().SendMessage(new Message(MessageType.EndGame, this, IvyGame.Get())); } } }
public virtual void ReceiveMessage(Message msg) { m_entityStateMgr.HandleMessage(msg); if (msg.Type == MessageType.CollideWithEntity) { HandleCollisionWithEntity((EntityCollisionMsg)msg); } else if ((msg.Type == MessageType.TakeDamage) && Damagable) { Energy = Math.Max(Energy - ((TakeDamageMsg)msg).Damage, 0); } if (msg.Type == MessageType.MoveLeft) { Direction = new Vector2(-1f, Direction.Y); CurrentSpeed = new Vector2(m_speed.X, CurrentSpeed.Y); } else if (msg.Type == MessageType.MoveRight) { Direction = new Vector2(1f, Direction.Y); CurrentSpeed = new Vector2(m_speed.X, CurrentSpeed.Y); } else if (msg.Type == MessageType.Stand) { CurrentSpeed = new Vector2(0f, CurrentSpeed.Y); } else if (msg.Type == MessageType.Jump) { Direction = new Vector2(Direction.X, -1f); CurrentSpeed = new Vector2(CurrentSpeed.X, m_speed.Y); m_platform = null; } else if (msg.Type == MessageType.Fall) { Direction = new Vector2(Direction.X, 1f); CurrentSpeed = new Vector2(CurrentSpeed.X, m_speed.Y); m_platform = null; } else if (msg.Type == MessageType.Land) { CurrentSpeed = new Vector2(CurrentSpeed.X, 0f); } // if moving message...update direction? // or should that be done on state change?? // and do we query input mgr or do we do it some other way }
protected override bool OnGamePadButtonEvent(GamePadButtonEvent e) { bool ret = true; if (e.Button == Buttons.B) { if (e.EventType == InputEventType.Pressed) { // start jump Message msg = new Message(MessageType.Jump, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else if (e.EventType == InputEventType.Released) { // end jump! Message msg = new Message(MessageType.Fall, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } } else if ((e.Button == Buttons.Y) && (e.EventType == InputEventType.Pressed)) { // Fire Message msg = new Message(MessageType.FireWeapon, this, m_playerOne); MessageDispatcher.Get().SendMessage(msg); } else { ret = base.OnGamePadButtonEvent(e); } return ret; }