GetLateBoundEffect() public static method

public static GetLateBoundEffect ( string name ) : Effect
name string
return Effect
Exemplo n.º 1
0
        private void CallCommand(SceneCallCommandInfo command)
        {
            var player = Entities.GetEntityById("Player");

            if (player != null)
            {
                EffectParser.GetLateBoundEffect(command.Name)(player);
            }
        }
        protected override void Update()
        {
            if (!CanMove || Parent.Paused)
            {
                return;
            }

            float accelX = (pendingVx - vx) * dragX;

            vx += accelX;

            float accelY = (pendingVy - vy) * dragY;

            vy += accelY;

            if (!Floating)
            {
                float gmult = (overTile != null) ? overTile.Properties.GravityMult : 1;

                if (Parent.Container.IsGravityFlipped)
                {
                    vy -= Parent.Container.Gravity * gmult;
                    if (vy < -Const.TerminalVel)
                    {
                        vy = -Const.TerminalVel;
                    }
                }
                else
                {
                    vy += Parent.Container.Gravity * gmult;
                    if (vy > Const.TerminalVel)
                    {
                        vy = Const.TerminalVel;
                    }
                }
            }

            if (FlipSprite)
            {
                SpriteComponent sprite = Parent.GetComponent <SpriteComponent>();
                if (sprite != null)
                {
                    sprite.HorizontalFlip = (Direction == Direction.Left);
                }
            }

            Tile nextOverTile = null;

            if (position != null)
            {
                float deltaX = vx + pushX;
                float deltaY = vy + pushY;

                PointF pos = position.Position;
                if (collision == null)
                {
                    pos.X += deltaX;
                    pos.Y += deltaY;
                }
                else
                {
                    if ((!collision.BlockLeft && deltaX < 0) || (!collision.BlockRight && deltaX > 0))
                    {
                        pos.X += deltaX;
                    }
                    if ((!collision.BlockTop && deltaY < 0) || (!collision.BlockBottom && deltaY > 0))
                    {
                        pos.Y += deltaY;
                    }
                }
                position.SetPosition(pos);

                nextOverTile = Parent.Screen.TileAt(position.Position.X, position.Position.Y);
            }

            if (Parent.Name == "Player")
            {
                if (overTile != null && nextOverTile != null && nextOverTile.Properties.Name != overTile.Properties.Name)
                {
                    if (overTile.Properties.OnLeave != null)
                    {
                        EffectParser.GetLateBoundEffect(overTile.Properties.OnLeave)(Parent);
                    }
                    if (nextOverTile.Properties.OnEnter != null)
                    {
                        EffectParser.GetLateBoundEffect(nextOverTile.Properties.OnEnter)(Parent);
                    }
                }

                if (nextOverTile != null && nextOverTile.Properties.OnOver != null)
                {
                    EffectParser.GetLateBoundEffect(nextOverTile.Properties.OnOver)(Parent);
                }
            }

            vx     *= resistX;
            vy     *= resistY;
            resistX = resistY = 1;

            pendingVx = vx;
            pendingVy = vy;

            overTile = nextOverTile;
            pushX    = pushY = 0;
            dragX    = dragY = 1;
        }