Пример #1
0
    // Use this for initialization
    public DualScreen()
    {
        MapModel mapModel = MapCache.GetInstance().GetModel();

        this.topWindow = new TopWindow(mapModel);
        this.topWindow.LocalPosition = new Vector2(0, -1.5f);

        this.bottomWindow = new BottomWindow(mapModel);

        Roga2dNode frame = new Roga2dNode();
        this.AddChild(frame);

        // Set up Frame
        Roga2dSprite mainWindow = new Roga2dSprite("UI/frame", new Vector2(160, 240), new Vector2(0, 0), new Rect(0, 0, 160, 240));
        frame.AddChild(mainWindow);

        // Connect PreviewWindow and ControlWindow
        this.bottomWindow.MessageEvent += this.bottomWindow.ReceiveMessage;
        this.bottomWindow.MessageEvent += this.topWindow.ReceiveMessage;

        this.topWindow.MessageEvent += this.bottomWindow.ReceiveMessage;
        this.topWindow.MessageEvent += this.topWindow.ReceiveMessage;

        this.lastTouchedPosition = InvalidTouchPosition;
    }
Пример #2
0
    public static void TestAddRemove()
    {
        Roga2dNode node1 = new Roga2dNode();
        Roga2dNode node2 = new Roga2dNode();

        node1.LocalPosition = new Vector2(5, 5);
        node1.LocalRotation = 50.0f;
        node1.LocalScale = new Vector2(3, 2);

        node2.LocalPosition = new Vector2(10, 10);
        node2.LocalRotation = 100.0f;
        node2.LocalScale = new Vector2(5, 4);

        Tester.Match(node1.ChildrenCount, 0);

        node1.AddChild(node2);
        Tester.Match(node1.ChildrenCount, 1);
        Tester.Match(node1, node2.Parent);

        // Check parent node transform is as expected
        Tester.Match(node1.LocalPosition, new Vector2(5, 5));
        Tester.Match(node1.LocalRotation, 50.0f);
        Tester.Match(node1.LocalScale, new Vector2(3, 2));

        // Check child node transform is as expected
        Tester.Match(node2.LocalPosition, new Vector2(10, 10));
        Tester.Match(node2.LocalRotation, 100.0f);
        Tester.Match(node2.LocalScale, new Vector2(5, 4));

        node1.RemoveChild(node2);
        Tester.Match(node1.ChildrenCount, 0);

        node1.Destroy();
    }
 public void Play(Roga2dNode root, Transform spawnTransform, Roga2dAnimation animation, Roga2dAnimationFinishCallback finishCallback)
 {
     if (root != null) {
         root.AddChild(animation.Node);
     }
     if (spawnTransform != null) {
         animation.Node.Transform.position = spawnTransform.position;
         animation.Node.Transform.rotation = spawnTransform.rotation;
     }
     animation.finishCallback = finishCallback;
     this.animations.Add(animation);
 }
Пример #4
0
    public static void TestAddRemoveAll()
    {
        Roga2dNode node1 = new Roga2dNode();
        Roga2dNode node2 = new Roga2dNode();

        Tester.Match(node1.ChildrenCount, 0);

        node1.AddChild(node2);
        Tester.Match(node1.ChildrenCount, 1);
        Tester.Match(node1, node2.Parent);

        node1.RemoveAllChildren();
        Tester.Match(node1.ChildrenCount, 0);

        node1.Destroy();
    }
Пример #5
0
    public static void TestAddRemove()
    {
        Roga2dNode node = new Roga2dNode();
        Roga2dRenderObject renderObject = new Roga2dRenderObject(null, new Vector2(64, 64), new Vector2(32, 16), new Rect(0, 0, 1, 1));
        Roga2dSprite sprite = new Roga2dSprite(renderObject);

        Tester.Match(node.ChildrenCount, 0);

        node.AddChild(sprite);
        Tester.Match(node.ChildrenCount, 1);
        node.Update();

        node.RemoveAllChildren();
        Tester.Match(node.ChildrenCount, 0);

        node.Destroy();
    }
Пример #6
0
        // Build animation for damage pop
        public Roga2dAnimation BuildDamagePopAnimation(Vector2 position, uint value)
        {
            Roga2dNode node = new Roga2dNode("Damage");
            List<uint> digits = Utils.getDigits(value);
            position.x -= (10 * digits.Count) / 2;
            node.LocalPixelPosition = position;
            node.LocalPriority = 1.0f;

            List<Roga2dBaseInterval> popIntervals = new List<Roga2dBaseInterval>();
            for (int i = 0; i < digits.Count; i++) {
                uint no = digits[i];
                // Get Font Image
                Roga2dSprite sprite = new Roga2dSprite("Font/number_font", new Vector2(7, 10), new Vector2(0, 0), new Rect(no * 7, 0, 7, 10));
                // X-coordinate each digit pop
                int popX = i * 10;
                // Init state
                sprite.LocalAlpha = 0.0f;
                sprite.LocalPosition = Roga2dUtils.pixelToLocal(new Vector2(popX, 0));
                // Add to parent
                node.AddChild(sprite);

                Roga2dBaseInterval interval = new Roga2dSequence(
                    new List<Roga2dBaseInterval>() {
                        new Roga2dWait(Roga2dUtils.TimeToFrame(i * 0.05f)),
                        new Roga2dAlphaInterval(sprite, 1.0f, 1.0f, Roga2dUtils.TimeToFrame(0.05f), false),
                        new Roga2dPositionInterval(sprite, Roga2dUtils.pixelToLocal(new Vector2(popX, 0)), Roga2dUtils.pixelToLocal(new Vector2(popX, -30)), Roga2dUtils.TimeToFrame(0.1f), true, null)
                        // TODO: destroy damage effects
                    }
                );

                popIntervals.Add(interval);
            }

            Roga2dBaseInterval resultInterval = new Roga2dSequence(new List<Roga2dBaseInterval>() {
                new Roga2dParallel(popIntervals),
                new Roga2dWait(5)
            });

            return Roga2dAnimation.Build(node, resultInterval);
        }
Пример #7
0
    public static void TestVisibility()
    {
        Roga2dNode node1 = new Roga2dNode();
        Roga2dNode node2 = new Roga2dNode();

        node1.Hide();
        Tester.Match(node1.IsVisible, false);

        node1.AddChild(node2);
        Tester.Match(node2.IsVisible, false);

        node1.Hide();
        Tester.Match(node1.IsVisible, false);
        Tester.Match(node2.IsVisible, false);

        node1.Show();
        Tester.Match(node1.IsVisible, true);
        Tester.Match(node2.IsVisible, true);

        node1.Destroy();
        node2.Destroy();
    }
Пример #8
0
    public static void TestUpdate()
    {
        Roga2dNode node = new Roga2dNode();
        Roga2dNode child = new Roga2dNode();

        node.LocalAlpha = 0.3f;
        node.LocalPriority = 0.4f;
        node.LocalPosition = new Vector2(1.0f, 2.0f);
        node.LocalRotation = 3.0f;
        node.LocalScale = new Vector2(-1.0f, -2.0f);

        child.LocalAlpha = 0.3f;
        child.LocalPriority = 0.4f;
        node.AddChild(child);

        // Before transform
        Tester.Match(node.Alpha, 1.0f);
        Tester.Match(node.Priority, -999.0f);
        Tester.Match(child.Alpha, 1.0f);
        Tester.Match(child.Priority, -999.0f);

        node.Update();
        // After transform
        Tester.Match(node.Transform.localPosition, new Vector3(1.0f, 2.0f, 0.4f));
        Tester.Match(node.Transform.localEulerAngles, new Vector3(0.0f, 0.0f, 3.0f));
        Tester.Match(node.Transform.localScale, new Vector3(-1.0f, -2.0f, 1.0f));
        Tester.Match(node.Transform, child.Transform.parent);
        Tester.Match(node.Alpha, 0.3f);
        Tester.Match(node.Priority, 0.4f);
        Tester.Match(child.Alpha, 0.09f);
        Tester.Match(child.Priority, 0.8f);

        node.Destroy();
    }