Esempio n. 1
0
    static void game()
    {
        //-------------Client code starts here

        var scene  = new Scene();
        var layer1 = new Layer();

        layer1.ClassName = "ObjectsLayer";
        var enemyLayer = new Layer();

        enemyLayer.ClassName = "EnemyLayer";

        var hero = new RenderableObject(new Vec2(400, 300));

        hero.ClassName = "Hero";
        var graph = new Glc.Component.GraphicalComponent.Animation(Glc.Component.GraphicalComponent.AnimationType.Cyclic);

        graph.AddFrame(new SpriteFrame(@"resources\soldier\Soldier1.png", 400));
        graph.AddFrame(new SpriteFrame(@"resources\soldier\Soldier2.png", 400));
        hero.GraphComponent = graph;
        hero.AddComponent(new Glc.Component.Script(@"player.gcs"));

        var bullet = new RenderableObject(new Vec2());

        bullet.ClassName      = "Bullet";
        bullet.GraphComponent = new Glc.Component.GraphicalComponent.Sprite(@"resources\bullet.jpg");
        bullet.AddComponent(new Glc.Component.Script(@"bullet.gcs"));
        bullet.AddComponent(new Glc.Component.Collider(Glc.Component.Collider.Type.Circle).SetRadius(5));
        bullet.IsRenderableAtStart = false;

        Random rand = new Random();

        for (var i = 0; i < 70; ++i)
        {
            var enemy  = new Glc.RenderableObject(new Vec2((float)rand.Next(0, 800), (float)600.54));
            var eGraph = new Glc.Component.GraphicalComponent.Animation(Glc.Component.GraphicalComponent.AnimationType.Cyclic);
            eGraph.AddFrame(new SpriteFrame(@"resources\enemy\enemy1.png", (float)rand.Next(300, 600)));
            eGraph.AddFrame(new SpriteFrame(@"resources\enemy\enemy2.png", (float)rand.Next(300, 600)));
            enemy.GraphComponent = eGraph;
            enemy.AddComponent(new Glc.Component.Collider(Glc.Component.Collider.Type.Rectangle).SetSize(new Vec2(54, 94)));
            enemy.AddComponent(new Glc.Component.Script(@"enemy.gcs"));
            enemyLayer.AddObject(enemy);
        }

        layer1.AddObject(hero);
        layer1.AddObject(bullet);
        scene.AddLayer(enemyLayer);
        scene.AddLayer(layer1);
        Glance.AddScene(scene);
        //-------------Client code ends here
        Glance.Build();

        Console.ReadKey();
    }
Esempio n. 2
0
        private void BossVortexShot(float degree)
        {
            // 砲台の位置を設定する
            asd.Vector2DF cannon3Pos = Position + new asd.Vector2DF(Texture.Size.X / 2.0f, -Texture.Size.Y / 2.0f);
            asd.Vector2DF cannon4Pos = Position + new asd.Vector2DF(-Texture.Size.X / 2.0f, -Texture.Size.Y / 2.0f);

            // 方向ベクトルを宣言する
            asd.Vector2DF dirVector = new asd.Vector2DF(1, 0);

            // 方向ベクトルの大きさを3とする
            dirVector.Length = 3.0f;

            // 方向ベクトルの向きをdegreeに合わせる
            // degreeが0度だと90度(下向き)を指すようにする
            dirVector.Degree = degree + 90;

            // 弾をレイヤーに登録する
            Layer.AddObject(new StraightMovingEnemyBullet(cannon3Pos, dirVector));

            // 方向ベクトルの向きを-degreeに合わせる
            // 左右対称になるように、degreeが0度だと90度(下向き)を指すようにする
            dirVector.Degree = -degree + 90;

            // 弾をレイヤーに登録する
            Layer.AddObject(new StraightMovingEnemyBullet(cannon4Pos, dirVector));
        }
Esempio n. 3
0
        private void BossAroundShot()
        {
            // 砲台の位置を設定する
            asd.Vector2DF cannon1Pos = Position + new asd.Vector2DF(-Texture.Size.X / 2.0f, Texture.Size.Y / 2.0f);
            asd.Vector2DF cannon2Pos = Position + new asd.Vector2DF(Texture.Size.X / 2.0f, Texture.Size.Y / 2.0f);

            // 5方向に弾が出るようにする(偶数の場合、場合分けが必要ですが今回は省略しています)
            int nWay = 5;

            // 方向ベクトルを宣言する
            asd.Vector2DF dirVector = new asd.Vector2DF(1, 0);

            //  方向ベクトルの大きさを3とする
            dirVector.Length = 2.0f;

            // 砲台1からプレイヤーに向く角度を設定する
            float degree = (player.Position - cannon1Pos).Degree;

            // nWayの数だけループする(iが0の時がちょうど真ん中にくるように)
            for (int i = -nWay / 2; i <= nWay / 2; i++)
            {
                // 発射角度を i*10 だけずらす
                dirVector.Degree = degree + i * 10;

                // 砲台1からの弾をレイヤーに登録する
                Layer.AddObject(new StraightMovingEnemyBullet(cannon1Pos, dirVector));
            }

            // 砲台2からプレイヤーに向く角度を設定する
            degree = (player.Position - cannon2Pos).Degree;

            // nWayの数だけループする(iが0の時がちょうど真ん中にくるように)
            for (int i = -nWay / 2; i <= nWay / 2; i++)
            {
                // 発射角度を i*10 だけずらす
                dirVector.Degree = degree + i * 10;

                // 砲台2からの弾をレイヤーに登録する
                Layer.AddObject(new StraightMovingEnemyBullet(cannon2Pos, dirVector));
            }



            // 2つの弾を中心から発射する

            // ボスの中心からプレーヤーに向く角度を設定する
            degree = (player.Position - Position).Degree;

            // 一定の角度ずらす
            dirVector.Degree = degree - 8;

            // 弾をレイヤーに登録
            Layer.AddObject(new StraightMovingEnemyBullet(Position, dirVector));

            // 一定の角度ずらす
            dirVector.Degree = degree + 8;

            // 弾をレイヤーに登録
            Layer.AddObject(new StraightMovingEnemyBullet(Position, dirVector));
        }
Esempio n. 4
0
        //Backwardで壁再生
        protected void RemakeWall <TypeWall, TypeEnemy>(byte axis, TypeWall typeWall, TypeEnemy typeEnemy)
            where TypeWall : Wall
            where TypeEnemy : EnemyRed
        {
            switch (axis)
            {
            case 0:
                typeWall.Position  = new asd.Vector2DF(Position.X, Position.Y - 2 * Program.CellLarge);
                typeEnemy.Position = new asd.Vector2DF(Position.X, Position.Y - Program.CellLarge);
                break;

            case 1:
                typeWall.Position  = new asd.Vector2DF(Position.X + 2 * Program.CellLarge, Position.Y);
                typeEnemy.Position = new asd.Vector2DF(Position.X + Program.CellLarge, Position.Y);
                break;

            case 2:
                typeWall.Position  = new asd.Vector2DF(Position.X, Position.Y + 2 * Program.CellLarge);
                typeEnemy.Position = new asd.Vector2DF(Position.X, Position.Y + Program.CellLarge);
                break;

            case 3:
                typeWall.Position  = new asd.Vector2DF(Position.X - 2 * Program.CellLarge, Position.Y);
                typeEnemy.Position = new asd.Vector2DF(Position.X - Program.CellLarge, Position.Y);
                break;
            }
            Effect effect = new Effect(typeWall.Position);

            effect.Scale = new asd.Vector2DF(Program.CellLarge / 5, Program.CellLarge / 5);
            Layer.AddObject(effect);
            effect.Play();
            Layer.AddObject(typeWall);
            Layer.AddObject(typeEnemy);
        }
Esempio n. 5
0
    protected override void OnAdded()
    {
        Layer.AddObject(Title);
        Layer.AddObject(frame);

        AddChild(Title, asd.ChildManagementMode.Nothing, asd.ChildTransformingMode.Position);
        AddChild(frame, asd.ChildManagementMode.Nothing, asd.ChildTransformingMode.Position);
    }
Esempio n. 6
0
        private void BossLaser()
        {
            // LaserをBossが制御できるように、Laserのインスタンスの情報をBossが持つようにする
            var laserRef = new Laser(player, this);

            // Laserをレイヤーに登録する
            Layer.AddObject(laserRef);
        }
Esempio n. 7
0
        protected void VortexShot(float degree)
        {
            asd.Vector2DF dirVector = new asd.Vector2DF(1, 0);
            dirVector.Degree = degree;
            Layer.AddObject(new StraightMovingEnemyBullet(Position, dirVector));

            asd.Engine.Sound.Play(shotSound);
        }
Esempio n. 8
0
		private static void DistressMethod1()
		{
			VectorDesign design = VectorDesign.Load(@"DistressDesign.PV", VectorDesignFileTypes.Pv);
			design.Render(@"DistressDesign-Method1-Original.PNG", RenderFormats.Png, 96, design.ColourContext, new RGBColour(1.0, 1.0, 1.0), 1.0);

			// Adding distress to a design is simply the following:
			// 1. Create a distress pattern. This can be a bitmap or vector design. 
			//    It is simply white "random" objects on a transparent background.
			// 2. Merge the distress pattern into your existing design.
			//    Some scaling of the distress pattern may be necessary to make it look good.
			// 3. Rendering the merged design.
			//
			// Assumption: the distress pattern is white. This assumes that it will be placed on a white background.
			// If this is not the case, then you should colourize the distress to match the background or use a different distress
			// pattern.

			var designBounds = design.GetBounds();

			{
				VectorDesign distress = VectorDesign.Load(@"DistressPattern.PV", VectorDesignFileTypes.Pv);
				var distressBounds = distress.GetBounds();

				// Move the distress so it's center is at the same location as the design's center
				var translate = Matrix3x2.Translate(designBounds.Center.X - distressBounds.Center.X, designBounds.Center.Y - distressBounds.Center.Y);
				distress.ApplyTransform(translate);

				// Depending on the distress, you may need to scale it.
				// Calculate an appropriate scaling factor based on your use case.
				//var scale = Matrix3x2.Scale(...);
				//distress.ApplyTransform(scale);

				var distressFirstPage = distress.Pages.First();
				var distressFirstLayer = distressFirstPage.Layers.First();

				// Create a new group object for the distress pattern so we can clip it
				GroupObject distressGroup = new GroupObject();

				foreach (var obj in distressFirstLayer.Objects)
				{
					distressGroup.AddObject(obj);
				}

				// Optional: Clip the distress to the bounding box of the design
				ClipObjectTo(distressGroup, designBounds);

				// Create a new layer for the distress and add the group object to it.
				// Finally, add that new layer to the first page of our design.
				Layer distressLayer = new Layer()
				{
					Name = "Distress" // Not required
				};
				distressLayer.AddObject(distressGroup);
				design.Pages.First().AddLayer(distressLayer);
			}

			// Render on a white background
			design.Render(@"DistressDesign-Method1-Final.PNG", RenderFormats.Png, 96, design.ColourContext, new RGBColour(1.0, 1.0, 1.0), 1.0);
		}
Esempio n. 9
0
 protected override void OnUpdate()
 {
     count++;
     if (count == 10)
     {
         Layer.AddObject(new ObjectAddingObject());
         Console.WriteLine("vanish object.");
         Vanish();
     }
 }
Esempio n. 10
0
 protected override void OnDispose()
 {
     if (!GeneralStage.IsStageMaking)
     {
         Effect effect = new Effect(Position);
         effect.Scale = new asd.Vector2DF(Program.CellLarge / 5, Program.CellLarge / 5);
         Layer.AddObject(effect);
         effect.Play();
     }
 }
Esempio n. 11
0
 public override void Redo()
 {
     if (!IsAdd)
     {
         Layer.RemoveObject(Object2D);
     }
     else
     {
         Layer.AddObject(Object2D);
     }
 }
Esempio n. 12
0
        // 衝突時の動作(子クラスでoverrideが可能)
        public override void OnCollide(CollidableObject obj)
        {
            // このインスタンスと同じ位置にエフェクトインスタンスを生成して、エンジンに追加する。
            Layer.AddObject(new BreakObjectEffect(Position));

            asd.Engine.Sound.Play(deathSound);
            // ゲームからオブジェクトを消滅させる
            Dispose();

            // スコアを加算
            var scene = (GameScene)Layer.Scene;

            scene.Score += 1;
        }
Esempio n. 13
0
 public override void OnLeftClicked()
 {
     if (!IsFragged)
     {
         noDetected = true;
         if (mines == 0)
         {
             BundleBreak();
         }
         //文字を追加し自身を削除
         Layer.AddObject(new Character(CellPosition));
         Dispose();
     }
 }
Esempio n. 14
0
        public static void AddWaterOverlays(Layer waterLayer, Layer solidLayer)
        {
            Rectangle[] waterSections = FindWaterSections(waterLayer).ToArray();

            List <WaterBlock> waterBlocks = new List <WaterBlock>();

            foreach (var rectangle in waterSections)
            {
                var waterBlock = new WaterBlock(solidLayer, rectangle);
                waterBlocks.Add(waterBlock);
                solidLayer.AddObject(waterBlock);
            }

            new WaterCollisionDetector(solidLayer, waterBlocks);
        }
Esempio n. 15
0
        private void Fire()
        {
            fireCount++;
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Z) == asd.KeyState.Push && fireCount > 20)
            {
                // Play SE
                asd.SoundSource shot = asd.Engine.Sound.CreateSoundSource("shot.ogg", true);

                int id_shot = asd.Engine.Sound.Play(shot);

                var bullet = new PlayerBullet
                {
                    Position = Position + new asd.Vector2DF(40, 0)
                };

                Layer.AddObject(bullet);
                fireCount = 0;
            }
        }
Esempio n. 16
0
        void Fire()
        {
            if (player.IsAlive)
            {
                fireCount++;
                if (fireCount == 180)
                {
                    fireCount = 0;

                    var dir = player.Position - Position;

                    var bullet = new EnemyBullet(dir)
                    {
                        Position = Position
                    };

                    Layer.AddObject(bullet);
                }
            }
        }
Esempio n. 17
0
 protected override void OnStart()
 {
     Layer.AddObject(Title);
     Layer.AddObject(frame);
 }
Esempio n. 18
0
 public override void OnCollide(CollidableObject obj)
 {
     Layer.AddObject(new BreakObjectEffect(Position));
     Dispose();
 }
Esempio n. 19
0
        protected override void OnUpdate()
        {
            foreach (var obj in Layer.Objects)
            {
                CollideWith(obj as CollidableObject);
            }

            // もし、上ボタンが押されていたら、位置に(0,-1)を足す。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Up) == asd.ButtonState.Hold)
            {
                Position = Position + new asd.Vector2DF(0, -3);
            }
            // もし、下タンが押されていたら、位置に(0,-1)を足す。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Down) == asd.ButtonState.Hold)
            {
                Position = Position + new asd.Vector2DF(0, 3);
            }
            // もし、右ボタンが押されていたら、位置に(0,-1)を足す。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Right) == asd.ButtonState.Hold)
            {
                Position = Position + new asd.Vector2DF(3, 0);
            }
            // もし、左ボタンが押されていたら、位置に(0,-1)を足す。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Left) == asd.ButtonState.Hold)
            {
                Position = Position + new asd.Vector2DF(-3, 0);
            }

            // もし、Zキーを押したら{}内の処理を行う。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.Z) == asd.ButtonState.Push)
            {
                Bullet bullet = new Bullet(Position + new asd.Vector2DF(0, -30), "PlayerBullet.png");
                // 弾のインスタンスをエンジンに追加する。
                Layer.AddObject(bullet);

                // ショットの効果音を再生する。
                asd.Engine.Sound.Play(shotSound);
            }

            //もしXキーが押されたら、大きい弾を発射する。
            if (asd.Engine.Keyboard.GetKeyState(asd.Keys.X) == asd.ButtonState.Push)
            {
                for (int i = 0; i < 24; i++)
                {
                    // ボムを生成
                    Bomb bomb = new Bomb(Position, 360 / 24 * i);

                    // ボム オブジェクトをエンジンに追加
                    asd.Engine.AddObject2D(bomb);
                }
                asd.Engine.Sound.Play(bombSound);
            }

            // プレイヤーの位置を取得する。
            asd.Vector2DF position = Position;

            // プレイヤーの位置を、(テクスチャの大きさ/2)~(ウインドウの大きさ-テクスチャの大きさ/2)の範囲に制限する。
            position.X = asd.MathHelper.Clamp(position.X, asd.Engine.WindowSize.X - Texture.Size.X / 2.0f, Texture.Size.X / 2.0f);

            position.Y = asd.MathHelper.Clamp(position.Y, asd.Engine.WindowSize.Y - Texture.Size.Y / 2.0f, Texture.Size.Y / 2.0f);

            // プレイヤーの位置を設定する。
            Position = position;
        }