Beispiel #1
0
        public override void OnMouseButtonReleased(MouseButton button, float x, float y)
        {
            var pos = Graphics2D.GetInstance ().GetMousePosition ();
            if (button == MouseButton.Left) {
                x = Math.Min (start.X, pos.X);
                y = Math.Min (start.Y, pos.Y);
                var width = (int)MyMath.Clamp (Math.Abs (pos.X - start.X), 2, 1200);
                var height = (int)MyMath.Clamp (Math.Abs (pos.Y - start.Y), 2, 1800);

                var mycol = new BoxCollision (width / 2, height / 2, 0);
                mycol.SetOffset (x + width / 2, y + height / 2, 0);
                var mytra = Node.GlobalTransform;

                var tanks = from node in World.Downwards
                            where node.Name == "MyTank"
                            let tank = node.GetComponent<MyTank> ()
                            let col = node.GetComponent<Collision> ()
                            let tra = node.GlobalTransform
                            where col != null
                            where Physics2D.Distance (col, tra, mycol, mytra) == 0
                            select tank;
                foreach (var tank in tanks) {
                    tank.Selected = true;
                }

                this.start = new Vector2 (0, 0);
                Node.Drawable = false;
            }
        }
Beispiel #2
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyDeadBox ();

            var spr = new Sprite (128, 128);
            spr.AddTexture (new Texture ("media/Image128x128(Red).png"));
            spr.Color = Color.Gray;

            var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0);
            col.SetOffset (spr.Width / 2, spr.Height / 2, 0);

            var body = new PhysicsBody ();
            body.Shape = col;
            body.IsTrigger = true;

            var node = new Node ("DeadBox");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);
            node.Attach (body);

            node.Translation  = pos;

            return node;
        }
Beispiel #3
0
        public static Node Create(int slot, Node charNode, Node tankNode)
        {
            var cha = charNode.GetComponent<MyCharacter> ();
            var tank = tankNode.GetComponent<MyTank> ();
            var cmp = new MyCard ();

            cmp.tank = tankNode;
            cmp.character = charNode;

            // 背景
            var spr1 = new Sprite (256, 128);
            spr1.Color = Color.Gray;

            // 顔
            var spr2 = new Sprite (128, 128);
            spr2.AddTexture (cha.FaceTexture);

            // 戦車
            var spr3 = new Sprite (32, 64);
            spr3.AddTexture (tank.TankTexture);
            spr3.SetOffset (128 + 6, 6);

            // 戦車名
            var label1 = new Label ();
            label1.Text = tank.TankName;
            label1.SetOffset (128 + 6 + 32 + 6, 6);

            // HP
            var hp = new Bar (4, 96, BarOrientation.Horizontal);
            hp.MaxValue = tank.MaxHp;
            hp.CurrentValue = tank.Hp;
            hp.SetOffset (128 + 6, 64 + 6);

            // クリック
            var col = new BoxCollision (128, 64, 0);
            col.SetOffset (128, 64, 0);

            var node = new Node ("Card");
            node.Attach (cmp);
            node.Attach (spr1);
            node.Attach (spr2);
            node.Attach (spr3);
            node.Attach (label1);
            node.Attach (hp);
            node.Attach (col);

            node.DrawPriority = -10;

            node.Translate (12+(256+4)*slot, 600, 0);

            // キャラクター -> マイカード
            cha.MyCard = node;

            return node;
        }
Beispiel #4
0
        public static Node Create()
        {
            var cmp = new MyBackground ();
            var spr = new Sprite (1200, 1800);
            spr.AddTexture (Resource.GetTexture ("media/Background-Glass.png"));

            var col = new BoxCollision (spr.Width/2, spr.Height/2, 0);
            col.SetOffset (spr.Width/2, spr.Height/2, 0);

            var node = new Node ("Ground");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);
            node.DrawPriority = 1;

            return node;
        }
Beispiel #5
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyGoal ();

            var spr = new Sprite (128, 128);
            spr.AddTexture (Resource.GetDefaultTexture ());
            spr.Color = Color.Blue;

            var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0);
            col.SetOffset (spr.Width / 2, spr.Height / 2, 0);

            var node = new Node ("Goal");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);

            node.Translation = pos;

            return node;
        }
Beispiel #6
0
        public static Node Create()
        {
            var cmp = new MyMouseSelector ();

            var spr = new Sprite (1, 1);
            spr.AddTexture (new Texture ("media/image128x128(Purple).png"));
            spr.SetColor (255, 255, 255, 64);

            var col = new BoxCollision (600, 900, 0);
            col.SetOffset (600, 900, 0);

            var node = new Node ("MouseSelector");
            node.Attach (cmp);
            node.Attach (spr);
            node.Attach (col);
            node.DrawPriority = -1;

            node.Drawable = false;

            return node;
        }
Beispiel #7
0
        private static Node CreateFloor(string name, int x, int y, int width, int height, Quaternion rot)
        {
            var spr = new Sprite (width, height);
            spr.AddTexture (Resource.GetTexture ("media/Rectangle-160x40.png"));

            var col = new BoxCollision (spr.Width / 2, spr.Height / 2, 0);
            col.SetOffset (spr.Width / 2, spr.Height / 2, 0);

            var body = new PhysicsBody ();
            var mat = new PhysicsMaterial ();
            body.Shape = col;
            body.Material = mat;

            var node = new Node (name);
            node.SetTranslation (x, y, 0);
            node.SetRotation (rot);
            node.Attach (spr);
            node.Attach (col);
            node.Attach (body);

            return node;
        }
Beispiel #8
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyCharacter ();

            var spr1 = new Sprite (new Texture ("media/Character-Gelato.png"), 24, 32);
            var spr2 = new Sprite (new Texture ("media/Image128x128(Red).png"), 24, 4);
            spr2.SetOffset (0, spr1.Height);

            var body = new BoxCollision (spr1.Width / 2, spr1.Height / 2, 0);
            var foot = new SphereCollision (2);
            body.SetOffset (spr1.Width / 2, spr1.Height / 2, 0);
            foot.SetOffset (spr1.Width / 2, spr1.Height + 2, 0);

            var node = new Node ("MyCharacter");
            node.Attach (spr1);
            node.Attach (spr2);
            node.Attach (body);
            node.Attach (foot);
            node.Attach (cmp);

            node.DrawPriority = -1;
            node.Translation = pos;

            cmp.jumpSound = new SoundClip ("JumpSound");
            cmp.jumpSound.AddTrack (new SoundEffectTrack ("media/Jump.ogg"));

            var track1 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track1.AddKeyframe (0, new Vector2 (0, 64));
            track1.AddKeyframe (300, new Vector2 (24, 64));
            track1.AddKeyframe (600, new Vector2 (48, 64));
            cmp.walkDown = new AnimationClip (900, "MyCharacter.Down");
            cmp.walkDown.AddTrack (spr1, track1);

            var track2 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track2.AddKeyframe (0, new Vector2 (0, 0));
            track2.AddKeyframe (300, new Vector2 (24, 0));
            track2.AddKeyframe (600, new Vector2 (48, 0));
            cmp.walkUp = new AnimationClip (900, "MyCharacter.Up");
            cmp.walkUp.AddTrack (spr1, track2);

            var track3 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track3.AddKeyframe (0, new Vector2 (0, 32));
            track3.AddKeyframe (300, new Vector2 (24, 32));
            track3.AddKeyframe (600, new Vector2 (48, 32));
            cmp.walkRight = new AnimationClip (900, "MyCharacter.Right");
            cmp.walkRight.AddTrack (spr1, track3);

            var track4 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track4.AddKeyframe (0, new Vector2 (0, 96));
            track4.AddKeyframe (300, new Vector2 (24, 96));
            track4.AddKeyframe (600, new Vector2 (48, 96));
            cmp.walkLeft = new AnimationClip (900, "MyCharacter.Left");
            cmp.walkLeft.AddTrack (spr1, track4);

            return node;
        }