This commit is contained in:
2026-07-14 11:44:07 +08:00
commit 4409c7b031
5906 changed files with 6959792 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
import { _decorator, Button, Component, Label, Node, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
import { SdkMgr } from '../framework/sdk/SdkMgr';
const { ccclass, property } = _decorator;
@ccclass('AddHeartPanel')
export class AddHeartPanel extends PanelBase {
static instance: AddHeartPanel;
@property({ type: Button })
addPower: Button = null;
@property({ type: Button })
closeBtn: Button = null;
onLoad() {
AddHeartPanel.instance = this;
this.closeBtn.node.on(Button.EventType.CLICK, this.closeBtnCallBack, this);
this.addPower.node.on(Button.EventType.CLICK, this.addPowerCallBack, this);
}
addPowerCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
SdkMgr.instance.playerRewardAds(() => {
LocalSaveMgr.instance.adsAddPower()
UIManager.instance.closePanel(AddHeartPanel)
})
}
closeBtnCallBack(button: Button) {
AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.closePanel(AddHeartPanel)
}
start() {
}
}
+1
View File
@@ -0,0 +1 @@
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"917bf6d3-04a8-4289-b46b-037db3226eca","files":[],"subMetas":{},"userData":{}}
+71
View File
@@ -0,0 +1,71 @@
import { _decorator, Button, Component, Label, Node, Sprite, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
const { ccclass, property } = _decorator;
@ccclass('LoadingPanel')
export class LoadingPanel extends PanelBase {
static instance: LoadingPanel;
@property({ type: Sprite })
loadingSprite: Sprite = null;
@property
fillDuration: number = 5; // 填充持续时间,单位为秒
private fillAmount: number = 0; // 当前填充量
startFill() {
this.schedule(this.updateFill, 0.01); // 每0.01秒更新一次填充量
}
protected onOpen(): void {
LoadingPanel.instance.startFill()
}
loadingComplete: boolean = false
completeCallback = null
onLoadingComplete(callBack) {
this.completeCallback = callBack
this.loadingComplete = true
if (this.fillAmount < 1) {
this.fillDuration = 1
} else {
UIManager.instance.closePanel(LoadingPanel)
callBack()
}
}
protected onDestroy(): void {
this.unschedule(this.updateFill);
}
updateFill() {
if (this.fillAmount < 1) {
this.fillAmount += 0.01 / this.fillDuration; // 根据持续时间逐步增加填充量
this.loadingSprite.fillRange = this.fillAmount; // 更新 Sprite 的填充量
} else {
this.unschedule(this.updateFill); // 填充完成后停止更新
if (this.loadingComplete) {
UIManager.instance.closePanel(LoadingPanel)
this.completeCallback()
}
}
}
onLoad() {
LoadingPanel.instance = this;
}
}
+1
View File
@@ -0,0 +1 @@
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"f4b84cb4-e7a2-4582-ad1b-d199ea5cebe4","files":[],"subMetas":{},"userData":{}}
+61
View File
@@ -0,0 +1,61 @@
import { _decorator, Button, Component, EventTouch, Input, input, instantiate, Label, Node, Prefab } from 'cc';
import { PanelBase } from '../framework/ui/PanelBase';
import { FPSCameraController } from '../FPSCameraController';
import { GameController } from '../GameController';
import { TargetIconItem } from './TargetIconItem';
import { EventCenter } from '../EventCenter';
import { UIManager } from '../framework/ui/UIManager';
import { SdkMgr } from '../framework/sdk/SdkMgr';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { AssetController } from '../AssetController';
const { ccclass, property } = _decorator;
@ccclass('LosePanel')
export class LosePanel extends PanelBase {
static instance: LosePanel = null
@property(Button)
closeBtn: Button = null;
@property(Button)
replayBtn: Button = null;
@property(Button)
addTimeBtn: Button = null;
@property(Label)
remainLabel: Label = null;
onLoad() {
LosePanel.instance = this
this.closeBtn.node.on(Button.EventType.CLICK, this.onClickClose, this);
this.replayBtn.node.on(Button.EventType.CLICK, this.onClickReplay, this);
this.addTimeBtn.node.on(Button.EventType.CLICK, this.onClickAddTime, this);
}
onClickClose() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
GameController.getInstance().backMain()
}
onClickReplay() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
GameController.getInstance().gameRestart()
}
onClickAddTime() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
SdkMgr.instance.playerRewardAds(() => {
GameController.getInstance().curLevel.addTimer()
GameController.getInstance().curLevel.ContinueRun()
UIManager.instance.closePanel(LosePanel)
})
}
protected onOpen(): void {
LosePanel.instance.remainLabel.string = "剩余: " + GameController.getInstance().curLevel.getAliveEnemeyCount().toString()
}
}
+1
View File
@@ -0,0 +1 @@
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"35c17ce9-c80c-4430-962b-f46ead6a2e73","files":[],"subMetas":{},"userData":{}}
+379
View File
@@ -0,0 +1,379 @@
import { _decorator, Asset, Button, Component, debug, instantiate, Label, Node, Prefab, randomRange, Sprite, sys, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
import { DataMgr } from '../framework/data/DataMgr';
import { Weapon } from '../data/ConfigData';
import { AddHeartPanel } from './AddHeartPanel';
import { SdkMgr } from '../framework/sdk/SdkMgr';
import { EventCenter } from '../EventCenter';
import { SideTipPanel } from './SideTipPanel';
import { SharePanel } from './SharePanel';
const { ccclass, property } = _decorator;
@ccclass('MainPanel')
export class MainPanel extends PanelBase {
static instance: MainPanel;
@property({ type: Button })
startBtn: Button = null;
@property({ type: Button })
leftBtn: Button = null;
@property({ type: Button })
right: Button = null;
@property({ type: Button })
equip: Button = null;
@property({ type: Button })
clear: Button = null;
@property({ type: Button })
addMoneyBtn: Button = null;
@property({ type: Button })
buy: Button = null;
@property({ type: Node })
equiped: Node = null;
@property({ type: Label })
weaponName: Label = null;
@property({ type: Label })
gunPrice: Label = null;
@property({ type: Label })
heart: Label = null;
@property({ type: Label })
heartTimer: Label = null;
@property({ type: Label })
coin: Label = null;
@property({ type: Button })
addHeartBtn: Button = null;
@property({ type: Button })
shareBtn: Button = null;
@property({ type: Prefab })
weaponSelectPrefab: Prefab = null;
@property(Prefab)
flyMoneyPrefab: Prefab = null;
@property(Node)
flyMoneyContent: Node = null;
@property(Node)
fingerNode: Node = null;
@property({ type: Button })
sideTipBtn: Button = null;
weaponDatas: Array<Weapon> = []
private weaponOffset: number = 1000
private curSelectIndex: number = 0
@property({ type: Node })
weaponContent: Node = null;
protected onOpen(): void {
MainPanel.instance.refresh()
}
refresh() {
var weapons = DataMgr.getInstance().GetDatas(Weapon)
this.weaponDatas = weapons
let equipedIndex: number = 0
for (let index = 0; index < weapons.length; index++) {
let data = weapons[index]
var item = instantiate(this.weaponSelectPrefab)
item.setParent(this.weaponContent)
let sprite = item.getChildByPath("Sprite").getComponent(Sprite)
AssetController.instance.loadSetSprite(`weaponSprite/${data.spriteName}`, sprite);
item.getChildByPath("Label").getComponent(Label).string = data.gunName
if (data.id == LocalSaveMgr.instance.playerData.equipedWeapon) {
equipedIndex = index
}
}
if (sys.platform == sys.Platform.WECHAT_GAME) {
this.sideTipBtn.node.active = false
const date: Date = new Date();
const dayOfMonth: number = date.getDate();
if (LocalSaveMgr.instance.playerData.day != dayOfMonth) {
this.shareBtn.node.active = true
}
} else if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
this.sideTipBtn.node.active = true
this.shareBtn.node.active = false
}
this.fingerNode.active = !LocalSaveMgr.instance.playerData.haveTutorial
this.heart.string = LocalSaveMgr.instance.playerData.power.toString()
this.coin.string = LocalSaveMgr.instance.playerData.coin.toString()
this.setToIndex(equipedIndex, false)
}
protected update(dt: number): void {
if (LocalSaveMgr.instance.playerData.isOnTimerRun) {
let totalSeconds = Math.ceil(LocalSaveMgr.instance.getPowerCD())
totalSeconds = Math.ceil(totalSeconds);
let minutes = Math.floor(totalSeconds / 60);
let seconds = totalSeconds % 60;
// 将分钟和秒格式化为两位数
let formattedMinutes = minutes < 10 ? `0${minutes}` : `${minutes}`;
let formattedSeconds = seconds < 10 ? `0${seconds}` : `${seconds}`;
// 组合成 00:00 的格式
let formattedTime = `${formattedMinutes}:${formattedSeconds}`;
this.heartTimer.string = formattedTime
} else {
this.heartTimer.string = "已满"
}
this.heart.string = LocalSaveMgr.instance.playerData.power.toString()
}
setToIndex(index: number, widthAim: boolean) {
this.curSelectIndex = index
if (!widthAim) {
this.weaponContent.setPosition(-this.weaponOffset * index, 0, 0)
} else {
let newPos = new Vec3(-this.weaponOffset * index, 0, 0)
tween(this.weaponContent)
.to(0.3, { position: newPos })
.start()
}
this.refreshToIndex()
}
refreshToIndex() {
let ownedWeapons = LocalSaveMgr.instance.playerData.ownWeapon
let owned: boolean = false
for (let index = 0; index < ownedWeapons.length; index++) {
let element = ownedWeapons[index];
console.log("刷新", this.weaponDatas[this.curSelectIndex].id, element, ownedWeapons.length, index)
if (element == this.weaponDatas[this.curSelectIndex].id) {
owned = true
break
}
}
let equiped: boolean = LocalSaveMgr.instance.playerData.equipedWeapon == this.weaponDatas[this.curSelectIndex].id
// this.weaponName.string = this.weaponDatas[this.curSelectIndex].gunName
this.gunPrice.string = this.weaponDatas[this.curSelectIndex].coin.toString()
this.equiped.active = false
this.buy.node.active = false
this.equip.node.active = false
if (equiped) {
this.equiped.active = true
} else if (owned) {
this.equip.node.active = true
} else {
this.buy.node.active = true
if (LocalSaveMgr.instance.playerData.coin >= this.weaponDatas[this.curSelectIndex].coin) {
this.buy.interactable = true;
this.buy.getComponent(Sprite).grayscale = false
} else {
this.buy.interactable = false;
this.buy.getComponent(Sprite).grayscale = true
}
}
if (this.curSelectIndex == 0) {
this.leftBtn.node.active = false
} else {
this.leftBtn.node.active = true
}
if (this.curSelectIndex == this.weaponDatas.length - 1) {
this.right.node.active = false
} else {
this.right.node.active = true
}
}
clickLeft() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
if (this.curSelectIndex > 0) {
this.setToIndex(this.curSelectIndex - 1, true)
}
}
clickRight() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
if (this.curSelectIndex < this.weaponDatas.length - 1) {
this.setToIndex(this.curSelectIndex + 1, true)
}
}
clickEquipBtn() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
LocalSaveMgr.instance.equipWeapon(this.weaponDatas[this.curSelectIndex].id)
this.refreshToIndex()
}
clickBuyBtn() {
LocalSaveMgr.instance.addCoin(-this.weaponDatas[this.curSelectIndex].coin)
AudioMgr.inst.playOneShot(AssetController.instance.click)
LocalSaveMgr.instance.buyWeapon(this.weaponDatas[this.curSelectIndex].id)
this.refreshToIndex()
}
clickClear() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
LocalSaveMgr.instance.clearData()
}
clickAddHeartBtn() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.openPanel(AddHeartPanel)
}
clickAddMoneyBtn() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
SdkMgr.instance.playerRewardAds(() => {
let addPoint = 200
let fromeMoney = LocalSaveMgr.instance.playerData.coin
LocalSaveMgr.instance.addCoin(addPoint)
let endMoney = LocalSaveMgr.instance.playerData.coin
this.flyMoney(fromeMoney, endMoney)
})
}
flyShareMoney(fromMoney: number, endMoney: number) {
AudioMgr.inst.playOneShot(AssetController.instance.getCoin)
for (let index = 0; index < 10; index++) {
let item = instantiate(this.flyMoneyPrefab)
item.setParent(this.flyMoneyContent)
item.setPosition(new Vec3(0, 0, 0))
let delay = index * 0.1
tween(item)
.by(0.3, { position: new Vec3(randomRange(-150, 150), randomRange(-150, 150), 0) })
.delay(delay)
.to(0.6, { worldPosition: this.coin.node.getWorldPosition() })
.call(() => {
item.destroy()
})
.start()
}
new Tween({ value: fromMoney })
.delay(0.9)
.to(1, { value: endMoney }, {
onUpdate: (target, ratio) => {
// 在每一帧更新时调用
let currentValue = Math.floor(target.value);
if (this.coin != null)
this.coin.string = currentValue.toString();
}
}).call(() => {
if (this.addMoneyBtn != null)
this.addMoneyBtn.interactable = true
})
.start();
}
flyMoney(fromMoney: number, endMoney: number) {
this.addMoneyBtn.interactable = false
AudioMgr.inst.playOneShot(AssetController.instance.getCoin)
for (let index = 0; index < 10; index++) {
let item = instantiate(this.flyMoneyPrefab)
item.setParent(this.flyMoneyContent)
item.setPosition(this.addMoneyBtn.node.getPosition())
let delay = index * 0.1
tween(item)
.by(0.3, { position: new Vec3(randomRange(-150, 150), randomRange(-150, 150), 0) })
.delay(delay)
.to(0.6, { worldPosition: this.coin.node.getWorldPosition() })
.call(() => {
item.destroy()
})
.start()
}
new Tween({ value: fromMoney })
.delay(0.9)
.to(1, { value: endMoney }, {
onUpdate: (target, ratio) => {
// 在每一帧更新时调用
let currentValue = Math.floor(target.value);
if (this.coin != null)
this.coin.string = currentValue.toString();
}
}).call(() => {
if (this.addMoneyBtn != null)
this.addMoneyBtn.interactable = true
})
.start();
}
onCoinCountChange() {
MainPanel.instance.coin.string = LocalSaveMgr.instance.playerData.coin.toString()
MainPanel.instance.refreshToIndex()
}
clickSideTipBtn() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
console.log("openPanel SideTipPanel")
UIManager.instance.openPanel(SideTipPanel)
}
protected onDestroy(): void {
EventCenter.coinCountChange.off("coinCountChange", this.onCoinCountChange)
}
clickShareBtn() {
UIManager.instance.openPanel(SharePanel)
}
onLoad() {
MainPanel.instance = this;
this.startBtn.node.on(Button.EventType.CLICK, this.startBtnCallBack, this);
this.leftBtn.node.on(Button.EventType.CLICK, this.clickLeft, this);
this.right.node.on(Button.EventType.CLICK, this.clickRight, this);
this.equip.node.on(Button.EventType.CLICK, this.clickEquipBtn, this);
this.buy.node.on(Button.EventType.CLICK, this.clickBuyBtn, this);
this.sideTipBtn.node.on(Button.EventType.CLICK, this.clickSideTipBtn, this);
this.shareBtn.node.on(Button.EventType.CLICK, this.clickShareBtn, this);
this.clear.node.on(Button.EventType.CLICK, this.clickClear, this);
this.addHeartBtn.node.on(Button.EventType.CLICK, this.clickAddHeartBtn, this);
this.addMoneyBtn.node.on(Button.EventType.CLICK, this.clickAddMoneyBtn, this);
EventCenter.coinCountChange.on("coinCountChange", this.onCoinCountChange).bind(this)
}
startBtnCallBack() {
GameController.getInstance().gameStart()
}
}
+1
View File
@@ -0,0 +1 @@
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"225f0e63-c4dc-4a85-b8f7-bed528fc1a07","files":[],"subMetas":{},"userData":{}}
+460
View File
@@ -0,0 +1,460 @@
import { _decorator, animation, Animation, AnimationComponent, Button, Component, EventTouch, Input, input, instantiate, Label, math, Node, Prefab, randomRange, randomRangeInt, screen, Screen, sys, tween, Vec2, Vec3, view } from 'cc';
import { PanelBase } from '../framework/ui/PanelBase';
import { FPSCameraController } from '../FPSCameraController';
import { GameController } from '../GameController';
import { TargetIconItem } from './TargetIconItem';
import { EventCenter } from '../EventCenter';
import { UIManager } from '../framework/ui/UIManager';
import { QingBaoPanel } from './QingBaoPanel';
import { SettingPanel } from './SettingPanel';
import { SdkMgr } from '../framework/sdk/SdkMgr';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { AssetController } from '../AssetController';
import { Ragdoll } from '../../Ragdoll/Ragdoll';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
const { ccclass, property } = _decorator;
@ccclass('PlayPanel')
export class PlayPanel extends PanelBase {
static instance: PlayPanel = null
@property(Node)
moveNode: Node = null; // 相机节点
@property(Node)
saoMiaoTip: Node = null; // 相机节点
@property(Node)
aimContent: Node = null;
@property(Node)
closeAim: Node = null;
@property(Node)
cancelLabel: Node = null;
@property(Prefab)
targetIconPrefab: Prefab = null;
@property(Node)
targetIconParent: Node = null;
@property(Button)
anim: Button = null;
@property(Button)
qingBao: Button = null;
@property(Label)
timerLabel: Label = null;
@property(Button)
saoMiao: Button = null;
@property(Button)
setting: Button = null;
@property(Label)
levelIndexLabel: Label = null;
@property(Button)
fire: Button = null;
@property(Node)
finger: Node = null;
@property(Node)
qingBaoResultNode: Node = null;
@property(Button)
qingBaoResultBtn: Button = null;
@property(AnimationComponent)
alienAnim: AnimationComponent = null;
@property(Label)
tutorialLabel: Label = null;
@property(Node)
tutorialLabelNode: Node = null;
@property(Node)
targetNode: Node = null;
@property(Node)
tipNode1: Node = null;
@property(Node)
tipNode2: Node = null;
@property(Node)
tipNode3: Node = null;
@property([Animation])
shootAnimations: Animation[] = [];
targetIcons: Array<TargetIconItem> = [];
onLoad() {
PlayPanel.instance = this
// Register the touch start event
this.moveNode.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.moveNode.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.moveNode.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
this.anim.node.on(Button.EventType.CLICK, this.onClickAim, this);
this.fire.node.on(Button.EventType.CLICK, this.onClickFire, this);
this.qingBao.node.on(Button.EventType.CLICK, this.onClickQingBao, this);
this.qingBaoResultBtn.node.on(Button.EventType.CLICK, this.onClickQingBaoResult, this);
this.saoMiao.node.on(Button.EventType.CLICK, this.onClickSaoMiao, this);
this.setting.node.on(Button.EventType.CLICK, this.onClickSetting, this);
EventCenter.onEnemyDie.on(null, this.refreshTargetCount).bind(this)
}
onClickSetting() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.openPanel(SettingPanel)
}
showTimer() {
let totalSeconds = GameController.getInstance().curLevel.timer
totalSeconds = Math.ceil(totalSeconds);
let minutes = Math.floor(totalSeconds / 60);
let seconds = totalSeconds % 60;
// 将分钟和秒格式化为两位数
let formattedMinutes = minutes < 10 ? `0${minutes}` : `${minutes}`;
let formattedSeconds = seconds < 10 ? `0${seconds}` : `${seconds}`;
// 组合成 00:00 的格式
let formattedTime = `${formattedMinutes}:${formattedSeconds}`;
this.timerLabel.string = formattedTime
}
onClickQingBao() {
if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
tt.reportAnalytics('use_prop', {
level: GameController.getInstance().curLevel.levelIndex,
});
}
AudioMgr.inst.playOneShot(AssetController.instance.click)
SdkMgr.instance.playerRewardAds(() => {
UIManager.instance.openPanel(QingBaoPanel)
this.closeTip()
this.qingBaoResultNode.active = true
this.qingBao.node.active = false
})
}
onClickQingBaoResult() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.openPanel(QingBaoPanel)
this.closeTip()
}
isOpenSaomiao: boolean = false
offset: Vec2
onClickSaoMiao() {
if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
tt.reportAnalytics('use_prop', {
level: GameController.getInstance().curLevel.levelIndex,
});
}
AudioMgr.inst.playOneShot(AssetController.instance.click)
SdkMgr.instance.playerRewardAds(() => {
this.saoMiaoTip.active = true
GameController.getInstance().curLevel.SetSaoMiaoTarget()
this.offset = new Vec2(randomRange(-200, 200), randomRange(-200, 200))
this.updateSaomiao()
this.isOpenSaomiao = true
this.closeTip()
})
}
tipTimer = 0;
onTip: boolean = false
protected update(dt: number): void {
this.showTimer()
if (!this.onStep && !this.onTip)
this.tipTimer += dt
if (!this.onTip && this.tipTimer > 30) {
this.startTip()
}
}
startTip() {
this.onTip = true
AudioMgr.inst.playOneShot(AssetController.instance.xiao)
this.tipTimer = 0
this.tipNode1.active = true
this.tipNode2.active = true
this.tipNode3.active = true
this.alienAnim.play()
}
closeTip() {
this.onTip = false
this.tipTimer = 0
this.tipNode1.active = false
this.tipNode2.active = false
this.tipNode3.active = false
}
updateTargetPos() {
let target = this.tutorialTarget
if (!target) return;
if (target.isDie) {
this.saoMiaoTip.active = false
this.isOpenSaomiao = false
}
// 获取 3D 物体的世界坐标
let worldPos = target.centerNode.getWorldPosition();
// 获取主摄像机
let camera = FPSCameraController.getInstance().camera;
// 将世界坐标转换为屏幕坐标
let uiPos = camera.convertToUINode(worldPos, this.node);
// 设置 UI 节点的位置
this.targetNode.position = uiPos;
if (this.targetNode.position.y < 0 && Math.abs(this.targetNode.position.x) < 30) {
this.EnterStep3()
FPSCameraController.getInstance().setTutorialRotate()
}
}
protected lateUpdate(dt: number): void {
this.updateSaomiao()
this.updateTargetPos()
// this.updateQingBao()
}
// updateQingBao() {
// if (this.qingBaoResultNode.active) {
// if (!GameController.getInstance().curLevel.haveQingBaoTarget()) {
// this.switchAim(this.isOnAim)
// }
// }
// }
updateSaomiao() {
let target = GameController.getInstance().curLevel.saoMiaoTarget
if (!target) return;
if (target.isDie) {
this.saoMiaoTip.active = false
this.isOpenSaomiao = false
}
if (!this.isOpenSaomiao) return
// 获取 3D 物体的世界坐标
let worldPos = target.centerNode.getWorldPosition();
// 获取主摄像机
let camera = FPSCameraController.getInstance().camera;
// 将世界坐标转换为屏幕坐标
let uiPos = camera.convertToUINode(worldPos, this.node);
// 设置 UI 节点的位置
// console.log(uiPos)
uiPos = new Vec3(uiPos.x + this.offset.x, uiPos.y + this.offset.y, 0)
this.saoMiaoTip.position = uiPos;
}
tutorialTarget: Ragdoll
protected onOpen(): void {
PlayPanel.instance.switchAim(false)
PlayPanel.instance.initEnemies()
this.levelIndexLabel.string = `关卡 ${GameController.getInstance().curLevel.levelIndex}`
if (GameController.getInstance().curLevel.levelIndex == 1 && !LocalSaveMgr.instance.playerData.haveTutorial) {
this.onStep = true
}
if (this.onStep) {
this.EnterStep1()
this.tutorialTarget = GameController.getInstance().curLevel.getTutorialAliveEnemey()
console.log("Player panel", this.tutorialTarget)
} else {
this.targetNode.active = false
this.finger.active = false
this.tutorialLabelNode.active = false
}
this.qingBaoResultNode.active = false
}
isOnAim: boolean = false
switchAim(onAim: boolean) {
this.anim.node.active = !onAim
this.fire.node.active = onAim
this.isOnAim = onAim
this.cancelLabel.active = onAim
this.qingBao.node.active = !onAim && !GameController.getInstance().curLevel.haveQingBaoTarget()
this.qingBaoResultNode.active = !onAim && GameController.getInstance().curLevel.haveQingBaoTarget()
this.saoMiao.node.active = !onAim
this.aimContent.active = onAim
this.closeAim.active = !onAim
GameController.getInstance().curLevel.gunNode.active = !onAim
}
refreshTargetCount() {
let self = PlayPanel.instance
let aliveCount = GameController.getInstance().curLevel.aliveCount
for (let index = 0; index < self.targetIcons.length; index++) {
if (index < aliveCount) {
self.targetIcons[index].switchActive(true)
} else {
self.targetIcons[index].switchActive(false)
}
}
}
initEnemies() {
let count = GameController.getInstance().curLevel.enemies.length
console.log("目标外星人个数", count)
for (let index = 0; index < count; index++) {
var item = instantiate(this.targetIconPrefab)
item.parent = this.targetIconParent
let iconItem = item.getComponent(TargetIconItem)
this.targetIcons.push(iconItem)
iconItem.switchActive(true)
}
}
onClickAim() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
FPSCameraController.getInstance().onAimButtonClick(true)
this.switchAim(true)
if (this.onStep) {
this.EnterStep2()
}
}
limitFire: boolean = false
onClickFire() {
if (this.limitFire) return
if (this.onStep) {
this.finishTutorial()
}
this.closeTip()
AudioMgr.inst.playOneShot(AssetController.instance.fire)
let result = FPSCameraController.getInstance().shoot()
if (result) {
let effect = this.shootAnimations[randomRangeInt(0, this.shootAnimations.length)]
effect.node.active = true
effect.play()
this.scheduleOnce(() => {
effect.node.active = false
}, 0.8)
}
let self = this
self.limitFire = true
tween(this.aimContent)
.to(0.05, { scale: new Vec3(1, 1, 1), position: new Vec3(0, 120, 0) })
.to(0.05, { scale: new Vec3(0.8, 0.8, 1), position: new Vec3(0, 0, 0) })
.call(() => {
self.limitFire = false
})
.start()
}
downTime: Date
startTouchPos: Vec2 = null
onTouchStart(event: EventTouch) {
FPSCameraController.getInstance().onTouchStart(event)
this.downTime = new Date();
this.startTouchPos = event.getLocation()
}
onTouchMove(event: EventTouch) {
FPSCameraController.getInstance().onTouchMove(event)
}
onTouchEnd(event: EventTouch) {
if (this.isOnAim) {
let now = new Date();
var offset = now.getTime() - this.downTime.getTime()
let moveDetal = Math.abs(this.startTouchPos.x - event.getLocation().x) + Math.abs(this.startTouchPos.y - event.getLocation().y)
// console.log("offset", offset, moveDetal)
if (!this.onStep)
if (offset < 200 && moveDetal < 20) {
FPSCameraController.getInstance().onAimButtonClick(false)
this.switchAim(false)
}
}
}
EnterStep1() {
this.targetNode.active = true
this.finger.active = true
this.tutorialLabel.string = "点击瞄准按钮"
this.moveNode.active = false
this.tutorialLabelNode.active = true
}
onStep: boolean = false
EnterStep2() {
this.finger.active = false
this.tutorialLabel.string = "滑动屏幕,瞄准目标"
this.moveNode.active = true
this.fire.node.active = false
this.cancelLabel.active = false
}
EnterStep3() {
this.fire.node.active = true
this.finger.active = true
this.tutorialLabel.string = "点击开火按钮"
this.moveNode.active = false
this.cancelLabel.active = false
}
finishTutorial() {
this.targetNode.active = false
this.finger.active = false
this.tutorialLabelNode.active = false
this.tutorialLabel.string = "点击开火按钮"
this.moveNode.active = true
this.onStep = false
this.tutorialTarget = null
LocalSaveMgr.instance.completeTutorial()
this.cancelLabel.active = true
}
protected onDestroy(): void {
PlayPanel.instance = null
EventCenter.onEnemyDie.off(null, this.refreshTargetCount)
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "a66cd6ea-f167-454e-857a-696e1ce3bc61",
"files": [],
"subMetas": {},
"userData": {}
}
+40
View File
@@ -0,0 +1,40 @@
import { _decorator, Button, Component, EventTouch, Input, input, instantiate, Node, Prefab } from 'cc';
import { PanelBase } from '../framework/ui/PanelBase';
import { FPSCameraController } from '../FPSCameraController';
import { GameController } from '../GameController';
import { TargetIconItem } from './TargetIconItem';
import { EventCenter } from '../EventCenter';
import { UIManager } from '../framework/ui/UIManager';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { AssetController } from '../AssetController';
import { PlayPanel } from './PlayPanel';
const { ccclass, property } = _decorator;
@ccclass('QingBaoPanel')
export class QingBaoPanel extends PanelBase {
static instance: QingBaoPanel = null
@property(Button)
closeBtn: Button = null;
onLoad() {
QingBaoPanel.instance = this
this.closeBtn.node.on(Button.EventType.CLICK, this.onClickClose, this);
}
onClickClose() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.closePanel(QingBaoPanel)
}
protected onOpen(): void {
FPSCameraController.getInstance().showQingBao()
}
protected onClose(): void {
FPSCameraController.getInstance().closeQingBao()
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "1ce9cf6b-89b7-440d-bc2e-d90f2e914d1f",
"files": [],
"subMetas": {},
"userData": {}
}
+95
View File
@@ -0,0 +1,95 @@
import { _decorator, Button, Component, Label, Node, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
const { ccclass, property } = _decorator;
@ccclass('SettingPanel')
export class SettingPanel extends PanelBase {
static instance: SettingPanel;
@property({ type: Button })
restartBtn: Button = null;
@property({ type: Button })
closeBtn: Button = null;
@property({ type: Button })
toMainBtn: Button = null;
@property({ type: UISwitcher })
soundSwitcher: UISwitcher = null;
@property({ type: UISwitcher })
musicSwitcher: UISwitcher = null;
@property({ type: Node })
music: Node = null;
@property({ type: Node })
sound: Node = null;
onLoad() {
SettingPanel.instance = this;
this.closeBtn.node.on(Button.EventType.CLICK, this.closeBtnCallBack, this);
this.restartBtn.node.on(Button.EventType.CLICK, this.restartCallBack, this);
this.toMainBtn.node.on(Button.EventType.CLICK, this.toMainCallBack, this);
this.node.active = false;
this.soundSwitcher.addCallBack(this.soundCallBack)
this.musicSwitcher.addCallBack(this.musicCallBack)
}
restartCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
GameController.getInstance().gameRestart()
}
toMainCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
GameController.getInstance().backMain()
}
soundCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
LocalSaveMgr.instance.activeSound(SettingPanel.instance.soundSwitcher.value)
}
musicCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
console.log("musicCallBack")
LocalSaveMgr.instance.activeMusic(SettingPanel.instance.musicSwitcher.value)
}
refresh() {
GameController.getInstance().curLevel.pause()
}
protected onOpen(): void {
SettingPanel.instance.refresh()
SettingPanel.instance.soundSwitcher.SetValue(!LocalSaveMgr.instance.playerData.muteSound)
SettingPanel.instance.musicSwitcher.SetValue(!LocalSaveMgr.instance.playerData.muteMusic)
}
closeBtnCallBack(button: Button) {
GameController.getInstance().curLevel.ContinueRun()
AudioMgr.inst.playOneShot(AssetController.instance.click)
// AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.closePanel(SettingPanel)
}
start() {
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "9c4d561f-c50d-4814-b227-2a0206669e69",
"files": [],
"subMetas": {},
"userData": {}
}
+64
View File
@@ -0,0 +1,64 @@
import { _decorator, Button, Component, Label, Node, sys, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
import { SdkMgr } from '../framework/sdk/SdkMgr';
import { WXSdk } from '../framework/sdk/WXSdk';
import { MainPanel } from './MainPanel';
const { ccclass, property } = _decorator;
@ccclass('SharePanel')
export class SharePanel extends PanelBase {
static instance: SharePanel;
@property({ type: Button })
shareBtn: Button = null;
@property({ type: Button })
closeBtn: Button = null;
onLoad() {
SharePanel.instance = this;
this.closeBtn.node.on(Button.EventType.CLICK, this.closeBtnCallBack, this);
this.shareBtn.node.on(Button.EventType.CLICK, this.shareCallBack, this);
}
activeShareBtn() {
const date: Date = new Date();
const dayOfMonth: number = date.getDate();
if (LocalSaveMgr.instance.playerData.day == dayOfMonth) {
this.shareBtn.node.active = false
} else {
this.shareBtn.node.active = true
}
}
shareCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
if (sys.platform == sys.Platform.WECHAT_GAME)
WXSdk.instance.initativeShare()
let fromeMoney = LocalSaveMgr.instance.playerData.coin
LocalSaveMgr.instance.addCoin(200)
LocalSaveMgr.instance.setShareTime()
let endMoney = LocalSaveMgr.instance.playerData.coin
MainPanel.instance.flyShareMoney(fromeMoney, endMoney)
UIManager.instance.closePanel(SharePanel)
}
closeBtnCallBack(button: Button) {
AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.closePanel(SharePanel)
}
start() {
this.activeShareBtn()
}
}
+1
View File
@@ -0,0 +1 @@
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"a5f9f430-fa04-4fb2-8af4-0e7176a078ce","files":[],"subMetas":{},"userData":{}}
+64
View File
@@ -0,0 +1,64 @@
import { _decorator, Button, Component, Label, Node, sys, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
import { DYSdk } from '../framework/sdk/DYSdk';
const { ccclass, property } = _decorator;
@ccclass('SideTipPanel')
export class SideTipPanel extends PanelBase {
static instance: SideTipPanel;
@property({ type: Button })
rewardBtn: Button = null;
@property({ type: Button })
closeBtn: Button = null;
@property({ type: Node })
getNode: Node = null;
onLoad() {
SideTipPanel.instance = this;
this.closeBtn.node.on(Button.EventType.CLICK, this.closeBtnCallBack, this);
this.rewardBtn.node.on(Button.EventType.CLICK, this.rewardCallBack, this);
}
rewardCallBack() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME)
DYSdk.instance.navigateToScene()
LocalSaveMgr.instance.addCoin(888)
LocalSaveMgr.instance.setSideTip();
this.getNode.active = LocalSaveMgr.instance.playerData.haveGetSideReward
this.rewardBtn.node.active = !LocalSaveMgr.instance.playerData.haveGetSideReward
}
protected onOpen(): void {
this.getNode.active = LocalSaveMgr.instance.playerData.haveGetSideReward
this.rewardBtn.node.active = !LocalSaveMgr.instance.playerData.haveGetSideReward
}
closeBtnCallBack(button: Button) {
AudioMgr.inst.playOneShot(AssetController.instance.click)
// AudioMgr.inst.playOneShot(AssetController.instance.click)
UIManager.instance.closePanel(SideTipPanel)
}
start() {
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "b585f61b-a132-4319-aba3-2942d022565b",
"files": [],
"subMetas": {},
"userData": {}
}
+26
View File
@@ -0,0 +1,26 @@
import { _decorator, color, Component, Node, Sprite, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('TargetIconItem')
export class TargetIconItem extends Component {
@property(Sprite)
sprite: Sprite = null;
@property(SpriteFrame)
activeFrame: SpriteFrame = null;
@property(SpriteFrame)
dieFrame: SpriteFrame = null;
switchActive(active: boolean) {
if (active) {
this.sprite.spriteFrame = this.activeFrame
} else {
this.sprite.spriteFrame = this.dieFrame
}
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "60379639-8194-4623-a1aa-39248b153655",
"files": [],
"subMetas": {},
"userData": {}
}
+256
View File
@@ -0,0 +1,256 @@
import { _decorator, Button, Component, instantiate, Label, math, Node, Prefab, randomRange, Sprite, Tween, tween, Vec3 } from 'cc';
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
import { UIManager } from '../framework/ui/UIManager';
import { UISwitcher } from '../framework/ui/UISwitcher';
import { AudioMgr } from '../framework/audio/AudioMgr';
import { PanelBase } from '../framework/ui/PanelBase';
import { AssetController } from '../AssetController';
import { GameController } from '../GameController';
import { BattleResult } from '../BattleLevel';
import { SdkMgr } from '../framework/sdk/SdkMgr';
const { ccclass, property } = _decorator;
@ccclass('WinPanel')
export class WinPanel extends PanelBase {
static instance: WinPanel;
@property(Node)
pointer: Node = null; // 指针节点
@property
amplitude: number = 450; // 运动幅度
@property
speed: number = 2; // 运动速度
@property(Button)
rewardBtn: Button = null;
@property(Button)
continueBtn: Button = null;
@property(Label)
remainTimer: Label = null;
@property(Label)
killEnemyCount: Label = null;
@property(Prefab)
flyMoneyPrefab: Prefab = null;
@property(Label)
coinCount: Label = null;
@property(Label)
rewardCoin: Label = null;
@property(Label)
rewardTimerCoin: Label = null;
@property(Label)
rewardKillCoin: Label = null;
@property(Node)
flyMoneyContent: Node = null;
@property(Label)
coinLabel: Label = null;
@property(Label)
continueCoinLabel: Label = null;
private time: number = 0;
runingPoint: boolean = false;
rewardDouble: number = 1;
onLoad() {
WinPanel.instance = this;
this.rewardBtn.node.on(Button.EventType.CLICK, this.onClickRewardBtn, this);
this.continueBtn.node.on(Button.EventType.CLICK, this.onClickContinueBtn, this);
}
onClickRewardBtn() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
if (Math.abs(this.pointPos) < 50) {
this.rewardDouble = 5
} else if (Math.abs(this.pointPos) < 150) {
this.rewardDouble = 4
} else if (Math.abs(this.pointPos) < 250) {
this.rewardDouble = 3
} else if (Math.abs(this.pointPos) < 350) {
this.rewardDouble = 2
} else if (Math.abs(this.pointPos) < 450) {
this.rewardDouble = 1
}
this.runingPoint = false
SdkMgr.instance.playerRewardAds(() => {
let addPoint = Math.ceil((this.curResult.coinCount * this.rewardDouble))
let fromeMoney = LocalSaveMgr.instance.playerData.coin
LocalSaveMgr.instance.addCoin(addPoint)
let endMoney = LocalSaveMgr.instance.playerData.coin
this.flyMoney(fromeMoney, endMoney)
})
}
onClickContinueBtn() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
GameController.getInstance().backMain()
SdkMgr.instance.showInterstitial()
}
backMain() {
AudioMgr.inst.playOneShot(AssetController.instance.click)
GameController.getInstance().backMain()
}
start() {
this.time = 0;
}
curResult: BattleResult;
winTween1 = null
winTween2 = null
winTween3 = null
refresh() {
let result = GameController.getInstance().curLevel.levelResult
this.curResult = result
LocalSaveMgr.instance.addCoin(result.coinCount)
this.killEnemyCount.string = result.enemyCount.toString()
this.remainTimer.string = result.timer.toString()
this.coinLabel.string = LocalSaveMgr.instance.playerData.coin.toString()
this.coinCount.string = "0"
let startValue = 0;
let endValue = result.coinCount;
let duration = 1; // 1秒
let startValue2 = 0;
let endValue2 = result.timerCoin;
let startValue3 = 0;
let endValue3 = result.enemyCoin;
this.continueCoinLabel.string = result.coinCount.toString()
this.winTween1 = new Tween({ value: startValue })
.to(duration, { value: endValue }, {
onUpdate: (target, ratio) => {
// 在每一帧更新时调用
let currentValue = Math.floor(target.value);
this.coinCount.string = currentValue.toString();
}
})
.start();
this.winTween2 = new Tween({ value: startValue2 })
.to(duration, { value: endValue2 }, {
onUpdate: (target, ratio) => {
// 在每一帧更新时调用
let currentValue = Math.floor(target.value);
this.rewardTimerCoin.string = currentValue.toString();
}
})
.start();
this.winTween3 = new Tween({ value: startValue3 })
.to(duration, { value: endValue3 }, {
onUpdate: (target, ratio) => {
// 在每一帧更新时调用
let currentValue = Math.floor(target.value);
this.rewardKillCoin.string = currentValue.toString();
}
})
.start();
this.runPoint()
}
flyMoney(fromMoney: number, endMoney: number) {
this.rewardBtn.interactable = false
this.continueBtn.interactable = false
AudioMgr.inst.playOneShot(AssetController.instance.getCoin)
for (let index = 0; index < 10; index++) {
let item = instantiate(this.flyMoneyPrefab)
item.setParent(this.flyMoneyContent)
item.setPosition(this.rewardBtn.node.getPosition())
let delay = index * 0.1
tween(item)
.by(0.3, { position: new Vec3(randomRange(-150, 150), randomRange(-150, 150), 0) })
.delay(delay)
.to(0.6, { worldPosition: this.coinLabel.node.getWorldPosition() })
.call(() => {
item.destroy()
})
.start()
}
new Tween({ value: fromMoney })
.delay(0.9)
.to(1, { value: endMoney }, {
onUpdate: (target, ratio) => {
// 在每一帧更新时调用
let currentValue = Math.floor(target.value);
this.coinLabel.string = currentValue.toString();
}
}).call(() => {
// this.rewardBtn.node.active = false
// this.continueBtn.interactable = true
this.backMain()
})
.start()
}
runPoint() {
this.runingPoint = true
}
pointPos: number
update(dt: number) {
if (!this.runingPoint) return
// 更新时间
this.time += dt * this.speed;
// 使用正弦函数计算指针的位置
const x = this.amplitude * Math.sin(this.time);
this.pointPos = x
// 设置指针的位置
this.pointer.setPosition(new Vec3(x, 65, 0))
if (Math.abs(x) < 93.079) {
this.rewardDouble = 5
} else if (Math.abs(x) < 224.786) {
this.rewardDouble = 4
} else if (Math.abs(x) < 341.818) {
this.rewardDouble = 3
} else if (Math.abs(x) < 430) {
this.rewardDouble = 2
}
this.rewardCoin.string = Math.ceil((this.curResult.coinCount * this.rewardDouble)).toString()
}
protected onDestroy(): void {
this.winTween1.stop()
this.winTween2.stop()
this.winTween3.stop()
}
protected onOpen(): void {
AudioMgr.inst.playOneShot(AssetController.instance.win)
WinPanel.instance.time = 0;
WinPanel.instance.refresh()
}
}
+1
View File
@@ -0,0 +1 @@
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"614eaab3-3518-4351-b915-2d135f4651f4","files":[],"subMetas":{},"userData":{}}