Exemple #1
0
 public Ground(float x, float y, int w, int h) : base(x, y)
 {
     Collider = new BoxCollider(w, h, Tags.Ground);
     Collider.CenterOrigin();
     Graphic = Image.CreateRectangle(w, h, Color.Black);
     Graphic.CenterOrigin();
 }
Exemple #2
0
 public ButtonComponent()
 {
     Graphic = Image.CreateRectangle(300, 200);
     Graphic.CenterOrigin();
     X = 900;
     Y = 200;
 }
Exemple #3
0
        public Cell(Point position, int size = 2, double minSpeed = 1, double maxSpeed = 1, Color spriteColor = null)
        {
            var rnd = new Random();

            MinSpeed = minSpeed;
            MaxSpeed = (maxSpeed > 5) ? 5 : maxSpeed;
            if (MinSpeed < 1)
            {
                MinSpeed = 1;
            }
            if (MaxSpeed < MinSpeed)
            {
                MaxSpeed = MinSpeed;
            }
            Size = size;

            Speed       = MinSpeed;
            SpriteColor = spriteColor;
            Sprite      = Image.CreateCircle(Size / 2, SpriteColor);
            Direction   = new Vector2();
            Target      = new Point(rnd.Next(Global.Width), rnd.Next(Global.Height));

            Graphic = Sprite;
            Graphic.CenterOrigin();
            X = position.X;
            Y = position.Y;

            Global.Cells.Add(this);
        }
Exemple #4
0
 public TitleEntity(float x, float y) : base(x, y)
 {
     AddGraphic <Image>(new Image(@"..\..\Sprites\logo.png"));
     Graphic.CenterOrigin();
     Graphic.Alpha = 0;
     Tween(this, new { alpha = 1 }, 120).Ease(Ease.QuadIn);
     Tween(this, new { _y = 15 }, 30).Ease(Ease.SineInOut).Reflect().Repeat();
 }
Exemple #5
0
 public Enemy(Vector2 Size, float x = 0, float y = 0, Graphic graphic = null, Collider collider = null, string name = "")
     : base(x, y, graphic, collider, name)
 {
     X        = Global.WINDOWWIDTH / 2;
     Y        = -5;
     Collider = new BoxCollider((int)Size.X, (int)Size.Y, Tag.Enemy);
     Collider.CenterOrigin();
     Graphic.CenterOrigin();
 }
Exemple #6
0
        public PickupItem(float x = 0, float y = 0, Graphic graphic = null, Collider collider = null, string name = "")
            : base(x, y, graphic, collider, name)
        {
            Graphic  = graphic ?? Image.CreateCircle(ItemRadius, Color.Green);
            Collider = new CircleCollider(ItemRadius, Tag.PickupItem);

            Graphic.CenterOrigin();
            Collider.CenterOrigin();
        }
Exemple #7
0
 public Square(float x, float y, int w, int h, System.Drawing.Color color, Game game, InputManager manager) : base(x, y)
 {
     _manager   = manager;
     _coroutine = game.Coroutine;
     Graphic    = Image.CreateRectangle(w, h, Color.FromDraw(color));
     Graphic.CenterOrigin();
     _collider = new BoxCollider(w, h);
     AddCollider(_collider);
     Collider.CenterOrigin();
 }
Exemple #8
0
 public FroggitAttack01() : base()
 {
     rand           = new Random();
     this.X         = rand.Next(160) + 240;
     this.Y         = 240;
     gambarParticle = new Image(@"image/projectile/projectile0.png");
     Graphic        = gambarParticle;
     Graphic.CenterOrigin();
     SetHitbox(25, 25, Global.Type.PARTICLE);
     Collider.CenterOrigin();
 }
        public void NineSlice(string file, int slicewidth, int sliceheight, int width, int height)
        {
            image = new NineSlice(file, slicewidth, sliceheight);
            {
                ((NineSlice)image).PanelWidth  = width;
                ((NineSlice)image).PanelHeight = height;

                image.CenterOrigin();
            }
            AddGraphic(image);
        }
        // Constructor: Prepare graphics for when added to the scene
        public Entity_Cursor(string file)
        {
            File = file;

            if (File != "")
            {
                AddGraphic(new Image(File));
                Graphic.CenterOrigin();
            }

            Layer = Helper.Layer_Cursor;
        }
Exemple #11
0
        public Prop(float x, float y, Room room, Rectangle collisionSize, string imagePath, bool breakable)
            : base(room.X + x + 0, room.Y + y + 16)
        {
            AddGraphic(new Image(Global.imagePath + "Props/" + imagePath + ".png"));
            Graphic.CenterOrigin();
            AddCollider(new BoxCollider(collisionSize.Width, collisionSize.Height, Global.Tags.Wall));

            this.breakable = breakable;
            Collider.SetPosition(-collisionSize.X, -collisionSize.Y); // This is wrong but it's easier

            AddComponent(new YSort());
        }
Exemple #12
0
        /// <summary>
        /// Creates the enemy depending on his Options
        /// </summary>
        /// <param name="x">The Spawn X Coordinate (Middle)</param>
        /// <param name="y">The Spawn Y Coordinate (Middle)</param>
        /// <param name="minx">The minimal X (for moving to the left and the right)</param>
        /// <param name="maxx">The maximal X (for moving to the left and the right)</param>
        public Enemy(int x, int y, int minx, int maxx, int level)
            : base(x, 0)
        {
            // Koordianten. Ursprung und minimal und Maximal Position
            this.SpawnX = x;
            this.SpawnY = y;
            this.MinX   = minx;
            this.MaxX   = maxx;
            // Höhe und Breite festlegen
            this.Width  = Dimensions.ENEMY_WIDTH;
            this.Height = Dimensions.ENEMY_HEIGHT;
            this.Y     -= Game.Instance.Height;
            // Healthbar
            this.HealthBarBackground = Image.CreateRectangle(this.Width, 5, Color.White);
            //this.HealthBarValue = Image.CreateRectangle(this.Width, 5, Color.Red);
            //
            this.weapon.SetBotWeapon(true);

            // X Bwegung
            speed.X = Rand.Float(0.1f, level * 0.1f);
            if (speed.X > 3.0)
            {
                speed.X = 3.0f;
            }
            speed.Y = 0.1f;

            if (rand.Next(1, 2) == 1)
            {
                this.MovingDirection = (int)MovingDirectons.DIR_LEFT;
            }
            else
            {
                this.MovingDirection = (int)MovingDirectons.DIR_RIGHT;
            }

            this.Level = level;
            //graphic = Image.CreateRectangle(this.Width, this.Height, Color.Red);
            graphic.CenterOrigin();
            SetGraphic(graphic);

            // Health
            this.CurrentHealth = level * Global.DAMAGE_ENEMY_LIVE_PER_LEVEL;
            this.MaximalHealth = this.CurrentHealth;

            // Create the Collidor
            BoxCollider col = new BoxCollider(this.Width, this.Height, (int)Global.HIT_TYPES.ENEMY);

            col.CenterOrigin();
            this.SetCollider(col);
        }
Exemple #13
0
        public virtual void Grow(int value)
        {
            Size   += value;
            Graphic = Image.CreateCircle(Size / 2, SpriteColor);
            Graphic.CenterOrigin();

            if (Size > GrowLimit * 2)
            {
                Die(DyingReason.Overpopulation);
            }
            if (Size > GrowLimit && Global.Herbivores.Count + Global.Predators.Count < Global.CellsLimit)
            {
                Reproduce();
            }
        }
Exemple #14
0
        //Base Player, Instancing with x & y empty will make the player spaw at the center of screen
        public Player(Game currentGame, float posX = 0, float posY = 0, Graphic graphic = null, Collider collider = null, string name = "")
            : base(posX, posY, graphic, collider, name)
        {
            var pX = (int)PlayerSize.X;
            var pY = (int)PlayerSize.Y;

            X = posX == 0 ? currentGame.HalfWidth : 0;
            Y = posY == 0 ? currentGame.HalfHeight : 0;

            ItemPickupSFX = new Sound("PickupItem.wav");
            Collider      = new BoxCollider(pX, pY, Tag.Player);
            Graphic       = graphic ?? Image.CreateRectangle(pX, pY, Color.Blue);

            Graphic.CenterOrigin();
            Collider.CenterOrigin();
        }
Exemple #15
0
        public Bullet(Vector2 direction, Vector2 position, float lifespan, float velocity, int radius, int layer,
                      bool isTrigger = false, Image sprite = null, Collider collider = null)
        {
            X = position.X;
            Y = position.Y;

            Graphic = sprite ?? Image.CreateCircle(radius);
            Graphic.CenterOrigin();
            Collider            = collider ?? new CircleCollider(Graphic.Height);
            Collider.Collidable = !isTrigger;
            Collidable          = !isTrigger;
            Collider.CenterOrigin();

            _direction = direction;
            _speed     = velocity;
            LifeSpan   = lifespan;
            Layer      = layer;
        }
        public Entity_Image(float x, float y, string imagepath, bool init = true) : base(x, y)
        {
            if (init)
            {
                // Create an Image using the path passed in with the constructor
                image = new Image(imagepath);
                {
                    // Center the origin of the Image
                    image.CenterOrigin();
                }
                // Add the Image to the Entity's Graphic list.
                AddGraphic(image);
            }

            Target.X = x;
            Target.Y = y;

            Layer = Helper.Layer_UI;
        }
Exemple #17
0
        private void UpdateState()
        {
            if (Entity.Graphic == null)
            {
                return;
            }

            _shaderSprite ??= Image.CreateRectangle(_sprite.Width, _sprite.Height, Color.White);
            _shaderSprite.CenterOrigin();

            if (!Entity.Graphics.Contains(_shaderSprite))
            {
                _shaderSprite.Shader = _shader;
                Entity.AddGraphic(_shaderSprite);
            }

            if (_input.MouseScreenX > Entity.X - _sprite.HalfWidth &&
                _input.MouseScreenX < Entity.X + _sprite.HalfWidth &&
                _input.MouseScreenY > Entity.Y - _sprite.HalfHeight &&
                _input.MouseScreenY < Entity.Y + _sprite.HalfHeight)
            {
                if (!_isHovered)
                {
                    OnHoverStartEvent?.Invoke();
                }
                _isHovered = true;
                _isPressed = _input.MouseButtonDown(MouseButton.Any);
            }
            else
            {
                if (_isHovered)
                {
                    OnHoverEndEvent?.Invoke();
                }
                _isHovered = false;
            }
        }
Exemple #18
0
 /// <summary>
 /// Set the graphic of the Entity.
 /// </summary>
 public new void SetGraphic(Graphic graphic)
 {
     Graphic = graphic;
     Graphic.CenterOrigin();
 }