コード例 #1
0
ファイル: nInputHandler.cs プロジェクト: shadowmint/pongstar
 /** 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;
 }
コード例 #2
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;
    }
コード例 #3
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");
        });
    }
コード例 #4
0
ファイル: nInputHandler.cs プロジェクト: shadowmint/pongstar
 /** 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;
     }
       }
 }
コード例 #5
0
ファイル: nInputHandler.cs プロジェクト: shadowmint/pongstar
 /** 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);
 }