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)); }
private void AddLineSegment(nQuad q, Vector2 start, Vector2 end, float w1, float w2) { var p = new nProp(q); p.Visible = true; p.Listen(_cam, nInputEvent.ENTER, delegate (nPropEvent e) { e.Prop.Color = new Color(1.0f, 1.0f, 0.0f, 0.3f); }); p.Listen(_cam, nInputEvent.EXIT, delegate (nPropEvent e) { e.Prop.Color = new Color(1.0f, 1.0f, 1.0f, 1.0f); }); nStrip.PopulateLineSegment(p.Vertices, start, end, w1, w2); p.PushVertexUpdate(); }
/** 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); } }
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"); }); }
private void DrawHelp(bool show) { if (show) { DrawHelpText("Welcome to bonsai bloom! You've got 90 days to grow your bonsai...", 0.4f, -5.5f, 4.5f); DrawHelpText("This shows you how much time\nhas passed in the game so far", 0.3f, 4.5f, 1.9f); DrawHelpText("You can control the speed of time\nby using these buttons!", 0.3f, -2f, 2.7f); DrawHelpText("The edit button pauses\n the game and lets\n you trim branches", 0.3f, -8f, 2.3f); DrawHelpText("Your tree will start growing right here!", 0.3f, -7f, -1.5f); DrawHelpText("Ready? Click here to start!", 0.4f, 0f, 0f); DrawArrow(2.9f, -0.5f, 3.3f, -1.3f); DrawArrow(5f, 2.0f, 4.7f, 2.6f); DrawArrow(-2.25f, 2.3f, -3.5f, 2.95f); DrawArrow(-6.0f, 2.30f, -5.4f, 2.9f); DrawArrow(-2.8f, -1.8f, -0.3f, -2.85f); var p = new nProp("startTree", new Vector2(1.8f, 1.8f)); p.Visible = true; p.Position = new Vector2(4f, -1.8f); p.Listen(_cam, nInputEvent.UP, delegate { DrawHelp(false); started = true; }); _helps.Add(p); } else { foreach(var p in _helps) { p.Visible = false; } } }
private void SetupButtons(SceneInfoViewModel model) { _editEnabled = new nProp("edit", new Vector2(0.5f, 0.5f)); _editDisabled = new nProp("edit.disabled", new Vector2(0.5f, 0.5f)); _editEnabled.Listen(_cam, nInputEvent.UP, delegate { SetEditState(false); }); _editDisabled.Listen(_cam, nInputEvent.UP, delegate { SetEditState(true); }); SetEditState(false); var p = new nProp("btn-play", new Vector2(0.5f, 0.5f)); p.Visible = true; p.Position = new Vector2(-4.45f, 3.0f); p.Listen(_cam, nInputEvent.UP, delegate { nLog.Debug("Play!!"); SetEditState(false); _controller.UpdateGameSpeed(0.4f); }); p = new nProp("btn-faster", new Vector2(0.5f, 0.5f)); p.Visible = true; p.Position = new Vector2(-3.90f, 3.0f); p.Listen(_cam, nInputEvent.UP, delegate { SetEditState(false); _controller.UpdateGameSpeed(0.9f); }); _controller.UpdateGameSpeed(0.4f); _controller.UpdateTime(5.0f, false); /*model.Button("Pause", delegate { Trace("Paused!"); _controller.SetPaused(true); }, new Vector2(5.0f, 3.0f)).Manifest(); model.Button("Start", delegate { var response = _controller.SetPaused(false); if (response.Success) Trace("Started~ (you should see an animation now depending on game speed... :P)"); else Trace("You need to create a new tree by clicking 'reset' first"); }, new Vector2(5.0f, 2.5f)).Manifest(); model.Button("Reset", delegate { _controller.Reset(); if (_lastTree != null) _lastTree.Visible = false; _lastTree = null; }, new Vector2(5.0f, 2.0f)).Manifest(); model.Button("Slower", delegate { _controller.UpdateGameSpeed(-0.05); }, new Vector2(5.0f, 1.5f)).Manifest(); model.Button("Faster", delegate { _controller.UpdateGameSpeed(0.05); }, new Vector2(5.0f, 1.0f)).Manifest(); model.Button("Dump Config", delegate { _controller.DumpConfig(); }, new Vector2(5.0f, 0.5f)).Manifest();*/ var light_font = (Font) Resources.Load ("Fonts/vinchard"); _trace = new nText(new Vector2(3.0f, 1.0f)); _trace.Color = Color.black; _trace.FontSize = 0.2f; _trace.Font = light_font; _trace.Text = ""; _traceProp = new nProp(_trace); _traceProp.Visible = true; _traceProp.Position = new Vector2(-7.0f, 4.5f); var d = new nText(new Vector2(3.0f, 2.0f)); d.Color = Color.black; d.FontSize = 0.4f; d.Font = light_font; d.Text = "90 days left"; _date = new nProp(d); _date.Visible = true; /* redraw text */ _date.Position = new Vector2(3.5f, 3.2f); d = new nText(new Vector2(3.0f, 2.0f)); d.Color = new Color (0.6f, 0.6f, 0.6f); d.FontSize = 0.25f; d.Font = light_font; d.Text = ""; _speed = new nProp(d); _speed.Visible = true; /* redraw text */ _speed.Position = new Vector2(3.6f, 2.75f); }
public void Manifest() { if (!_visible) { _visible = true; _button = new nProp (Texture, Size); _button.Visible = true; _button.Position = Position; _button.Depth = 1; var text = new nText (Size); text.Text = Text; text.Font = (Font) Resources.Load(Font); text.FontSize = FontSize; text.Color = Color; _text = new nProp (text); _text.Visible = true; _text.Position = new Vector2(Position[0] - Size[0] / 3, Position[1] + Size[1] / 3); _text.Depth = 0; _button.Listen (Camera, Action); } }
public void Manifest() { if (!_visible) { _visible = true; _button = new nProp (Texture, Size); _button.Visible = true; _button.Position = Position; _button.Depth = Depth + 1f; if (OverTexture != null) { _buttonOver = new nProp (OverTexture, Size); _buttonOver.Visible = true; _buttonOver.Position = Position; _buttonOver.Depth = Depth + 2f; _button.Listen(Camera, nInputEvent.ENTER, delegate { _button.Depth = Depth + 3; _buttonOver.Depth = Depth + 2f; }); _buttonOver.Listen(Camera, nInputEvent.EXIT, delegate { _button.Depth = Depth + 1; _buttonOver.Depth = Depth + 3f; }); } if (DownTexture != null) { _buttonDown = new nProp (DownTexture, Size); _buttonDown.Visible = true; _buttonDown.Position = Position; _buttonDown.Depth = Depth + 2f; _button.Listen(Camera, nInputEvent.DOWN, delegate { _buttonDown.Depth = Depth + 1f; }); _buttonDown.Listen(Camera, nInputEvent.UP, delegate { _buttonDown.Depth = Depth + 4f; }); _buttonDown.Listen(Camera, nInputEvent.EXIT, delegate { _buttonDown.Depth = Depth + 4f; }); } if ((Text != null) && (Text != "")) { var text = new nText (Size); text.Text = Text; text.Font = (Font) Resources.Load(Font); text.FontSize = FontSize; text.Color = Color; _text = new nProp (text); _text.Visible = true; _text.Position = new Vector2(Position[0] - Size[0] / 3.0f, Position[1] + Size[1] / 3.3f); _text.Depth = Depth + 0f; } _button.Listen(Camera, nInputEvent.UP, Action); } }