コード例 #1
0
ファイル: CClimberLanding.cs プロジェクト: mzaman07/kot-mono
 public override void init(string name, Vector2 position, string dataType, int compAddress, params string[] additional)
 {
     base.init(name, position, dataType, compAddress, additional);
     additional[1] = "16";
     _hitBox       = new CHitBox(this, 0, 0, Convert.ToInt32(additional[0]), 8);
     _moveToLayer  = 3;
 }
コード例 #2
0
        public override void init(string name, Vector2 position, string dataType, int compAddress, params string[] additional)
        {
            base.init(name, position, dataType, compAddress, additional);
            _width  = Convert.ToInt32(additional[0]);
            _height = Convert.ToInt32(additional[1]);
            _hitBox = new CHitBox(this, 0, 0, _width, _height);

            //determine corner angles and magnitudes
            Vector2 center = _hitBox.center + position;

            _angleTopLeft     = MathExt.MathExt.angle(center, position);
            _angleTopRight    = MathExt.MathExt.angle(center, position + new Vector2(_width, 0));
            _angleBottomRight = MathExt.MathExt.angle(center, position + new Vector2(_width, _height));
            _angleBottomLeft  = MathExt.MathExt.angle(center, position + new Vector2(0, _height));

            _distToTopLeft     = MathExt.MathExt.distance(center, position);
            _distToTopRight    = MathExt.MathExt.distance(center, _position + new Vector2(_width, 0));
            _distToBottomRight = MathExt.MathExt.distance(center, _position + new Vector2(_width, _height));
            _distToBottomLeft  = MathExt.MathExt.distance(center, _position + new Vector2(0, _height));

            //calculate triangles
            _leftTri   = MathExt.MathExt.buildTriangle(180.0, _angleBottomLeft - _angleTopLeft, (double)center.X - _width / 2.0, center);
            _rightTri  = MathExt.MathExt.buildTriangle(0, (_angleTopRight + 360) - _angleBottomRight, (double)center.X + _width / 2.0, center);
            _topTri    = MathExt.MathExt.buildTriangle(90.0, _angleTopLeft - _angleTopRight, (double)center.X - _height / 2.0, center);
            _bottomTri = MathExt.MathExt.buildTriangle(270.0, _angleBottomLeft - _angleBottomRight, (double)center.X + _height / 2.0, center);
        }
コード例 #3
0
ファイル: CSolidTile.cs プロジェクト: mzaman07/kot-mono
 public CSolidTile(int x, int y, int width, int height)
     : base()
 {
     _hitBox     = new CHitBox(this, x, y, width, height);
     _width      = width;
     _height     = height;
     _followRoot = false;
 }
コード例 #4
0
ファイル: CLayerChanger.cs プロジェクト: mzaman07/kot-mono
 public override void init(string name, Microsoft.Xna.Framework.Vector2 position, string dataType, int compAddress, params string[] additional)
 {
     base.init(name, position, dataType, compAddress, additional);
     _height  = Convert.ToInt32(additional[1]);
     _width   = Convert.ToInt32(additional[0]);
     _hitBox  = new CHitBox(this, 0, 0, _width, _height);
     _toLayer = Convert.ToInt32(additional[2]);
     _imageIndex.Add(_MAP_ICON, null);
 }
コード例 #5
0
ファイル: CActor.cs プロジェクト: mzaman07/kot-mono
        public virtual void destroy(object sender)
        {
            if (_hitBox != null)
            {
                _hitBox.destroy();
                _hitBox = null;
            }

            Dispose();
        }
コード例 #6
0
ファイル: CVaulter.cs プロジェクト: mzaman07/kot-mono
        public override void init(string name, Vector2 position, string dataType, int compAddress, params string[] additional)
        {
            base.init(name, position, dataType, compAddress, additional);

            _hitBox  = new CHitBox(this, 0, 0, Convert.ToInt32(additional[0]), Convert.ToInt32(additional[1]));
            _airTime = Convert.ToInt32(additional[2]);

            _vaultDirection = new Vector2(Convert.ToInt32(additional[3]), Convert.ToInt32(additional[4]));
            _layerSwap      = Convert.ToInt32(additional[5]);
        }
コード例 #7
0
ファイル: CSolidTile.cs プロジェクト: mzaman07/kot-mono
        public override void init(string name, Microsoft.Xna.Framework.Vector2 position, string dataType, int compAddress, params string[] additional)
        {
            base.init(name, position, dataType, compAddress, additional);

            if (additional != null)
            {
                _hitBox = new CHitBox(this, 0, 0, Convert.ToInt32(additional[0]), Convert.ToInt32(additional[1]));
                _width  = (int)(_hitBox.halfWidth * 2f);
                _height = (int)(_hitBox.halfHeight * 2f);
            }

            _imageIndex.Add("debug:redBox", new Graphics.CSprite("debug:redBox"));
        }
コード例 #8
0
ファイル: CActor.cs プロジェクト: mzaman07/kot-mono
        protected void solidCollide(CActor collider, bool knockBack = false)
        {
            //Calculate How much to move to get out of collision moving towards last collisionless point
            Collision.CHitBox otherbox = collider.hitBox;

            //Calculate how far in we went
            float distx = (collider.position.X + otherbox.center.X) - (position.X + hitBox.center.X);

            distx = (float)Math.Sqrt(distx * distx);
            float disty = (position.Y + hitBox.center.Y) - (collider.position.Y + otherbox.center.Y);

            disty = (float)Math.Sqrt(disty * disty);

            float lenx = hitBox.halfWidth + otherbox.halfWidth;
            float leny = hitBox.halfHeight + otherbox.halfHeight;

            int px = 1;
            int py = 1;

            if (collider.position.X + otherbox.center.X < position.X + hitBox.center.X)
            {
                px = -1;
            }
            if (collider.position.Y + otherbox.center.Y < position.Y + hitBox.center.Y)
            {
                py = -1;
            }

            float penx = px * (distx - lenx);
            float peny = py * (disty - leny);
            //Resolve closest to previous position
            float diffx = (position.X + penx) - _oldPosition.X;

            diffx *= diffx;
            float diffy = (position.Y + peny) - _oldPosition.Y;

            diffy *= diffy;

            if (!knockBack)
            {
                _escapeCollide(diffx, diffy, penx, peny);
            }
            else
            {
                _knockBack(diffx, diffy, px, py);
            }
        }
コード例 #9
0
ファイル: CHitBox.cs プロジェクト: wildex999/King-of-Thieves
        public bool checkCollision(CActor sender)
        {
            float   distance = 0;
            float   length   = 0;
            CHitBox otherBox = sender.hitBox;

            distance = Math.Abs((actor.position.X + _center.X) - (sender.position.X + otherBox._center.X));
            length   = _halfSize.X + otherBox._halfSize.X;

            if (distance < length)
            {
                distance = Math.Abs((actor.position.Y + _center.Y) - (sender.position.Y + otherBox._center.Y));
                length   = _halfSize.Y + otherBox._halfSize.Y;

                return(distance < length);
            }

            return(false);
        }
コード例 #10
0
ファイル: CMapChanger.cs プロジェクト: mzaman07/kot-mono
 public CMapChanger() :
     base()
 {
     _hitBox = new CHitBox(this, 0, 0, 16, 16);
 }
コード例 #11
0
ファイル: CSolidTile.cs プロジェクト: mzaman07/kot-mono
 public CSolidTile() : base()
 {
     _hitBox     = new CHitBox(this, 0, 0, 16, 16);
     _followRoot = false;
     _width      = 16; _height = 16;
 }
コード例 #12
0
 public CSolidTile() : base()
 {
     _hitBox     = new CHitBox(this, 0, 0, 16, 16);
     _followRoot = false;
 }