97 lines
3.8 KiB
Markdown
97 lines
3.8 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
This is a Cocos Creator 3.8.4 game project called "XiangQin" (相亲/Dating). It's a dating simulation/chat game with AI integration using Google's Gemini API.
|
|
|
|
## Technology Stack
|
|
|
|
- **Engine**: Cocos Creator 3.8.4
|
|
- **Language**: TypeScript
|
|
- **AI Integration**: Google Generative AI (Gemini)
|
|
- **Build Target**: Multi-platform (Web, WeChat Mini Game, Kuaishou, Baidu)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
assets/
|
|
├── Scripts/
|
|
│ ├── Main/ # Core game framework
|
|
│ │ ├── Channel/ # Platform SDK integrations (WeChat, Baidu, Kuaishou, Web)
|
|
│ │ ├── Common/ # Common utilities and base components
|
|
│ │ ├── Config/ # Game configuration and resources
|
|
│ │ └── Manager/ # Game managers (Audio, View, Resource, Player data)
|
|
│ ├── Sub/ # Game-specific logic
|
|
│ │ ├── UI/ # UI components and screens
|
|
│ │ ├── Item/ # UI items and dialogs
|
|
│ │ └── Compo/ # Additional components
|
|
│ └── test/ # Chat AI implementation
|
|
│ ├── ChatAIService.ts # Gemini AI integration
|
|
│ ├── ChatPanel.ts # Chat UI panel
|
|
│ └── index.ts # System instructions/prompts
|
|
├── Scenes/ # Game scenes
|
|
├── resources/ # Static resources
|
|
└── bundles/ # Asset bundles
|
|
```
|
|
|
|
## Key Components
|
|
|
|
### AI Chat System
|
|
- **ChatAIService.ts**: Handles Google Gemini API integration for chat functionality
|
|
- **ChatPanel.ts**: Main chat interface implementation
|
|
- **index.ts**: Contains system prompts and character definitions
|
|
|
|
### Platform SDKs
|
|
- **SDKManager.ts**: Manages platform-specific SDK initialization
|
|
- **wxSDK.ts**: WeChat Mini Game SDK integration
|
|
- **bdSDK.ts**: Baidu SDK integration
|
|
- **ksSDK.ts**: Kuaishou SDK integration
|
|
- **webSDK.ts**: Web platform SDK
|
|
|
|
### Game Flow
|
|
- **GameEntry.ts**: Game initialization and configuration
|
|
- **MainScene.ts**: Main menu scene
|
|
- **GameScene.ts**: Core game scene
|
|
- **ViewManager.ts**: Manages UI view navigation
|
|
|
|
## Development Commands
|
|
|
|
Since this is a Cocos Creator project, development is primarily done through the Cocos Creator IDE. Common tasks:
|
|
|
|
### Build & Run
|
|
- Open project in Cocos Creator 3.8.4
|
|
- Use Creator's built-in preview: Menu → Project → Preview
|
|
- Build for platforms: Menu → Project → Build
|
|
|
|
### TypeScript Compilation
|
|
TypeScript compilation is handled automatically by Cocos Creator. Manual compilation isn't typically needed.
|
|
|
|
## Important Considerations
|
|
|
|
### API Keys
|
|
The project contains API keys in the code (Google Gemini API). These should be moved to environment variables or a secure configuration file.
|
|
|
|
### Character System
|
|
The game uses configurable character profiles defined in `index.ts` with different personality settings (Role_1, Role_2, Role_3).
|
|
|
|
### Multi-Platform Support
|
|
The codebase includes platform-specific code branches. When modifying core functionality, ensure compatibility across all supported platforms (Web, WeChat, Baidu, Kuaishou).
|
|
|
|
### Asset Management
|
|
- Assets are organized in bundles for dynamic loading
|
|
- Resource management is handled through ResManager
|
|
- Audio assets are managed separately through AudioManager
|
|
|
|
### UI System
|
|
- Uses Cocos Creator's UI system with custom components
|
|
- Base view class: `li_BaseView.ts`
|
|
- View navigation managed by ViewManager
|
|
|
|
## Code Conventions
|
|
|
|
- TypeScript with non-strict mode (`"strict": false` in tsconfig)
|
|
- Component-based architecture following Cocos Creator patterns
|
|
- Singleton pattern for managers (e.g., `SDKManager.I`, `PlayerDataManager.I`)
|
|
- Event system using `li_EventManager` for decoupled communication |