示例#1
0
文件: Platform.cs 项目: endy/IvyXNA
 public override void ReceiveMessage(Message msg)
 {
     if (msg.Type == MessageType.CollideWithEntity)
     {
         // Ignore this message!
     }
     else
     {
         base.ReceiveMessage(msg);
     }
 }
示例#2
0
 public void SendMessage(Message msg)
 {
     if (msg.SendTime == 0)
     {
         msg.Receiver.ReceiveMessage(msg);
     }
     else
     {
         m_messageList.Add(msg);
     }
 }
示例#3
0
文件: ZonePortal.cs 项目: endy/IvyXNA
        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);
            }
        }
示例#4
0
文件: Ceres.cs 项目: endy/IvyXNA
        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);
            }
        }
示例#5
0
 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;
     }
 }
示例#6
0
 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;
     }
 }
示例#7
0
 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;
     }
 }
示例#8
0
文件: AnimGraph.cs 项目: endy/IvyXNA
            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;
            }
示例#9
0
文件: AnimGraph.cs 项目: endy/IvyXNA
 public void ReceiveMessage(Message msg)
 {
     if (m_currentNode != null)
     {
         m_currentNode.HandleMessage(msg);
     }
 }
示例#10
0
文件: Ridley.cs 项目: endy/IvyXNA
        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);
            }
        }
示例#11
0
文件: Ceres.cs 项目: endy/IvyXNA
        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;
        }
示例#12
0
文件: Ceres.cs 项目: endy/IvyXNA
        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;
        }
示例#13
0
文件: WorldZone.cs 项目: endy/IvyXNA
 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);
         }
     }
 }
示例#14
0
文件: State.cs 项目: endy/IvyXNA
 public abstract void HandleMessage(Entity entity, Message msg);
示例#15
0
文件: Skree.cs 项目: endy/IvyXNA
        public override void ReceiveMessage(Message msg)
        {
            base.ReceiveMessage(msg);

            m_animGraph.ReceiveMessage(msg);
        }
示例#16
0
文件: Projectile.cs 项目: endy/IvyXNA
        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);
            }
        }
示例#17
0
文件: StateMgr.cs 项目: endy/IvyXNA
 public void HandleMessage(Message msg)
 {
     CurrentState.HandleMessage(m_owner, msg);
 }
示例#18
0
文件: IvyGame.cs 项目: endy/IvyXNA
 protected virtual void HandleGameEndMsg(Message msg)
 {
     if (msg.Type == MessageType.EndGame)
     {
         State = GameState.GameOver;
     }
 }
示例#19
0
文件: Ceres.cs 项目: endy/IvyXNA
        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;
        }
示例#20
0
文件: IvyGame.cs 项目: endy/IvyXNA
 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);;
     }
 }
示例#21
0
文件: Player.cs 项目: endy/IvyXNA
        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()));
                }
            }
        }
示例#22
0
文件: Entity.cs 项目: endy/IvyXNA
        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
        }
示例#23
0
文件: Ceres.cs 项目: endy/IvyXNA
        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;
        }