/** Check if we match a specific event for a specific gameobject */
 public bool QueryHits(nCamera c, nInputEvent e, GameObject o)
 {
     var rtn = false;
       var hits = _hits[c];
       if (e == nInputEvent.DOWN) {
     if (Input.GetMouseButtonDown(0) && Intersects(hits, o))
       rtn = true;
       }
       else if (e == nInputEvent.UP) {
     if (Input.GetMouseButtonUp(0) && Intersects(hits, o))
       rtn = true;
       }
       else if (e == nInputEvent.ENTER) {
     if (_prevHits.ContainsKey(c)) {
       var lhits = _prevHits[c];
       if (Intersects(hits, o) && (!Intersects(lhits, o))) {
       rtn = true;
       }
     }
       }
       else if (e == nInputEvent.EXIT) {
     if (_prevHits.ContainsKey(c)) {
       var lhits = _prevHits[c];
       if (!Intersects(hits, o) && (Intersects(lhits, o)))
     rtn = true;
     }
       }
       return rtn;
 }
Exemplo n.º 2
0
 public nBackground(nCamera camera)
 {
     _camera = camera;
       _color.Set (new float[4] { 1, 1, 1, 1 });
       TilesHigh = 1;
       TilesWide = 1;
 }
Exemplo n.º 3
0
        public Field(GameState parent, nCamera camera)
            : base(parent)
        {
            _cam = camera;

              var bounds = parent == null ? camera.ScreenBounds : parent.GameBounds();
              Bounds = new float[4] { bounds.xMin, bounds.yMin, bounds.xMax, bounds.yMax };
        }
 public bTreeViewModel(bTree tree, nCamera camera, bool force)
 {
     Tree = new nLayer();
       if (tree != null) {
     foreach (var p in tree.Render(camera, force)) {
       Tree.Add(p);
     }
       }
 }
Exemplo n.º 5
0
    void Start()
    {
        var controller = HelloApp.App.Get<HomeController>();
        var model = controller.SceneInfo().Model.As<SceneInfoViewModel>();
        model.BackButton.Manifest();
        _cam = model.Camera;

        p = new GraphicsPipe();
        p.Drawables.Add(new Thingo());
    }
Exemplo n.º 6
0
        void Start()
        {
            _controller = HelloApp.App.Get<GameController>();
              var model = _controller.SceneInfo().Model.As<SceneInfoViewModel>();
              _cam = model.Camera;

              var text = new nText(new Vector2(1.0f, 1.0f));
              text.Font = (Font) Resources.Load("Fonts/vinchard");
              text.FontSize = 0.5f;
              text.Text = "Select the type of tree you want to grow...";
              text.Color = new Color(0.3f, 0.3f, 0.3f);
              var p = new nProp(text);
              p.Visible = true;
              p.Position = new Vector2(-5.2f, 2.5f);

              p = new nProp("tree.1", new Vector2(2.0f, 2.0f));
              p.Visible = true;
              p.Position = new Vector2(-4.35f, -0.3f);
              p.Listen(_cam, nInputEvent.ENTER, delegate { SetNotice("Lovie", bTreeType.TREE_1, new Vector2(-4.72f, -1.5f)); });
              p.Listen(_cam, nInputEvent.EXIT, delegate { SetNotice(""); });
              p.Listen(_cam, nInputEvent.DOWN, delegate {
            HelloApp.App.Get<TreeController>().Index().Activate();
              });

              p = new nProp("tree.2", new Vector2(2.0f, 2.0f));
              p.Visible = true;
              p.Position = new Vector2(-0.35f, -0.3f);
              p.Listen(_cam, nInputEvent.ENTER, delegate { SetNotice("Nujiper", bTreeType.TREE_2, new Vector2(-0.80f, -1.5f)); });
              p.Listen(_cam, nInputEvent.EXIT, delegate { SetNotice(""); });
              p.Listen(_cam, nInputEvent.DOWN, delegate {
            HelloApp.App.Get<TreeController>().Index().Activate();
              });

              p = new nProp("tree.3", new Vector2(2.0f, 2.0f));
              p.Visible = true;
              p.Position = new Vector2(3.35f, -0.3f);
              p.Listen(_cam, nInputEvent.ENTER, delegate { SetNotice("Pamle", bTreeType.TREE_3, new Vector2(2.97f, -1.5f)); });
              p.Listen(_cam, nInputEvent.EXIT, delegate { SetNotice(""); });
              p.Listen(_cam, nInputEvent.DOWN, delegate {
            HelloApp.App.Get<TreeController>().Index().Activate();
              });

              text = new nText(new Vector2(1.0f, 1.0f));
              text.Font = (Font) Resources.Load("Fonts/vinchard");
              text.FontSize = 0.4f;
              text.Text = "";
              text.Color = new Color(0.2f, 0.5f, 0.2f);
              _notice = new nProp(text);
              _notice.Visible = true;
              _notice.Position = new Vector2(-2.0f, -3.5f);
              SetNotice("Nujiper", bTreeType.TREE_2, new Vector2(-0.8f, -1.5f));
        }
Exemplo n.º 7
0
 public GameStateViewModel(GameState state, nCamera camera)
 {
     Items = new List<nIDrawable> {
     state.Field.Display,
     state.PlayerPaddle.Display,
     state.AiPaddle.Display,
     state.Ball.Display,
     state.Sparkle.Display,
     state.RainbowTrail.Display,
     state.Flare.Display,
     state.Collectables.Display
       };
       Camera = camera;
 }
Exemplo n.º 8
0
    void Start()
    {
        var controller = HelloApp.App.Get<HomeController>();
        var model = controller.SceneInfo().Model.As<SceneInfoViewModel>();
        model.BackButton.Manifest();
        _cam = model.Camera;

        /* load a quad */
        _quads[0] = new nQuad(new Vector2(1.0f, 1.0f));
        _quads[0].Texture = (Texture) Resources.Load("test.quad.1");

        /* create a couple of props from the quad */
        _props[0] = new nProp(_quads[0]);
        _props[0].Visible = true;
        _props[0].Position = new Vector2(0, 0);
        _props[0].Listen(_cam, delegate (nProp prop) {
          nLog.Debug("Got a click on 0!");
        });

        _props[1] = new nProp(_quads[0]);
        _props[1].Visible = true;
        _props[1].Position = new Vector2(2, 0);
        _props[1].Scale = new Vector2(0.5f, 0.5f);

        _props[2] = new nProp(_quads[0]);
        _props[2].Visible = true;
        _props[2].Position = new Vector2(0, 2);
        _props[2].Rotation = 45.0f;
        _props[2].Listen(_cam, delegate (nProp prop) {
          nLog.Debug("Got a click on 2!");
        });

        _props[3] = new nProp(_quads[0]);
        _props[3].Visible = true;
        _props[3].Position = new Vector2(2, 2);
        _props[3].Depth = 0;

        _props[4] = new nProp(_quads[0]);
        _props[4].Visible = true;
        _props[4].Position = new Vector2(2.5f, 2.5f);
        _props[4].Depth = 1;

        _props[5] = new nProp("test.quad.1", new Vector2(2.0f, 2.0f));
        _props[5].Visible = true;
        _props[5].Position = new Vector2(-3, 0);
        _props[5].Scale = new Vector2(0.5f, 2.0f);
        _props[5].Rotation = -15.0f;
    }
Exemplo n.º 9
0
        void Start()
        {
            _controller = HelloApp.App.Get<GameController>();
              var model = _controller.SceneInfo().Model.As<SceneInfoViewModel>();
              _cam = model.Camera;

              var p = new nProp("Title", new Vector2(8.0f, 4.0f));
              p.Visible = true;
              p.Position = new Vector2(0f, 1.7f);

              var b = new nButton() {
            Camera = _cam,
            Color = Color.black,
            Texture = "new",
            OverTexture = "new.active",
            DownTexture = "new.click",
            Position = new Vector2(-.5f, -1.5f),
            Size = new Vector2(2.59f, 1.00f),
            Text = "",
            Action = delegate {
              _controller.SelectTree().Activate();
            }
              };
              b.Manifest();

              var text = new nText(new Vector2(1.0f, 1.0f));
              text.Font = (Font) Resources.Load ("Fonts/vinchard");
              text.Text = "by One Thousand Faces";
              text.FontSize = 0.3f;
              text.Color = new Color(0.4f, 0.4f, 0.4f);
              p = new nProp(text);
              p.Visible = true;
              p.Position = new Vector2(3f, -3f);

              text = new nText(new Vector2(1.0f, 1.0f));
              text.Font = (Font) Resources.Load ("Fonts/vinchard");
              text.Text = "Sandra Lim & Douglas Linder";
              text.FontSize = 0.2f;
              text.Color = new Color(0.7f, 0.7f, 0.7f);
              p = new nProp(text);
              p.Visible = true;
              p.Position = new Vector2(3f, -3.4f);
        }
Exemplo n.º 10
0
 /** Update for camera if we haven't already */
 public void UpdateHits(nCamera c)
 {
     var thisFrame = Time.frameCount;
       if (lastFrame != thisFrame) {
     _prevHits = _hits;
     _hits = new Dictionary<nCamera, RaycastHit[]>();
     lastFrame = thisFrame;
       }
       if (c != null) {
     if (!_hits.ContainsKey(c)) {
       var mouse = Input.mousePosition;
       var ray = c.ScreenPointToRay(mouse);
       RaycastHit[] hits;
       hits = Physics.RaycastAll(ray);
       _hits [c] = hits;
     }
       }
 }
        public nView SceneInfo()
        {
            if (_cam == null) {
            _cam = new nCamera(10.0f);
            _session.Game.Camera = _cam;
              }

              var model = new SceneInfoViewModel();
              model.Camera = _cam;
              model.Camera.Active = true;
              model.Camera.Background = new Color(1f, 1f, 1f, 0f);

              model.BackButton = model.Button("Back", delegate {
            HelloApp.App.Get<HomeController>().Menu().Activate();
              });
              model.BackButton.Position = new Vector2(-5.0f, -3.0f);

              return View(model);
        }
Exemplo n.º 12
0
 /** Generate a ui camera to use */
 public nCamera UiCamera()
 {
     var c = new nCamera(Config.Height);
       return c;
 }
Exemplo n.º 13
0
 /** Generate a camera to use */
 public nCamera Camera()
 {
     if (_camera == null)
     _camera = new nCamera(Config.Height);
       return _camera;
 }
Exemplo n.º 14
0
 /** Add a camera for the scene */
 public void Camera(nCamera c)
 {
     _cameras.Add(c);
 }
Exemplo n.º 15
0
        void Start()
        {
            _controller = HelloApp.App.Get<GameController>();
              var model = _controller.SceneInfo(14.0f).Model.As<SceneInfoViewModel>();
              _cam = model.Camera;

              var fortune = Fortunes.Next();
              var offset = new Vector2((float) (53 - (int) fortune[2]) * 0.1f, 0f);

              var text = new nText(new Vector2(1.0f, 1.0f));
              text.Font = (Font) Resources.Load("Fonts/vinchard");
              text.FontSize = 0.45f;
              text.Text = (string) fortune[0];
              text.Color = new Color(0.2f, 0.2f, 0.2f);
              var p = new nProp(text);
              p.Visible = true;
              p.Position = new Vector2(-4.0f, -3.5f) + offset;

              text = new nText(new Vector2(1.0f, 1.0f));
              text.Font = (Font) Resources.Load("Fonts/vinchard");
              text.FontSize = 0.35f;
              text.Text = (string) fortune[1];
              text.Color = new Color(0.5f, 0.5f, 0.5f);
              p = new nProp(text);
              p.Visible = true;
              p.Position = new Vector2(-4.0f, -3.0f) + offset;

              /*p = new nProp("pot", new Vector2(2.0f, 2.0f));
              p.Visible = true;
              p.Position = new Vector2(0f, -1.25f);
              p.Depth = 6.0f;
              p.Color = new Color(0.5f, 0.5f, 0.5f);*/

              /*p = new nProp("square-pot", new Vector2(4.5f, 2.0f));
              p.Visible = true;
              p.Position = new Vector2(0f, -1.7f);
              p.Depth = 7.0f;
              p.Color = new Color(0.5f, 0.5f, 0.5f);*/

              p = new nProp("oval-pot", new Vector2(3.85f, 1.5f));
              p.Visible = true;
              p.Position = new Vector2(-0.15f, -1.47f);
              p.Scale = new Vector2(1.2f, 1.1f);
              p.Depth = 7.0f;
              p.Color = new Color(0.5f, 0.5f, 0.5f);

              b = new nButton() {
            Text = "Return to menu",
            Font = "Fonts/vinchard",
            Position = new Vector2(6.0f, 5.5f),
            FontSize = 0.5f,
            Camera = _cam,
            Size = new Vector2(4.0f, 1.0f),
            Color = new Color(0.2f, 0.2f, 0.2f),
            Texture = "Menu.button.0",
            Action = delegate {
              _controller.Index().Activate();
            }
              };
              b.Manifest();

              b2 = new nButton() {
            Text = "Download this Bonsai",
            Font = "Fonts/vinchard",
            Position = new Vector2(-6.7f, 5.5f),
            FontSize = 0.5f,
            Camera = _cam,
            Size = new Vector2(4.0f, 1.0f),
            Color = new Color(0.2f, 0.2f, 0.2f),
            Texture = "Menu.button.0",
              };
              b2.Action = delegate {
            StartCoroutine(WaitingForSS());
              };
              b2.Manifest();

              bLeaf.MagicOffset = -1f;
              var tree = HelloApp.App.Get<TreeController>().ForceTreeRedraw().Model.As<bTreeTestViewModel>();
              tree.Data.TreeView.Tree.Position = new Vector2(0f, -1f);
        }
Exemplo n.º 16
0
        /** Create a series of line segments as props for this and all sub branches */
        public void Render(List<nProp> elements, nCamera camera, bool force)
        {
            if (_dead)
            return;
              if (camera == null)
            return;

              /* Do we have a prop for this branch yet? If not, make one */
              if ((_display == null) || (force)) {
            if (_display != null) {
              _display.Visible = false;
              _display = null;
            }
            if (camera != null) {
              var t = (Texture)Resources.Load("test.line.3");
              var q = new nQuad("Tree", new Vector2(1f, 1f));
              q.Texture = t;
              _display = new nProp(q);
              _display.Visible = true;
              _display.Data = this;
              _display.Depth = 3.0f;
              _display.ClearEventListeners(camera, nInputEvent.ENTER);
              _display.ClearEventListeners(camera, nInputEvent.EXIT);
              _display.Listen(camera, nInputEvent.ENTER, delegate {
            if (Tree.EditMode)
              _display.Color = new Color(0f, 1f, 0f, 0.5f);
              });
              _display.Listen(camera, nInputEvent.EXIT, delegate {
            _display.Color = Color.white;
              });
              _display.Listen(camera, nInputEvent.UP, delegate {
            if (Tree.EditMode)
              Hello.HelloApp.App.Get<TreeController>().RemoveBranch(this);
              });
            }
              }

              /** Update this to match the actual branch */
              var _base = Base;
              var _tip = Tip;
              var _parentWidth = Parent != null ? Parent.WidthAtPoint(Offset) : Width;
              var _baseWidth = _parentWidth < Width ? _parentWidth : Width;

              // Segments must join up cleanly
              if (IsSegment)
            _baseWidth = _parentWidth;

              var _tipWidth = TipWidth;
              nStrip.PopulateLineSegment(_display.Vertices, _base, _tip, _baseWidth, _tipWidth);
              _display.PushVertexUpdate();

              /** Collect this */
              elements.Add(_display);

              /** Collect segments */
              var segs = new List<bTreeBranch>();
              CollectSegments(segs);
              foreach (var s in segs) {
            if (s != this) {
              s.Render(elements, camera, force);
            }
              }

              /** Collect branches */
              foreach (var b in Branches) {
            b.Render(elements, camera, force);
              }

              /** Collect leaves */
              foreach (var l in Leaves) {
            l.Render(elements, force);
              }
        }
Exemplo n.º 17
0
 void Start()
 {
     _controller = HelloApp.App.Get<TreeController>();
     var model = _controller.SceneInfo().Model.As<SceneInfoViewModel>();
     _cam = model.Camera;
     _controller.Reset();
     SetupButtons(model);
     DrawGround();
     DrawHelp(true);
     _controller.SetPaused(false);
 }
Exemplo n.º 18
0
 /** Check if we match a specific event for a specific gameobject */
 public static bool Query(nCamera c, nInputEvent e, GameObject o)
 {
     var i = nInputHandler.Get();
       i.UpdateHits (c);
       return i.QueryHits(c, e, o);
 }
Exemplo n.º 19
0
 /** Listen for a click on this object; delegate must be unique */
 public void Listen(nCamera cam, nPropClick click)
 {
     _clicks[click] = cam;
 }
Exemplo n.º 20
0
 /** Render a list of props for this tree */
 public List<nProp> Render(nCamera camera, bool force)
 {
     var rtn = new List<nProp>();
       Trunk.Render(rtn, camera, force);
       return rtn;
 }
Exemplo n.º 21
0
    void Start()
    {
        var controller = HelloApp.App.Get<HomeController>();
        var model = controller.SceneInfo().Model.As<SceneInfoViewModel>();
        model.BackButton.Manifest();
        _cam = model.Camera;

        var light_font = (Font) Resources.Load ("Fonts/Roboto-Regular");
        var bold_font = (Font) Resources.Load ("Fonts/Roboto-BoldCondensed");

        var instance = new nText(new Vector2(1.0f, 1.0f));
        instance.Font = bold_font;
        instance.FontSize = 0.2f;
        instance.Color = Color.white;
        instance.Text = "Hello nText, yeah!\nhithere\ndfsdfasfdasfasdf\ndasfasdfasdf";

        var prop = new nProp(instance);
        prop.Visible = true;
        prop.Scale = new Vector2(1.0f, 1.0f);
        prop.Position = new Vector2(-6.0f, 2.0f);
        prop.Depth = 0;
        prop.Listen(_cam, delegate {
          nLog.Debug ("Text click");
        });

        instance = new nText(new Vector2(1.0f, 1.0f));
        instance.Font = light_font;
        instance.FontSize = 1.0f;
        instance.Color = Color.blue;
        instance.Text = "this is a blue test";

        prop = new nProp(instance);
        prop.Visible = true;
        prop.Scale = new Vector2(1.0f, 1.0f);
        prop.Position = new Vector2(-6.0f, 1.0f);
        prop.Depth = 0;
        prop.Listen(_cam, delegate {
          nLog.Debug ("Text click");
        });

        instance = new nText(new Vector2(1.0f, 1.0f));
        instance.Font = bold_font;
        instance.FontSize = 2.0f;
        instance.Color = Color.magenta;
        instance.Text = "This is a pink test which is all scaled";

        prop = new nProp(instance);
        prop.Visible = true;
        prop.Scale = new Vector2(0.5f, 1.0f);
        prop.Position = new Vector2(-6.0f, -1.0f);
        prop.Depth = 1;
        prop.Listen(_cam, delegate {
          nLog.Debug ("Text click");
        });

        instance = new nText(new Vector2(1.0f, 1.0f));
        instance.Font = bold_font;
        instance.FontSize = 0.5f;
        instance.Color = Color.green;
        instance.Text = "This is another random test we've rotated!";

        prop = new nProp(instance);
        prop.Visible = true;
        prop.Scale = new Vector2(0.8f, 1.0f);
        prop.Position = new Vector2(3.0f, 3.0f);
        prop.Rotation = -90.0f;
        prop.Depth = 0;
        prop.Listen(_cam, delegate {
          nLog.Debug ("Text click");
        });
    }
Exemplo n.º 22
0
 /** Special mapping function for screen -> world */
 public static float DistanceInWorld(float mm, nAxis axis, nCamera camera)
 {
     var height = camera.Native.orthographicSize * 2;
       var width = camera.Native.GetScreenWidth() / camera.Native.GetScreenHeight() * height;
       var p = 0f;
       if (axis == nAxis.X) {
     p = Distance(mm) / camera.Native.GetScreenWidth() * width;
       }
       else if (axis == nAxis.Y) {
     p = Distance(mm) / camera.Native.GetScreenHeight() * height;
       }
       return p;
 }
Exemplo n.º 23
0
    void Start()
    {
        var controller = HelloApp.App.Get<HomeController>();
        var model = controller.SceneInfo().Model.As<SceneInfoViewModel>();
        model.BackButton.Manifest();
        _cam = model.Camera;

        /* load a quad */
        _quads[0] = new nQuad(new Vector2(1.0f, 1.0f));
        _quads[0].Texture = (Texture) Resources.Load("test.quad.1");

        /* create a couple of props from the quad */
        _props[0] = new nProp(_quads[0]);
        _props[0].Visible = true;
        _props[0].Position = new Vector2(0, 0);
        _props[0].Listen(_cam, nInputEvent.UP, delegate (nPropEvent prop) {
          nLog.Debug("Got a click on 0!");
        });

        _props[1] = new nProp(_quads[0]);
        _props[1].Visible = true;
        _props[1].Position = new Vector2(2, 0);
        _props[1].Scale = new Vector2(0.5f, 0.5f);

        _props[2] = new nProp(_quads[0]);
        _props[2].Visible = true;
        _props[2].Position = new Vector2(0, 2);
        _props[2].Rotation = 45.0f;
        _props[2].Listen(_cam, nInputEvent.UP, delegate (nPropEvent prop) {
          nLog.Debug("Got a click on 2!");
        });

        _props[3] = new nProp(_quads[0]);
        _props[3].Visible = true;
        _props[3].Position = new Vector2(2, 2);
        _props[3].Depth = 0;

        _props[4] = new nProp(_quads[0]);
        _props[4].Visible = true;
        _props[4].Position = new Vector2(2.5f, 2.5f);
        _props[4].Depth = 1;

        _props[5] = new nProp("test.quad.1", new Vector2(2.0f, 2.0f));
        _props[5].Visible = true;
        _props[5].Position = new Vector2(-3, 0);
        _props[5].Scale = new Vector2(0.5f, 2.0f);
        _props[5].Rotation = -15.0f;
        _props[5].Listen(_cam, nInputEvent.ENTER, delegate (nPropEvent e) {
          e.Prop.Color = new Color(1.0f, 1.0f, 0.0f, 1.0f);
        });
        _props[5].Listen(_cam, nInputEvent.EXIT, delegate (nPropEvent e) {
          e.Prop.Color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
        });

        /* Load a transparent prop set and make sure transparency overlays work */
        var p = new nProp("lovie-foliage", new Vector2(2.0f, 2.0f));
        p.Visible = true;
        p.Position = new Vector2(4.0f, 2.0f);
        p.Depth = 1;

        p = new nProp("nujiper-foliage", new Vector2(2.0f, 2.0f));
        p.Visible = true;
        p.Position = new Vector2(4.5f, 2.5f);
        p.Color = new Color(1.0f, 0.0f, 0.0f, 0.5f);

        /* load a quad and distort it*/
        var q = new nQuad(new Vector2(1.0f, 1.0f));
        q.Texture = (Texture) Resources.Load("test.quad.1");
        q.Layout[0][0] = 4.0f;
        q.Layout[0][1] = 4.0f;

        AddLineSegment(q, new Vector2(-4, -3), new Vector2(-3, -3), 1.0f, 0.8f);
        AddLineSegment(q, new Vector2(-3, -3), new Vector2(-2, -3), 0.8f, 0.6f);
        AddLineSegment(q, new Vector2(-2, -3), new Vector2(-1, -3), 0.6f, 0.4f);
        AddLineSegment(q, new Vector2(-1, -3), new Vector2(0, -3), 0.4f, 0.2f);
        AddLineSegment(q, new Vector2(0, -3), new Vector2(1, -3), 0.2f, 0.1f);
        AddLineSegment(q, new Vector2(1, -3), new Vector2(2, -3), 0.1f, 0.05f);
        AddLineSegment(q, new Vector2(2, -3), new Vector2(3, -3), 0.05f, 0.01f);
    }
Exemplo n.º 24
0
 /** Special mapping function for screen -> world */
 public static float DistanceInWorld(float mm, nEdge boundary, nCamera camera)
 {
     var height = camera.Native.orthographicSize * 2;
       var width = camera.Native.GetScreenWidth() / camera.Native.GetScreenHeight() * height;
       var p = 0f;
       if (boundary == nEdge.BOTTOM)
     p = - height / 2 + DistanceInWorld(mm, nAxis.Y, camera);
       else if (boundary == nEdge.LEFT)
     p = - width / 2 + DistanceInWorld(mm, nAxis.X, camera);
       else if (boundary == nEdge.RIGHT)
     p = width / 2 - DistanceInWorld(mm, nAxis.X, camera);
       else if (boundary == nEdge.TOP)
     p = height / 2 - DistanceInWorld(mm, nAxis.Y, camera);
       return p;
 }