コード例 #1
0
ファイル: Hero.cs プロジェクト: alexhg128/ZeldaRecreation
        public Hero(COORD casilla, Panel panel, PictureBox s, Form1 instance) : base(new COORD(8, 2), panel)
        {
            this.s = s;
            COORD AbsoluteCOORD = COORD.GetCasillaCoords(panel, new COORD(8, 2));

            s.Left          = (int)AbsoluteCOORD.X;
            s.Top           = (int)AbsoluteCOORD.Y;
            this.panel      = panel;
            aTimer          = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(Unattack);
            aTimer.Interval = 100;
            this.instance   = instance;
            direction       = EDirection.Down;
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: Hero.cs プロジェクト: alexhg128/ZeldaRecreation
        public void Relocate(COORD Casilla)
        {
            COORD Absolute = COORD.GetCasillaCoords(panel, Casilla);

            s.Location = new System.Drawing.Point((int)Absolute.X, (int)Absolute.Y);
        }
コード例 #4
0
 public List <Object> FindAtCOORD(COORD coord)
 {
     return(objects.FindAll(x => x.RelativeCOORD.Equals(coord)));
 }
コード例 #5
0
ファイル: Object.cs プロジェクト: alexhg128/ZeldaRecreation
 public virtual void OnResize()
 {
     absoluteCOORD = COORD.GetCasillaCoords(panel, relativeCOORD);
 }
コード例 #6
0
ファイル: Object.cs プロジェクト: alexhg128/ZeldaRecreation
 public Object(COORD relative, Panel panel)
 {
     RelativeCOORD = relative;
     this.panel    = panel;
 }