public static void TestPlay()
    {
        GameObject gameObject = new GameObject();
        Roga2dAnimationPlayer player = new Roga2dAnimationPlayer();
        Roga2dWait interval = new Roga2dWait(3);
        Roga2dNode node = new Roga2dNode();
        Roga2dAnimation animation = Roga2dAnimation.Build(node, interval);
        player.Play(null, null, animation, AnimationFinished);

        Tester.Ok(!interval.IsDone());

        player.Update();
        Tester.Ok(!interval.IsDone());

        player.Update();
        Tester.Ok(!interval.IsDone());

        player.Update();
        Tester.Ok(!interval.IsDone());

        Tester.Match(testCounter, 0);

        player.Update();
        Tester.Ok(interval.IsDone());
        Tester.Match(testCounter, 999);

        node.Destroy();
        Object.Destroy(gameObject);
    }
예제 #2
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;
    }
예제 #3
0
 // Build interval for red-flash
 public Roga2dBaseInterval BuildDamageInterval(Roga2dNode target)
 {
     List<Roga2dBaseInterval> list = new List<Roga2dBaseInterval>();
     list.Add(new Roga2dHueInterval(target, new Roga2dHue(0, 0, 0), new Roga2dHue(100, -100, -100), Roga2dUtils.TimeToFrame(0.15f), true));
     list.Add(new Roga2dHueInterval(target, new Roga2dHue(100, -100, -100), new Roga2dHue(0, 0, 0), Roga2dUtils.TimeToFrame(0.15f), true));
     return new Roga2dSequence(list);
 }
예제 #4
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();
    }
예제 #5
0
    public static void TestSetterGetter()
    {
        Roga2dNode node = new Roga2dNode();

        // Scale
        node.LocalScale = new Vector2(1.0f, 1.0f);
        Tester.Match(node.LocalScale, new Vector2(1.0f, 1.0f));

        // Position
        node.LocalPosition = new Vector2(1.0f, 1.0f);
        Tester.Match(node.LocalPosition, new Vector2(1.0f, 1.0f));
        Tester.Match(node.Position, new Vector2(1.0f, 1.0f));

        // Rotation
        node.LocalRotation = 30.0f;
        Tester.Match(node.LocalRotation, 30.0f);

        // Alpha
        node.LocalAlpha = 0.5f;
        Tester.Match(node.LocalAlpha, 0.5f);

        // Hue
        node.LocalHue = new Roga2dHue(100, 100, 100);
        Tester.Match(node.LocalHue, new Roga2dHue(100, 100, 100));

        // Priority
        node.LocalPriority = 0.5f;
        Tester.Match(node.LocalPriority, 0.5f);

        // BlendType
        node.BlendType = Roga2dBlendType.Add;
        Tester.Match(node.BlendType, Roga2dBlendType.Add);

        node.Destroy();
    }
예제 #6
0
        // Use this for initialization
        public MapNavigatorPanel(MapModel mapModel)
        {
            this.mapModel = mapModel;
            this.mapSize = new Vector2(512, 512);

            // BG
            this.floor = new Roga2dNode();
            Roga2dSprite sprite = new Roga2dSprite("bg/map", new Vector2(512, 512), new Vector2(0, 0), new Rect(0, 0, 512, 512));
            sprite.LocalPixelPosition = new Vector2(256, 256);
            this.floor.AddChild(sprite);
            this.AddChild(this.floor);

            // Camera
            this.camera = new Roga2dNode();
            this.AddChild(this.camera);

            MapModel model = MapCache.GetInstance().GetModel();
            StepData[] steps = model.GetSteps();
            foreach (StepData step in steps) {
                this.addStep(step.StepId, step.PosX, step.PosY);
            }

            this.playerPiece = new Roga2dSprite("Dungeon/piece", new Vector2(32, 32), new Vector2(16, 32), new Rect(0, 0, 64, 64));
            this.playerPiece.LocalPriority = 0.2f;
            this.floor.AddChild(this.playerPiece);
        }
    public static void TestTween()
    {
        Roga2dNode node = new Roga2dNode();
        Roga2dRotationIntervalOption option = new Roga2dRotationIntervalOption();
        Roga2dRotationInterval interval = new Roga2dRotationInterval(node, 360.0f, 0.0f, 3, true, option);

        Tester.Ok(!interval.IsDone());

        Tester.Match(node.LocalRotation, 0.0f);
        Tester.Ok(!interval.IsDone());

        interval.Start();
        Tester.Match(node.LocalRotation, 0.0f); // 360.0f = 0.0f
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalRotation, 240.0f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalRotation, 120.0f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalRotation, 0.0f);
        Tester.Ok(interval.IsDone());

        interval.Reset();
        Tester.Match(node.LocalRotation, 0.0f); // 360.0f = 0.0f
        Tester.Ok(!interval.IsDone());

        node.Destroy();
    }
예제 #8
0
        public Stage()
        {
            this.root = new Roga2dNode();
            this.AddChild(this.root);
            this.sprites = new List<Roga2dSprite>();

            this.setupStage();
        }
 public Roga2dAnimationSettings(Roga2dAnimationPlayer player, Roga2dNode root, Roga2dNode origin, Roga2dNode target, Roga2dCommandCallback commandCallBack)
 {
     this.player = player;
     this.root = root;
     this.origin = origin;
     this.Target = target;
     this.commandCallBack = commandCallBack;
 }
예제 #10
0
 public static Roga2dAnimation Build(Roga2dNode node, Roga2dBaseInterval interval, Roga2dAnimationSettings settings)
 {
     Roga2dAnimation animation = new Roga2dAnimation();
     animation.Interval = interval;
     animation.Node = node;
     animation.IsStarted = false;
     animation.finishCallback = null;
     animation.settings = settings;
     return animation;
 }
예제 #11
0
    public static void TestTween()
    {
        Roga2dNode node = new Roga2dNode();

        Roga2dAlphaInterval interval1 = new Roga2dAlphaInterval(node, 0.1f, 1.0f, 3, true);
        Roga2dRotationIntervalOption option = new Roga2dRotationIntervalOption();
        Roga2dRotationInterval interval2 = new Roga2dRotationInterval(node, 0.0f, 180.0f, 5, true,  option);

        List<Roga2dBaseInterval> intervals = new List<Roga2dBaseInterval>();
        intervals.Add(interval1);
        intervals.Add(interval2);
        Roga2dParallel parallel = new Roga2dParallel(intervals);

        parallel.Start();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Match(node.LocalRotation, 0.0f);
        Tester.Ok(!parallel.IsDone());

        parallel.Update();
        Tester.Match(node.LocalAlpha, 0.4f);
        Tester.Match(node.LocalRotation, 36.0f);
        Tester.Ok(!parallel.IsDone());

        parallel.Update();
        Tester.Match(node.LocalAlpha, 0.7f);
        Tester.Match(node.LocalRotation, 72.0f);
        Tester.Ok(!parallel.IsDone());

        parallel.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Match(node.LocalRotation, 108.0f);
        Tester.Ok(!parallel.IsDone());

        parallel.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Match(node.LocalRotation, 144.0f);
        Tester.Ok(!parallel.IsDone());

        parallel.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Match(node.LocalRotation, 180.0f);
        Tester.Ok(parallel.IsDone());

        parallel.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Match(node.LocalRotation, 180.0f);
        Tester.Ok(parallel.IsDone());

        parallel.Reset();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Match(node.LocalRotation, 0.0f);
        Tester.Ok(!parallel.IsDone());

        node.Destroy();
    }
예제 #12
0
    public static void TestTween()
    {
        Roga2dNode node = new Roga2dNode();

        Roga2dAlphaInterval interval1 = new Roga2dAlphaInterval(node, 0.1f, 1.0f, 3, true);
        Roga2dWait interval2 = new Roga2dWait(2);
        Roga2dAlphaInterval interval3 = new Roga2dAlphaInterval(node, 0.7f, 0.0f, 2, true);

        List<Roga2dBaseInterval> intervals = new List<Roga2dBaseInterval>();
        intervals.Add(interval1);
        intervals.Add(interval2);
        intervals.Add(interval3);

        Roga2dSequence sequence = new Roga2dSequence(intervals);

        sequence.Start();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.4f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.7f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.35f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.0f);
        Tester.Ok(sequence.IsDone());

        sequence.Reset();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Ok(!sequence.IsDone());

        node.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);
 }
예제 #14
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();
    }
예제 #15
0
    public static void Test2Loop()
    {
        Roga2dNode node = new Roga2dNode();

        Roga2dAlphaInterval interval1 = new Roga2dAlphaInterval(node, 0.1f, 1.0f, 1, true);
        Roga2dWait interval2 = new Roga2dWait(1);
        Roga2dAlphaInterval interval3 = new Roga2dAlphaInterval(node, 0.7f, 0.0f, 1, true);

        List<Roga2dBaseInterval> intervals = new List<Roga2dBaseInterval>();
        intervals.Add(interval1);
        intervals.Add(interval2);
        intervals.Add(interval3);

        Roga2dSequence sequence = new Roga2dSequence(intervals);
        Roga2dLoop loop = new Roga2dLoop(sequence, 2);

        loop.Start();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Ok(!loop.IsDone());

        loop.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!loop.IsDone());

        loop.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!loop.IsDone());

        loop.Update();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Ok(!loop.IsDone());

        loop.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!loop.IsDone());

        loop.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!loop.IsDone());

        loop.Update();
        Tester.Match(node.LocalAlpha, 0.0f);
        Tester.Ok(loop.IsDone());

        node.Destroy();
    }
예제 #16
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();
    }
    public static void TestTween()
    {
        Roga2dNode node = new Roga2dNode();
        Roga2dAlphaInterval interval = new Roga2dAlphaInterval(node, 0.0f, 1.0f, 5, true);

        Tester.Ok(!interval.IsDone());

        interval.Start();
        Tester.Match(node.LocalAlpha, 0.0f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalAlpha, 0.2f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalAlpha, 0.4f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalAlpha, 0.6f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalAlpha, 0.8f);
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(interval.IsDone());

        interval.Reset();
        Tester.Match(node.LocalAlpha, 0.0f);
        Tester.Ok(!interval.IsDone());

        node.Destroy();
    }
예제 #18
0
        // Use this for initialization
        public TopWindow(MapModel mapModel)
        {
            Shader.WarmupAllShaders() ;

            this.mapModel = mapModel;
            this.animationPlayer = new Roga2dAnimationPlayer();
            this.root = new Roga2dNode("Root");
            this.AddChild(this.root);

            // animationPlayer
            this.player = spawnBattler("hose", 40, 30);
            this.root.AddChild(this.player);

            // Stage
            this.stage = new Stage();
            this.stage.LocalPriority = 0.0f;
            this.root.AddChild(stage);

            this.mapModel.StepMoved += this.onStepMoved;
            this.stage.ScrollFinished += this.onScrollFinished;
        }
예제 #19
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);
        }
    public static void TestTween()
    {
        Roga2dNode node = new Roga2dNode();

        Vector2 start = new Vector2(10.0f, 10.0f);
        Vector2 end = new Vector2(2.0f, 6.0f);
        Roga2dPositionIntervalOption option = Roga2dPositionIntervalOption.Build();
        Roga2dPositionInterval interval = new Roga2dPositionInterval(node, start, end, 4, true, option);

        Tester.Ok(!interval.IsDone());

        Tester.Match(node.LocalPosition, new Vector2(0.0f, 0.0f));
        Tester.Ok(!interval.IsDone());

        interval.Start();
        Tester.Match(node.LocalPosition, new Vector2(10.0f, 10.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalPosition, new Vector2(8.0f, 9.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalPosition, new Vector2(6.0f, 8.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalPosition, new Vector2(4.0f, 7.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalPosition, new Vector2(2.0f, 6.0f));
        Tester.Ok(interval.IsDone());

        interval.Reset();
        Tester.Match(node.LocalPosition, new Vector2(10.0f, 10.0f));
        Tester.Ok(!interval.IsDone());

        node.Destroy();
    }
예제 #21
0
    public static void TestMixTween()
    {
        Roga2dNode node = new Roga2dNode();

        Roga2dAlphaInterval interval1 = new Roga2dAlphaInterval(node, 1.0f, 0.5f, 1, false);
        Roga2dAlphaInterval interval2 = new Roga2dAlphaInterval(node, 0.5f, 0.3f, 1, false);
        Roga2dAlphaInterval interval3 = new Roga2dAlphaInterval(node, 0.3f, 0.1f, 1, true);
        Roga2dAlphaInterval interval4 = new Roga2dAlphaInterval(node, 0.1f, 0.1f, 1, true);

        List<Roga2dBaseInterval> intervals = new List<Roga2dBaseInterval>();
        intervals.Add(interval1);
        intervals.Add(interval2);
        intervals.Add(interval3);
        intervals.Add(interval4);

        Roga2dSequence sequence = new Roga2dSequence(intervals);

        sequence.Start();
        Tester.Match(node.LocalAlpha, 1.0f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.5f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.3f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Ok(!sequence.IsDone());

        sequence.Update();
        Tester.Match(node.LocalAlpha, 0.1f);
        Tester.Ok(sequence.IsDone());

        node.Destroy();
    }
    public static void TestTween()
    {
        Roga2dNode node = new Roga2dNode();

        Vector2 start = new Vector2(10.0f, 10.0f);
        Vector2 end = new Vector2(2.0f, 6.0f);
        Roga2dScaleInterval interval = new Roga2dScaleInterval(node, start, end, 4, true);

        Tester.Ok(!interval.IsDone());

        Tester.Match(node.LocalScale, new Vector2(1.0f, 1.0f));
        Tester.Ok(!interval.IsDone());

        interval.Start();
        Tester.Match(node.LocalScale, new Vector2(10.0f, 10.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalScale, new Vector2(8.0f, 9.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalScale, new Vector2(6.0f, 8.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalScale, new Vector2(4.0f, 7.0f));
        Tester.Ok(!interval.IsDone());

        interval.Update();
        Tester.Match(node.LocalScale, new Vector2(2.0f, 6.0f));
        Tester.Ok(interval.IsDone());

        interval.Reset();
        Tester.Match(node.LocalScale, new Vector2(10.0f, 10.0f));
        Tester.Ok(!interval.IsDone());

        node.Destroy();
    }
 public void Destroy()
 {
     if (this.targetOrigin != null) {
         this.targetOrigin.Destroy();
         this.targetOrigin.Parent.RemoveChild(this.targetOrigin);
         this.targetOrigin = null;
     }
 }
예제 #24
0
 public static Roga2dAnimation Build(Roga2dNode node,  Roga2dBaseInterval interval)
 {
     return Build(node, interval, null);
 }
예제 #25
0
    // Use this for initialization
    void Start()
    {
        Shader.WarmupAllShaders() ;

        this.player = new Roga2dAnimationPlayer();
        this.root = new Roga2dNode("Root");
        this.root.LocalScale = new Vector2(2.0f, 2.0f);
        Roga2dGameObjectState state = Roga2dUtils.stashState(this.root.Transform);
        this.root.Transform.parent = roga2dRoot.transform;
        Roga2dUtils.applyState(this.root.Transform, state);

        // Player
        this.root.AddChild(spawnBattler("pierre", 40, -20));
        this.root.AddChild(spawnBattler("amon", 40, 20));
        this.root.AddChild(spawnBattler("draco", 80, -40));
        this.root.AddChild(spawnBattler("lilia", 80, 0));
        this.root.AddChild(spawnBattler("hose", 80, 40));

        // Monster
        this.monster = spawnMonster("death_wind", -40, 0);
        this.root.AddChild(this.monster);

        // Stage
        Stage stage = new Stage();
        stage.LocalPriority = 0.0f;
        this.root.AddChild(stage);
    }
예제 #26
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();
    }
예제 #27
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();
    }
예제 #28
0
    public void AddChild(Roga2dNode node)
    {
        if (node.Parent != null) {
            Debug.LogError("Node cannot have multiple parent");
        }

        this.children.Add(node);

        if (this.isHidden) {
            node.Hide();
        }
        Roga2dGameObjectState state = Roga2dUtils.stashState(node.Transform);
        node.Transform.parent = this.transform;
        node.Parent = this;
        Roga2dUtils.applyState(node.Transform, state);
        nodeCount += 1;
    }
예제 #29
0
 public void RemoveChild(Roga2dNode node)
 {
     if (node != null) {
         this.children.Remove(node);
         node.Destroy();
         nodeCount -= 1;
     }
 }