_xiaofang/xiaofang/Assets/Script/hylScripts/TaskTarget.cs

45 lines
1.3 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum TargetType
{
KillEnemy, // 击杀敌人
ReachArea, // 到达区域
CollectItem, // 收集物品
InteractNPC // 与NPC互动
}
public class TaskTarget:MonoBehaviour
{
public TargetType Type { get; private set; } // 目标类型
public string TargetID { get; private set; } // 目标ID
public string Description { get; private set; } // 目标描述
public int CurrentProgress { get; private set; } // 当前进度
public int RequiredProgress { get; private set; } // 目标完成所需进度
public bool IsCompleted => CurrentProgress >= RequiredProgress; // 是否完成
public TaskTarget(TargetType type, string targetId, string description, int requiredProgress)
{
Type = type;
TargetID = targetId;
Description = description;
RequiredProgress = requiredProgress;
CurrentProgress = 0;
}
// 更新目标进度
public void UpdateProgress(int amount)
{
if (IsCompleted) return;
CurrentProgress += amount;
Console.WriteLine($"目标 {Description} 进度: {CurrentProgress}/{RequiredProgress}");
if (IsCompleted)
{
Console.WriteLine($"目标 {Description} 已完成");
}
}
}