コード例 #1
0
ファイル: Hero.cs プロジェクト: alexhg128/ZeldaRecreation
        public override void OnResize()
        {
            base.OnResize();
            s.Location = new System.Drawing.Point((int)this.absoluteCOORD.X, (int)this.absoluteCOORD.Y);
            COORD boxSize = COORD.GetBoxSize(panel);

            s.Height = (int)boxSize.Y;
            s.Width  = (int)boxSize.X;
        }
コード例 #2
0
        public Enemy(COORD casilla, Panel panel, PictureBox s, Form1 instance, int damage, int live) : base(casilla, panel)
        {
            this.s = s;
            COORD AbsoluteCOORD = COORD.GetCasillaCoords(panel, casilla);

            s.Left        = (int)AbsoluteCOORD.X + ((int)COORD.GetBoxSize(panel).X / 10);
            s.Top         = (int)AbsoluteCOORD.Y - ((int)COORD.GetBoxSize(panel).X / 7);;
            this.panel    = panel;
            this.instance = instance;
            this.damage   = damage;
            this.live     = live;
        }
コード例 #3
0
ファイル: Hero.cs プロジェクト: alexhg128/ZeldaRecreation
        public void Move(EDirection direction)
        {
            int destination;

            switch (direction)
            {
            case EDirection.Down:
                this.direction = EDirection.Down;
                destination    = (int)RelativeCOORD.Y + 1;
                if (destination <= 9)
                {
                    this.destination = new COORD(RelativeCOORD.X, destination);
                    List <Object> ob = instance.plane.FindAtCOORD(this.destination);
                    if (ob.Count != 0)
                    {
                        Collision(ob);
                    }
                    else
                    {
                        RelativeCOORD.Y = destination;
                        s.Top          += (int)COORD.GetBoxSize(panel).Y;
                    }
                    s.BackgroundImage = Properties.Resources.hero_down;
                }
                return;

            case EDirection.Up:
                this.direction = EDirection.Up;
                destination    = (int)RelativeCOORD.Y - 1;
                if (destination >= 1)
                {
                    this.destination = new COORD(RelativeCOORD.X, destination);
                    List <Object> ob = instance.plane.FindAtCOORD(this.destination);
                    if (ob.Count != 0)
                    {
                        Collision(ob);
                    }
                    else
                    {
                        RelativeCOORD.Y = destination;
                        s.Top          -= (int)COORD.GetBoxSize(panel).Y;
                    }
                    s.BackgroundImage = Properties.Resources.hero_up;
                }
                return;

            case EDirection.Right:
                this.direction = EDirection.Right;
                destination    = (int)RelativeCOORD.X + 1;
                if (destination <= 16)
                {
                    this.destination = new COORD(destination, RelativeCOORD.Y);
                    List <Object> ob = instance.plane.FindAtCOORD(new COORD(destination, RelativeCOORD.Y));
                    if (ob.Count != 0)
                    {
                        Collision(ob);
                    }
                    else
                    {
                        RelativeCOORD.X = destination;
                        s.Left         += (int)COORD.GetBoxSize(panel).X;
                    }

                    s.BackgroundImage = Properties.Resources.hero_right;
                }
                return;

            case EDirection.Left:
                destination    = (int)RelativeCOORD.X - 1;
                this.direction = EDirection.Left;
                if (destination >= 1)
                {
                    this.destination = new COORD(destination, RelativeCOORD.Y);
                    List <Object> ob = instance.plane.FindAtCOORD(this.destination);
                    if (ob.Count != 0)
                    {
                        Collision(ob);
                    }
                    else
                    {
                        RelativeCOORD.X = destination;
                        s.Left         -= (int)COORD.GetBoxSize(panel).X;
                    }
                    s.BackgroundImage = Properties.Resources.hero_left;
                }
                return;
            }
        }