three实现三维树林生存塔防策略游戏代码
代码语言:html
所属分类:其他
代码由gemini-4 ai生成,可能有错误,仅供参考:点击查看提示词
代码描述:three实现三维树林生存塔防策略游戏代码
代码标签: three 三维 树林 生存 塔防 策略 游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>荒野营地:昼夜防线 - 3D生存塔防</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body { overflow: hidden; background: #000; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; color: #eee; }
/* 顶部左上角:生存状态面板 */
#status-panel {
position: absolute; top: 15px; left: 15px; width: 250px;
background: rgba(15, 20, 28, 0.8); backdrop-filter: blur(6px);
border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
padding: 12px 15px; pointer-events: none; z-index: 10;
}
.panel-title { font-size: 13px; font-weight: bold; color: #aaa; margin-bottom: 8px; letter-spacing: 1px; display: flex; justify-content: space-between; }
.stat-row { margin-bottom: 7px; }
.stat-label { font-size: 12px; display: flex; justify-content: space-between; margin-bottom: 2px; }
.stat-bar-bg { width: 100%; height: 8px; background: rgba(0,0,0,0.6); border-radius: 4px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); }
.stat-bar-fill { height: 100%; width: 100%; transition: width 0.15s ease; }
/* 顶部居中:昼夜与波次信息 */
#time-panel {
position: absolute; top: 15px; left: 50%; transform: translateX(-50%);
background: rgba(15, 20, 28, 0.85); backdrop-filter: blur(6px);
border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
padding: 8px 24px; text-align: center; pointer-events: none; z-index: 10;
}
#day-title { font-size: 18px; font-weight: bold; color: #ffd166; }
#phase-info { font-size: 13px; color: #ccc; margin-top: 2px; }
#wave-alert { font-size: 13px; color: #ff595e; font-weight: bold; margin-top: 3px; display: none; }
/* 右上角:快捷按键提示与资源概览 */
#quick-res-panel {
position: absolute; top: 15px; right: 15px;
background: rgba(15, 20, 28, 0.8); backdrop-filter: blur(6px);
border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
padding: 12px 15px; font-size: 13px; z-index: 10; min-width: 190px;
}
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.res-item { display: flex; justify-content: space-between; background: rgba(0,0,0,0.35); padding: 4px 8px; border-radius: 4px; }
.res-val { font-weight: bold; color: #ffd166; }
.key-hint { font-size: 12px; color: #bbb; line-height: 1.7; }
.k-badge { background: #2b3545; border: 1px solid #556; padding: 1px 5px; border-radius: 3px; color: #fff; font-size: 11px; }
/* 屏幕中心准星与交互提示 */
#crosshair {
position: absolute; top: 50%; left: 50%; width: 16px; height: 16px;
transform: translate(-50%, -50%); pointer-events: none; z-index: 5;
}
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: rgba(255,255,255,0.85); }
#crosshair::before { top: 7px; left: 0; width: 16px; height: 2px; }
#crosshair::after { top: 0; left: 7px; width: 2px; height: 16px; }
#interact-hint {
position: absolute; top: 58%; left: 50%; transform: translateX(-50%);
background: rgba(0, 0, 0, 0.75); border: 1px solid rgba(255,255,255,0.2);
padding: 6px 14px; border-radius: 20px; font-size: 14px; color: #ffd166;
pointer-events: none; display: none; z-index: 10;
}
/* 建造模式提示条 */
#build-banner {
position: absolute; top: 95px; left: 50%; transform: translateX(-50%);
background: rgba(20, 60, 40, 0.9); border: 1px solid #4ade80;
padding: 8px 20px; border-radius: 6px; font-size: 14px; color: #fff;
display: none; z-index: 10; text-align: center;
}
/* 底部快捷装备与道具栏 */
#hotbar {
position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
display: flex; gap: 8px; background: rgba(15, 20, 28, 0.85);
padding: 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15); z-index: 10;
}
.slot {
width: 64px; height: 68px; background: rgba(0,0,0,0.5);
border: 2px solid rgba(255,255,255,0.15); border-radius: 6px;
display: flex; flex-direction: column; justify-content: space-between;
padding: 5px; cursor: pointer; position: relative; transition: all 0.15s;
}
.slot.active { border-color: #ffd166; background: rgba(255, 209, 102, 0.15); transform: translateY(-3px); }
.slot-key { font-size: 11px; color: #999; font-weight: bold; }
.slot-name { font-size: 12px; text-align: center; font-weight: bold; color: #fff; }
.slot-count { font-size: 11px; text-align: right; color: #4ade80; }
/* 弹窗面板(背包 / 工作台制作 / 建造选择) */
#modal-overlay {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.55); display: none; justify-content: center; align-items: center; z-index: 50;
}
.modal-box {
width: 720px; max-height: 82vh; background: rgba(18, 24, 34, 0.95);
border: 1px solid rgba(255,255,255,0.2); border-radius: 10px;
display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 15px 40px rgba(0,0,0,0.7);
}
.modal-header {
display: flex; justify-content: space-between; align-items: center;
background: rgba(0,0,0,0.4); padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.modal-tabs { display: flex; gap: 10px; }
.tab-btn {
background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
color: #ccc; padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;
}
.tab-btn.active { background: #3b82f6; color: #fff; border-color: #60a5fa; }
.close-btn { background: #ef4444; border: none; color: #fff; padding: 6px 14px; border-radius: 5px; cursor: pointer; font-weight: bold; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
/* 卡片网格 */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.item-card {
background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.12);
border-radius: 8px; padding: 12px; display: flex; justify-content: space-between; align-items: center;
}
.card-info h4 { font-size: 15px; color: #ffd166; margin-bottom: 4px; }
.card-info p { font-size: 12px; color: #aaa; margin-bottom: 4px; }
.card-cost { font-size: 12px; color: #60a5fa; }
.action-btn {
background: #10b981; border: none; color: #fff; padding: 8px 14px;
border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px; white-space: nowrap;
}
.action-btn:hover { background: #059669; }
.action-btn:disabled { background: #374151; color: #777; cursor: not-allowed; }
/* 飘字提示容器 */
#toast-container {
position: absolute; top: 30%; left: 50%; transform: translateX(-50%);
pointer-events: none; z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.toast-msg {
background: rgba(0,0,0,0.75); padding: 5px 14px; border-radius: 15px;
font-size: 14px; font-weight: bold; animation: fadeUp 1.6s forwards;
border: 1px solid rgba(255,255,255,0.15);
}
@keyframes fadeUp {
0% { opacity: 1; transform: translateY(0); }
100% { opacity: 0; transform: translateY(-25px); }
}
/* 初始引导与结束遮罩 */
#start-screen {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(10, 14, 22, 0.88); backdrop-filter: blur(8px);
display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 100;
}
.start-box {
max-width: 620px; background: rgba(20, 28, 40, 0.95); border: 1px solid rgba(255,255,255,0.2);
border-radius: 12px; padding: 28px 34px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}
.start-box h1 { color: #ffd166; font-size: 28px; margin-bottom: 10px; }
.start-box p { color: #ccc; font-size: 14px; line-height: 1.6; margin-bottom: 14px; text-align: left; }
.start-btn {
background: #f59e0b; color: #000; border: none; padding: 12px 32px;
font-size: 16px; font-weight: bold; border-radius: 8px; cursor: pointer; margin-top: 10px;
}
.start-btn:hover { background: #fbbf24; }
</style>
</head>
<body>
<!-- 左上角:生存状态面板 (包含4大核心生存条 + 角色与木屋生命) -->
<div id="status-panel">
<div class="panel-title">
<span>生存状态监控</span>
<span id="temp-indicator" style="color:#4ade80;">气温: 舒适</span>
</div>
<div class="stat-row">
<div class="stat-label"><span>🏠 核心木屋耐久</span><span id="val-cabin">1000/1000</span></div>
<div class="stat-bar-bg"><div id="bar-cabin" class=".........完整代码请登录后点击上方下载按钮下载查看















网友评论0