예제 #1
0
        public Bullet(Node parent, string name)
            : base(parent, name)
        {
            Render = new ImageRender(this, "Render");
            Render.SetTexture(GetRoot<State>().GetService<AssetCollector>().GetAsset<Texture2D>("bullet"));
            Render.Layer = .1f;
            Render.Scale = new Vector2(.1f);
            Render.Color = Color.White;
            Render.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);

            //Make our collision rectangles the size of the rendered sprite.
            Body.Bounds = Render.Bounds;
            Body.Origin = new Vector2(Render.Texture.Width / 2f, Render.Texture.Height / 2f);

            Shape = new Circle(this, "Shape", Body.Width / 2);
            Shape.Offset = new Vector2(Body.Width / 2, Body.Height / 2);
            Shape.LinkDependency(Circle.DEPENDENCY_BODY, Body);

            Collision.Group.AddMask(1);
            Collision.Pair.AddMask(2);
            Collision.Immovable = true;
            Collision.CollideEvent += collision => Recycle();
            Collision.LinkDependency(Collision.DEPENDENCY_SHAPE, Shape);
            Shape.LinkDependency(Circle.DEPENDENCY_COLLISION, Collision);

            DeathTimer = new Timer(this, "DeathTimer");
            DeathTimer.Milliseconds = 2000;
            DeathTimer.LastEvent += Recycle;
            DeathTimer.LastEvent += DeathTimer.Stop;
        }
예제 #2
0
        public Spawn(Node parent, int ttl)
            : base(parent, parent.Name + ".Spawn")
        {
            Name = Name + Id;

            DeathTimer = new Timer(this, "Timer");
            TimeToLive = ttl;
            DeathTimer.Start();
            //TimeToLiveTimer.LastEvent += () => Destroy();
        }
            public FadeOutLabel(Page parent, string name, Point tabPosition)
                : base(parent, name, tabPosition)
            {
                _beginFadeTimer = new Timer(this, "BeginFadeTimer");
                _beginFadeTimer.Milliseconds = 2000;
                _beginFadeTimer.LastEvent += StartFade;
                _beginFadeTimer.LastEvent += _beginFadeTimer.Stop;
                _beginFadeTimer.Start();

                _fadeStepTimer = new Timer(this, "FadeStepTimer");
                _fadeStepTimer.Milliseconds = 500;
                _fadeStepTimer.LastEvent += _fadeStepTimer.Stop;
            }
            public ColorGameOfLifeManager(Node parent, string name)
                : base(parent, name)
            {
                UpdateTimer = new Timer(this, "UpdateTimer");
                UpdateTimer.Milliseconds = 250;

                DrawButton = new GamepadInput(this, "DrawButton", Buttons.B, PlayerIndex.One);
                DrawMouseButton = new MouseInput(this, "DrawMousebUtton", MouseButton.RightButton);

                EraseButton = new GamepadInput(this, "EraseButton", Buttons.X, PlayerIndex.One);
                EraseMouseButton = new MouseInput(this, "EraseMousebUtton", MouseButton.MiddleButton);
            }
        public override void Initialize()
        {
            base.Initialize();

            EmitTimer = new Timer(this, "EmitTimer");
            EmitTimer.Milliseconds = 250;
            EmitTimer.LastEvent += EmitParticle;

            B = new CircleTester(this, "B", 60);
            B.Render.Color = Color.Blue;
            B.Physics.Restitution = 2f;
            B.Collision.Immovable = true;
            B.Body.Position = new Vector2(EntityGame.Viewport.Width / 2f - B.Body.Width / 2,
                EntityGame.Viewport.Height - 20 - B.Body.Height);
            B.Debug = true;
            //B.Physics.Velocity.X = -1;
        }