コード例 #1
0
        public override void Update(KeyMapping _kmp, Scene _sce)
        {
            if (_kmp.IsPressed(Joypad.A))
                this.IsTriggered = true;

            base.Update(_kmp, _sce);

            if (!this.IsTriggered)
                this.pos.X = ((MainGameScene)_sce).GetPlayer().pos.X + 10;
        }
コード例 #2
0
        public override void Update(KeyMapping _kmp, Scene _sce)
        {
            base.Update(_kmp, _sce);

            this.IsDamaged = false;

            if (IsDead)
                this.pos = new Point(-999, -999);

            if (this.BulletCoolDown < 0)
                this.BulletCoolDown = 0;

            if (this.BulletCoolDown > 0)
                this.BulletCoolDown--;

            if (_kmp.IsPressing(Joypad.Left))
                if (this.pos.X - BaseStep > 0)
                    this.pos.X -= BaseStep;
                else
                    this.pos.X = 0;

            if (_kmp.IsPressing(Joypad.Right))
                if (this.pos.X + BaseStep + this.box.Width < MainScreen.Width   )
                    this.pos.X += BaseStep;
                else
                    this.pos.X = MainScreen.Width    - this.box.Width;

            if (_kmp.IsPressing(Joypad.Up))
                if (this.pos.Y - BaseStep > 0)
                    this.pos.Y -= BaseStep;
                else
                    this.pos.Y = 0;

            if (_kmp.IsPressing(Joypad.Down))
                if (this.pos.Y + BaseStep + this.box.Height < MainScreen.Height)
                    this.pos.Y += BaseStep;
                else
                    this.pos.Y = MainScreen.Height - this.box.Height;

            if (this.BulletCoolDown == 0 && _kmp.IsPressing(Joypad.A))
            {
                if (this.WeaponList[this.WeaponType] == "N")
                {
                    _sce.AddGameObject(new PC_WeaponN(new Point(this.pos.X + 5, this.pos.Y)));
                    this.BulletCoolDown = 5;
                }
                else if (this.WeaponList[this.WeaponType] == "L")
                {
                    _sce.AddGameObject(new PC_WeaponL(new Point(0, this.pos.Y)));
                    this.BulletCoolDown = 1;
                }
                else if (this.WeaponList[this.WeaponType] == "W")
                {
                    _sce.AddGameObject(new PC_WeaponW(new Point(this.pos.X + 10, this.pos.Y)));
                    this.BulletCoolDown = 2;

                }
            }

            if(_kmp.IsPressed(Joypad.X))
            {
                this.WeaponType--;
                if (this.WeaponType < 0)
                    this.WeaponType += this.WeaponList.GetLength(0);

                if (this.WeaponType >= this.WeaponList.GetLength(0))
                    this.WeaponType -= this.WeaponList.GetLength(0);
            }

            if (_kmp.IsPressed(Joypad.Y))
            {
                this.WeaponType--;
                if (this.WeaponType < 0)
                    this.WeaponType += this.WeaponList.GetLength(0);

                if (this.WeaponType >= this.WeaponList.GetLength(0))
                    this.WeaponType -= this.WeaponList.GetLength(0);
            }
        }
コード例 #3
0
        public override void Update(KeyMapping _kmp)
        {
            if(_kmp.IsPressed(Joypad.Start))
            {
                this.GetPlayer().pos = new Point(0, 440);
                this.GetPlayer().Life = this.GetPlayer().MaxLife;
            }

            base.Update(_kmp);

            BuildTree();

            foreach(GameObject gobj in this.SceneObjList)
            {
                if (gobj.TAG == "KeyDisplayer")
                    continue;

                List<GameObject> CollisionList = this.ObjTree.Retrieve(new List<GameObject>(), (Box)gobj);

                foreach (Box col_gobj in CollisionList)
                {
                    if (AABB.IsCollision(((Box)gobj).pos, ((Box)gobj).box, col_gobj.pos, col_gobj.box))
                    {
                        ((Box)gobj).CollisionWith(col_gobj);
                        col_gobj.CollisionWith((Box)gobj);
                    }
                }
            }
        }