375 lines
8.3 KiB
Markdown
375 lines
8.3 KiB
Markdown
# ⚡ POWER GRID SYSTEM - Električna Omrežja
|
||
**Design Concept**
|
||
**Datum:** 10. Februar 2026
|
||
|
||
---
|
||
|
||
## 🎯 KONCEPT:
|
||
|
||
**Player lahko gradi električno omrežje (power grid) po otoku!**
|
||
|
||
```
|
||
Generator → [Kabel] → Električni Drog 1 → [Kabel] → Drog 2 → [Kabel] → Farma
|
||
```
|
||
|
||
---
|
||
|
||
## 🔌 KAKO DELUJE:
|
||
|
||
### **1. BUILD POWER POLE (Električni Drog)**
|
||
|
||
**Crafting:**
|
||
- Wood × 10 (pole material)
|
||
- Wire × 5 (connections)
|
||
- Nails × 3 (assembly)
|
||
|
||
**Mehanika:**
|
||
- Postaviš kjer hočeš (click to place)
|
||
- **Range:** 10 tiles (max distance do naslednjega droga)
|
||
- **Height:** 2 tiles (visual tall pole)
|
||
|
||
---
|
||
|
||
### **2. AUTO-CONNECT CABLES**
|
||
|
||
**Cable Drawing:**
|
||
- Ko postaviš Power Pole, se **avtomatsko poveže** z najbližjim:
|
||
- Generator (source)
|
||
- Drugim Power Pole (chain)
|
||
|
||
**Vizualizacija:**
|
||
- Uporabi `objekt_cevi_in_kabli_set.png`
|
||
- Draw line (cable) med connected poles
|
||
- Animated spark effect (power flow)
|
||
|
||
**Range Rules:**
|
||
- Max **10 tiles** med dvema drogoma
|
||
- Če je predaleč → ❌ "TOO FAR - Need another pole"
|
||
- Če je prenizko → ⚠️ "Low voltage warning"
|
||
|
||
---
|
||
|
||
### **3. POWER BUILDINGS**
|
||
|
||
**Powered Structures:**
|
||
|
||
#### **A) Generator (Source):**
|
||
- Produces power (bio-oil fuel)
|
||
- **Output:** Unlimited range to first pole
|
||
- **Visual:** Green light when ON
|
||
|
||
#### **B) Power Poles (Relays):**
|
||
- Extend power range
|
||
- **Chain:** Pole → Pole → Pole (unlimited chain)
|
||
- **Visual:** Small spark at top when powered
|
||
|
||
#### **C) Buildings (Consumers):**
|
||
|
||
**Powered zgradbe:**
|
||
1. **Rudnik (Mine)** - Deep mining enabled
|
||
2. **Rastlinjak (Greenhouse)** - Climate control (faster growth!)
|
||
3. **Cold Storage** - Food preservation
|
||
4. **Workshop (Delavnica)** - Power tools (faster crafting)
|
||
5. **Water Pump** - Auto-irrigation system
|
||
6. **Electric Fence** - Auto-shock zombies
|
||
|
||
**Power Required:**
|
||
- Manjši buildings: 1 unit
|
||
- Večji buildings: 3 units
|
||
- **Generator capacity:** 10 units total
|
||
|
||
---
|
||
|
||
## 🎮 GAMEPLAY MECHANICS:
|
||
|
||
### **Phase 1: Basic Grid**
|
||
|
||
```
|
||
Player Actions:
|
||
1. Build Generator near base
|
||
2. Craft Power Pole × 3
|
||
3. Place poles forming path to Greenhouse
|
||
4. Cables auto-connect (visual line)
|
||
5. Greenhouse now "Powered" (green icon)
|
||
6. Growth speed +50%!
|
||
```
|
||
|
||
### **Phase 2: Expansion**
|
||
|
||
```
|
||
Player expands grid:
|
||
- Generator → Pole 1 → Pole 2 → Farm Area
|
||
↘ Pole 3 → Mine
|
||
|
||
All connected buildings get power!
|
||
```
|
||
|
||
### **Phase 3: Management**
|
||
|
||
```
|
||
Power Management:
|
||
- Generator capacity: 10 units
|
||
- Currently used: 7 units
|
||
- Mine: 3
|
||
- Greenhouse: 2
|
||
- Workshop: 2
|
||
- Available: 3 units (can add more buildings)
|
||
```
|
||
|
||
---
|
||
|
||
## 📊 VISUAL DESIGN:
|
||
|
||
### **Cable Rendering:**
|
||
|
||
**Option A: Simple Lines (Easy)**
|
||
```javascript
|
||
// Draw straight line between poles
|
||
graphics.lineStyle(2, 0x555555, 0.8);
|
||
graphics.lineBetween(pole1.x, pole1.y, pole2.x, pole2.y);
|
||
```
|
||
|
||
**Option B: Hanging Cables (Realistic)**
|
||
```javascript
|
||
// Curved line (sag effect)
|
||
graphics.lineStyle(2, 0x333333, 0.8);
|
||
// Bezier curve with slight droop
|
||
const midY = (pole1.y + pole2.y) / 2 + 20; // Sag
|
||
graphics.curve(pole1.x, pole1.y, midX, midY, pole2.x, pole2.y);
|
||
```
|
||
|
||
**Option C: Tileset Cables (High Quality)**
|
||
- Use `objekt_cevi_in_kabli_set.png` sprites
|
||
- Place segments between poles
|
||
- Animated spark particles
|
||
|
||
---
|
||
|
||
### **Visual Feedback:**
|
||
|
||
**Power Status Colors:**
|
||
- 🟢 **Green:** Powered (working)
|
||
- 🟡 **Yellow:** Low power (capacity warning)
|
||
- 🔴 **Red:** No power (disconnected)
|
||
- ⚪ **Gray:** Not connected
|
||
|
||
**Particle Effects:**
|
||
- ⚡ Small sparks travel along cables
|
||
- 💡 Buildings glow when powered
|
||
- 🔥 Generator emits smoke (when ON)
|
||
|
||
---
|
||
|
||
## 🛠️ IMPLEMENTATION:
|
||
|
||
### **Step 1: Power Pole Building**
|
||
|
||
```javascript
|
||
// In GrassScene
|
||
createPowerPole(x, y) {
|
||
const pole = this.add.sprite(x, y, 'objekt_elektricni_drog');
|
||
pole.setOrigin(0.5, 1.0); // Bottom anchor
|
||
pole.setDepth(y);
|
||
|
||
// Physics
|
||
this.physics.add.existing(pole, true);
|
||
|
||
// Power data
|
||
pole.isPowered = false;
|
||
pole.connectedTo = null; // Linked pole
|
||
|
||
this.powerPoles.push(pole);
|
||
this.connectNearestPole(pole);
|
||
}
|
||
```
|
||
|
||
### **Step 2: Auto-Connection**
|
||
|
||
```javascript
|
||
connectNearestPole(newPole) {
|
||
let nearest = null;
|
||
let minDist = Infinity;
|
||
|
||
// Find nearest powered pole or generator
|
||
this.powerPoles.forEach(pole => {
|
||
if (!pole.isPowered) return;
|
||
const dist = Phaser.Math.Distance.Between(
|
||
newPole.x, newPole.y, pole.x, pole.y
|
||
);
|
||
|
||
if (dist < minDist && dist <= MAX_CABLE_RANGE) {
|
||
minDist = dist;
|
||
nearest = pole;
|
||
}
|
||
});
|
||
|
||
if (nearest) {
|
||
newPole.connectedTo = nearest;
|
||
newPole.isPowered = true;
|
||
this.drawCable(newPole, nearest);
|
||
}
|
||
}
|
||
```
|
||
|
||
### **Step 3: Cable Drawing**
|
||
|
||
```javascript
|
||
drawCable(pole1, pole2) {
|
||
const cable = this.add.graphics();
|
||
|
||
// Hanging cable effect
|
||
cable.lineStyle(3, 0x333333, 0.7);
|
||
cable.beginPath();
|
||
cable.moveTo(pole1.x, pole1.y - 100); // Top of pole
|
||
|
||
// Bezier curve (sag)
|
||
const midX = (pole1.x + pole2.x) / 2;
|
||
const midY = (pole1.y + pole2.y) / 2 + 30; // Droop
|
||
cable.quadraticCurveTo(
|
||
midX, midY,
|
||
pole2.x, pole2.y - 100
|
||
);
|
||
|
||
cable.strokePath();
|
||
cable.setDepth(-10); // Behind objects
|
||
|
||
this.cables.push(cable);
|
||
}
|
||
```
|
||
|
||
### **Step 4: Power Buildings**
|
||
|
||
```javascript
|
||
checkBuildingPower(building) {
|
||
// Check if any power pole is in range
|
||
this.powerPoles.forEach(pole => {
|
||
if (!pole.isPowered) return;
|
||
|
||
const dist = Phaser.Math.Distance.Between(
|
||
building.x, building.y, pole.x, pole.y
|
||
);
|
||
|
||
if (dist <= POWER_RADIUS) {
|
||
building.isPowered = true;
|
||
building.setTint(0x88ff88); // Green glow
|
||
}
|
||
});
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 🎯 GAMEPLAY BENEFITS:
|
||
|
||
### **Strategic Depth:**
|
||
- Plan pole placement (optimize routes)
|
||
- Balance cost vs. coverage
|
||
- Expand grid as island grows
|
||
|
||
### **Visual Appeal:**
|
||
- See power flow (cables, sparks)
|
||
- Satisfying build progression
|
||
- Clear infrastructure visualization
|
||
|
||
### **Resource Management:**
|
||
- Generator needs bio-oil (fuel)
|
||
- Limited capacity (10 units)
|
||
- Choose which buildings to power
|
||
|
||
---
|
||
|
||
## 💡 ADVANCED FEATURES (Future):
|
||
|
||
### **Faza 2+:**
|
||
1. **Upgrade System:**
|
||
- Wood Pole → Steel Pole (longer range)
|
||
- Basic Generator → Industrial Generator (20 units)
|
||
|
||
2. **Power Loss:**
|
||
- Long cable runs = voltage drop
|
||
- Need transformer poles
|
||
|
||
3. **Backup Power:**
|
||
- Solar panels (day only)
|
||
- Battery storage (night backup)
|
||
|
||
4. **Circuit Breaker:**
|
||
- Overload protection
|
||
- Manual ON/OFF switches
|
||
|
||
---
|
||
|
||
## ✅ PRODUCTION PRIORITY:
|
||
|
||
### **Faza 1 (DEMO Extended):**
|
||
- ✅ Basic pole placement
|
||
- ✅ Auto-connect cables (simple lines)
|
||
- ✅ Power 2-3 buildings (Mine, Greenhouse)
|
||
|
||
### **Faza 1 Advanced:**
|
||
- ⚠️ Visual cable sag (curved lines)
|
||
- ⚠️ Spark particles
|
||
- ⚠️ Power capacity UI
|
||
|
||
### **Faza 2:**
|
||
- ❌ Multiple generators
|
||
- ❌ Advanced pole types
|
||
- ❌ Power management UI
|
||
|
||
---
|
||
|
||
## 🎮 EXAMPLE USE CASE:
|
||
|
||
```
|
||
Player Story:
|
||
1. Day 10: Build Generator near base
|
||
2. Day 12: Craft 3 power poles
|
||
3. Day 13: Place poles to Greenhouse (3 tiles apart)
|
||
4. Cables auto-draw (visual confirmation)
|
||
5. Greenhouse now Powered!
|
||
- Growth speed +50%
|
||
- Climate control ON
|
||
- Can grow rare crops!
|
||
6. Day 20: Extend grid to Mine
|
||
- Add 2 more poles
|
||
- Mine now Powered
|
||
- Unlock Deep Mining (rare ores!)
|
||
7. Day 30: Hit capacity limit (10 units)
|
||
- Decide: Power Greenhouse OR Workshop?
|
||
- Build 2nd Generator? (expensive!)
|
||
```
|
||
|
||
---
|
||
|
||
## 📝 ASSET REQUIREMENTS:
|
||
|
||
✅ **Already have:**
|
||
- `objekt_elektricni_drog_predelan_svetlejsi.png` (pole sprite)
|
||
- `objekt_cevi_in_kabli_set.png` (cable segments)
|
||
- `item_zica_kolut.png` (wire item)
|
||
- `agregat_1_pokvarjen.png` + `agregat_2_delujoc.png` (generator states)
|
||
|
||
❌ **Need to create:**
|
||
- Power pole build UI icon
|
||
- "Powered" building indicator (green glow overlay)
|
||
- Spark particle sprite (small lightning)
|
||
|
||
---
|
||
|
||
## 🎯 CONCLUSION:
|
||
|
||
**JA - Power Grid sistem je odličen addition!** ⚡🏗️
|
||
|
||
**Benefits:**
|
||
- Strategic planning layer
|
||
- Visual satisfaction (build infrastructure)
|
||
- Resource management (power capacity)
|
||
- Incentive to explore (extend grid)
|
||
|
||
**Implementation:** Medium complexity, high gameplay value!
|
||
|
||
---
|
||
|
||
*Concept Design: 10. Februar 2026*
|
||
*Status: Ready for Implementation (Faza 1)*
|