protected override SceneObject makeSceneObject() { var background = this.mBackgroundNormal; if (this.isHovered) { background = this.mBackgroundHover; } if (this.isToggled) { background = this.mBackgroundToggled; } var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (this.mForgroundImage != null) { soBuilder. StartSprite(this.Z0 - this.ZRange / 2, this.mForgroundImage.Sprite.Id, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(this.mForgroundImage, this.Position.Size.X, this.Position.Size.Y)); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { var soBuilder = new SceneObjectBuilder(); if (this.mForgroundImage.HasValue) { soBuilder.StartSimpleSprite(this.Z0, this.mForgroundImage.Value, this.mForgroundImageColor). Scale(this.Position.Size - new Vector2(this.padding, this.padding)). Translate(this.Position.Center); } if (this.selected && this.mSelectorImage.HasValue) { soBuilder.StartSimpleSprite(this.Z0 - this.ZRange / 2, this.mSelectorImage.Value, Color.White). Scale(this.Position.Size). Translate(this.Position.Center); } if (!this.selected && this.isHovered && this.mSelectorImage.HasValue) { soBuilder.StartSimpleSprite(this.Z0 - this.ZRange / 2, this.mSelectorImage.Value, Color.Gray). Scale(this.Position.Size). Translate(this.Position.Center); } return(soBuilder.Build()); }
override public void Awake() { base.Awake(); // Set Param sceneObjectName = "Tree"; SceneObjectBuilder.GetObjectByName(GetComponent <BaseSceneObject>()); }
protected override SceneObject makeSceneObject() { var pressOffset = this.isPressed && this.isHovered ? new Vector2(PressOffsetX, PressOffsetY) : new Vector2(0, 0); var background = this.isHovered ? this.BackgroundHover : this.mBackgroundNormal; var soBuilder = new SceneObjectBuilder(). PixelSize(1 / SettingsWinforms.Get.GuiScale). Clip(this.Position.ClipArea). //TODO(v0.8) add press offset to clip area StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center + pressOffset). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (!string.IsNullOrWhiteSpace(this.Text)) { soBuilder.StartText(this.Text, -0.5f, 0.5f, this.Z0 - this.ZRange / 2, this.ZRange / 2, this.TextColor). Scale(this.TextHeight). Translate(this.Position.Center + new Vector2(0, this.textSize.Y / 2f * this.TextHeight)); } if (this.mForgroundImage.HasValue) { soBuilder. StartSimpleSprite(this.Z0 - this.ZRange / 2, this.mForgroundImage.Value, Color.White). Scale(this.Position.Size - new Vector2(2 * this.paddingX, 2 * this.paddingY)). Translate(this.Position.Center); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { var pressOffset = this.isPressed && this.isHovered ? new Vector2(PressOffsetX, PressOffsetY) : new Vector2(0, 0); var background = this.isHovered ? this.BackgroundHover : this.mBackgroundNormal; var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). //TODO(v0.8) add press offset to clip area StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center + pressOffset). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (!string.IsNullOrWhiteSpace(this.Text)) { //TODO(later) split single line if it doesn't fit var lines = this.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { soBuilder.StartText(lines[i], this.fontSize(), -0.5f, this.Z0 - this.ZRange / 2, TextRenderUtil.Get.TextureId, this.TextColor, Matrix4.Identity). Scale(this.fontHeight, this.fontHeight). Translate(this.Position.Center + new Vector2(0, (lines.Length / 2f - i) * this.fontHeight)); } } if (this.mForgroundImage.HasValue) { soBuilder. StartSimpleSprite(this.Z0 - this.ZRange / 2, this.mForgroundImage.Value, Color.White). Scale(this.Position.Size - new Vector2(2 * this.paddingX, 2 * this.paddingY)). Translate(this.Position.Center); } return(soBuilder.Build()); }
private void Start() { GetComponent <Button>().onClick.AddListener(() => { SceneObjectBuilder.CreateBuildingFromCatalogue(ItemData); UiController.Instance.Catalogue.gameObject.SetActive(false); }); }
private static async Task LoadScene() { var sceneManager = Instantiate(Resources.Load <GameObject>("SceneObjects/SceneManager")); sceneManager.AddComponent <InputHandler>(); CatalogueBuilder.Build(); ObjectDetailPanel.Build(); await SceneObjectBuilder.BuildScene(); Instantiate(Resources.Load <GameObject>("SceneObjects/Main Camera")); }
protected override SceneObject makeSceneObject() { var soBuilder = new SceneObjectBuilder(); if (this.mImages != null && this.mImages.Length > 0) { for (int i = 0; i < this.mImages.Length; i++) { soBuilder.StartSimpleSprite(this.Z0 - i * this.ZRange / this.mImages.Length, this.mImages[i].Texture, this.mImages[i].ModulationColor). Scale(this.Position.Size). Translate(this.Position.Center); } } return(soBuilder.Build()); }
public static SceneNPC CreateNPC(SceneMap map, SceneObjectBuilder builder) { var npcId = AutoIncrementGenerator.Get(MapManager.current.npcList); //var go = new GameObject ("NPC-"+npcId); var go = GameObject.CreatePrimitive(PrimitiveType.Capsule); go.name = "NPC-" + npcId; var obj = go.AddComponent <SceneNPC>(); obj.objectId = npcId; obj.resId = builder.res; obj.objectType = builder.type; obj.objectShape = builder.shape; obj.objectSize = builder.size; //var offset = CaculatePostionOffset (builder); //CreateCollider (go, builder); var offset = new Vector3(0, obj.objectSize.y, 0); var parent = map.transform; if (MapManager.selectionWave != null) { parent = MapManager.selectionWave.transform; } else if (MapManager.selectionGroup != null) { parent = MapManager.selectionGroup.transform; } go.transform.SetParent(parent); go.transform.position = selectionPosition + offset; go.transform.localScale = Vector3.one; go.transform.rotation = Quaternion.identity; map.AddNPC(obj); _isUpdated = true; Selection.activeGameObject = go; return(obj); }
protected override SceneObject makeSceneObject() { var pressOffset = this.isPressed && this.isHovered ? new Vector2(PressOffsetX, PressOffsetY) : new Vector2(0, 0); var background = this.isHovered ? this.BackgroundHover : this.mBackgroundNormal; var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). //TODO(v0.8) add press offset to clip area StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center + pressOffset). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (this.forgroundImage.HasValue) { soBuilder. StartSimpleSprite(this.Z0 - this.ZRange / 2, this.forgroundImage.Value, Color.White). Scale(this.Position.Size - new Vector2(2 * this.mPadding, 2 * this.mPadding)). Translate(this.Position.Center); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { if (string.IsNullOrWhiteSpace(this.Text)) { return(null); } var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). StartText(this.Text, this.fontSize(), -0.5f, this.Z0, TextRenderUtil.Get.TextureId, this.TextColor, Matrix4.Identity). Scale(this.fontHeight, this.fontHeight). Translate(this.Position.Center + new Vector2(0, this.fontHeight * this.lineCount() / 2)); if (this.Animation != null) { return(soBuilder.Build(polygons => this.Animation(polygons[0]))); } else { return(soBuilder.Build()); } }
protected override SceneObject makeSceneObject() { if (string.IsNullOrWhiteSpace(this.Text)) { return(null); } var soBuilder = new SceneObjectBuilder(). PixelSize(1 / SettingsWinforms.Get.GuiScale). Clip(this.Position.ClipArea). StartText(this.Text, -0.5f, 0, this.Z0, this.ZRange, this.TextColor). Scale(this.TextHeight). Translate(this.Position.Center + new Vector2(0, this.TextHeight * textSize.Y / 2)); if (this.Animation != null) { return(soBuilder.Build(polygons => this.Animation(polygons[0]))); } else { return(soBuilder.Build()); } }