Upgrades ui

This commit is contained in:
Martin 2022-12-16 12:20:37 +01:00
parent 6521ce1f92
commit c85345cba0
19 changed files with 582 additions and 175 deletions

View File

@ -0,0 +1,91 @@
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: sprite-vs:vert
frag: sprite-fs:frag
depthStencilState:
depthTest: false
depthWrite: false
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
rasterizerState:
cullMode: none
properties:
alphaThreshold: { value: 0.5 }
}%
CCProgram sprite-vs %{
precision highp float;
#include <builtin/uniforms/cc-global>
#if USE_LOCAL
#include <builtin/uniforms/cc-local>
#endif
#if SAMPLE_FROM_RT
#include <common/common-define>
#endif
in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;
out vec4 color;
out vec2 uv0;
vec4 vert () {
vec4 pos = vec4(a_position, 1);
#if USE_LOCAL
pos = cc_matWorld * pos;
#endif
#if USE_PIXEL_ALIGNMENT
pos = cc_matView * pos;
pos.xyz = floor(pos.xyz);
pos = cc_matProj * pos;
#else
pos = cc_matViewProj * pos;
#endif
uv0 = a_texCoord;
#if SAMPLE_FROM_RT
CC_HANDLE_RT_SAMPLE_FLIP(uv0);
#endif
color = a_color;
return pos;
}
}%
CCProgram sprite-fs %{
precision highp float;
#include <builtin/internal/embedded-alpha>
#include <builtin/internal/alpha-test>
in vec4 color;
#if USE_TEXTURE
in vec2 uv0;
#pragma builtin(local)
layout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture;
#endif
vec4 frag () {
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);
#if IS_GRAY
float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;
o.r = o.g = o.b = gray;
#endif
#endif
o *= color;
ALPHA_TEST(o);
return o;
}
}%

View File

@ -0,0 +1 @@
{"ver":"1.6.0","importer":"effect","imported":true,"uuid":"3c0cc5ba-c2cb-4948-a991-ea3b91b58798","files":[".json"],"subMetas":{},"userData":{"combinations":[{}]}}

View File

@ -1,12 +0,0 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "63c984ff-f414-4b17-947c-cf8c6e809a4e",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -1,142 +0,0 @@
[
{
"__type__": "cc.Prefab",
"_name": "UpgradeLevelPointUI",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "UpgradeLevelPointUI",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 6
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -12.5,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_contentSize": {
"__type__": "cc.Size",
"width": 20,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b52eZzV09InJK+jo6LzLIQ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "0a917d5c-2810-46e1-8332-63f00395d63a@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b0oW25W9NI85/atu15qR76"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "d316td07RIIriz5Jc4fIFq"
}
]

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "ce5459a7-0c87-44b9-af63-3a2854b890ca", "uuid": "c3e15fb0-6bf6-48bd-9a7d-c0bddc1f6030",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "6b4febd9-02c6-407b-83e4-ba4d38a59288", "uuid": "3e24da81-45db-4a4e-b84d-8e4fdb7d44b8",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -26,25 +26,28 @@
}, },
{ {
"__id__": 14 "__id__": 14
},
{
"__id__": 20
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 20
},
{
"__id__": 22
},
{
"__id__": 24
},
{ {
"__id__": 26 "__id__": 26
},
{
"__id__": 28
},
{
"__id__": 30
},
{
"__id__": 32
} }
], ],
"_prefab": { "_prefab": {
"__id__": 28 "__id__": 34
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -340,7 +343,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "LevelPoints", "_name": "Cost",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
@ -361,7 +364,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -63.985, "y": -33,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@ -397,6 +400,138 @@
"__prefab": { "__prefab": {
"__id__": 16 "__id__": 16
}, },
"_contentSize": {
"__type__": "cc.Size",
"width": 33.57,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "fbXhjtUG9CVpcniyjLku3O"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"__prefab": {
"__id__": 18
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 167,
"b": 34,
"a": 255
},
"_string": "300",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 20,
"_fontSize": 20,
"_fontFamily": "Arial",
"_lineHeight": 20,
"_overflow": 0,
"_enableWrapText": true,
"_font": {
"__uuid__": "c96b42a9-d20d-4c59-8e99-8ed749a715c8",
"__expectedType__": "cc.BitmapFont"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a4AECYqyxEk5ETjyuIkDrU"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "8ftf2pEX1N57cPayWX0BUw"
},
{
"__type__": "cc.Node",
"_name": "LevelPoints",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 21
},
{
"__id__": 23
}
],
"_prefab": {
"__id__": 25
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -63.985,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"__prefab": {
"__id__": 22
},
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 0, "width": 0,
@ -418,11 +553,11 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 14 "__id__": 20
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 18 "__id__": 24
}, },
"_resizeMode": 1, "_resizeMode": 1,
"_layoutType": 1, "_layoutType": 1,
@ -469,7 +604,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 21 "__id__": 27
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -496,7 +631,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 23 "__id__": 29
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -540,14 +675,14 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 25 "__id__": 31
}, },
"levelPointPrefab": { "levelPointPrefab": {
"__uuid__": "41ca6952-fa32-4e38-8d43-eec2e982533c", "__uuid__": "41ca6952-fa32-4e38-8d43-eec2e982533c",
"__expectedType__": "cc.Prefab" "__expectedType__": "cc.Prefab"
}, },
"levelPointsParent": { "levelPointsParent": {
"__id__": 14 "__id__": 20
}, },
"title": { "title": {
"__id__": 5 "__id__": 5
@ -555,6 +690,9 @@
"description": { "description": {
"__id__": 11 "__id__": 11
}, },
"cost": {
"__id__": 17
},
"_id": "" "_id": ""
}, },
{ {
@ -570,7 +708,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 27 "__id__": 33
}, },
"clickEvents": [], "clickEvents": [],
"_interactable": true, "_interactable": true,

View File

@ -0,0 +1,298 @@
[
{
"__type__": "cc.Prefab",
"_name": "UpgradeLevelPointUI",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "UpgradeLevelPointUI",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 8
},
{
"__id__": 10
},
{
"__id__": 12
}
],
"_prefab": {
"__id__": 14
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -12.5,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "UpgradedGraphics",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 7
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 4
},
"_contentSize": {
"__type__": "cc.Size",
"width": 20,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "13705VGy1EgI77YCh0/dGK"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 195,
"g": 139,
"b": 53,
"a": 255
},
"_spriteFrame": {
"__uuid__": "0a917d5c-2810-46e1-8332-63f00395d63a@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "699kaQdiFOVaLq5RRNJWMt"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5dLwgaQwRNG5BZNvGhc9YF"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"_contentSize": {
"__type__": "cc.Size",
"width": 20,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b52eZzV09InJK+jo6LzLIQ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "0a917d5c-2810-46e1-8332-63f00395d63a@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b0oW25W9NI85/atu15qR76"
},
{
"__type__": "10d0fuUwd1E24b6fVo7KYFK",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 13
},
"upgradedGraphics": {
"__id__": 2
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "8a4q+RjfdPHJzMdXLPbFju"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "d316td07RIIriz5Jc4fIFq"
}
]

View File

@ -0,0 +1,15 @@
import { _decorator, Component, Node } from "cc";
const { ccclass, property } = _decorator;
@ccclass("UpgradeLevelPointUI")
export class UpgradeLevelPointUI extends Component {
@property(Node) private upgradedGraphics: Node;
public init(): void {
this.upgradedGraphics.active = false;
}
public upgrade(): void {
this.upgradedGraphics.active = true;
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "10d0fb94-c1dd-44db-86fa-7d5a3b29814a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,4 +1,5 @@
import { Component, instantiate, Label, Node, Prefab, _decorator } from "cc"; import { Component, instantiate, Label, Node, Prefab, _decorator } from "cc";
import { UpgradeLevelPointUI } from "./UpgradeLevelPointUI";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass("UpgradeUI") @ccclass("UpgradeUI")
@ -7,14 +8,22 @@ export class UpgradeUI extends Component {
@property(Node) private levelPointsParent: Node; @property(Node) private levelPointsParent: Node;
@property(Label) private title: Label; @property(Label) private title: Label;
@property(Label) private description: Label; @property(Label) private description: Label;
@property(Label) private cost: Label;
public init(titleText: string, descriptionText: string, levels: number): void { public init(titleText: string, descriptionText: string, levels: number): void {
for (let i = 0; i < levels; i++) { for (let i = 0; i < levels; i++) {
const node: Node = instantiate(this.levelPointPrefab); const node: Node = instantiate(this.levelPointPrefab);
node.setParent(this.levelPointsParent); node.setParent(this.levelPointsParent);
const levelPointUI = node.getComponent(UpgradeLevelPointUI);
levelPointUI.init();
if (i < 3) {
levelPointUI.upgrade();
}
} }
this.title.string = titleText; this.title.string = titleText;
this.description.string = descriptionText; this.description.string = descriptionText;
this.cost.string = "55";
} }
} }