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

45 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum TargetType
{
KillEnemy, // <20><>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>
ReachArea, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CollectItem, // <20>ռ<EFBFBD><D5BC><EFBFBD>Ʒ
InteractNPC // <20><>NPC<50><43><EFBFBD><EFBFBD>
}
public class TaskTarget:MonoBehaviour
{
public TargetType Type { get; private set; } // Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string TargetID { get; private set; } // Ŀ<><C4BF>ID
public string Description { get; private set; } // Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int CurrentProgress { get; private set; } // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
public int RequiredProgress { get; private set; } // Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public bool IsCompleted => CurrentProgress >= RequiredProgress; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
public TaskTarget(TargetType type, string targetId, string description, int requiredProgress)
{
Type = type;
TargetID = targetId;
Description = description;
RequiredProgress = requiredProgress;
CurrentProgress = 0;
}
// <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void UpdateProgress(int amount)
{
if (IsCompleted) return;
CurrentProgress += amount;
Console.WriteLine($"Ŀ<><C4BF> {Description} <20><><EFBFBD><EFBFBD>: {CurrentProgress}/{RequiredProgress}");
if (IsCompleted)
{
Console.WriteLine($"Ŀ<><C4BF> {Description} <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
}