105 lines
2.1 KiB
C#
105 lines
2.1 KiB
C#
// ***********************************************************************
|
|
// Assembly : Unity
|
|
// Author : Kimch
|
|
// Created : 2020-07-09
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "StoryProxy" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
namespace G
|
|
{
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 剧情代理
|
|
/// </summary>
|
|
public class StoryProxy : F.GameProxy
|
|
{
|
|
private StoryGroup _currGroup;
|
|
readonly Dictionary<int, StoryGroup> _storyGroups = new Dictionary<int, StoryGroup>();
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool storyEnabled
|
|
{
|
|
get;
|
|
set;
|
|
} = true;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="groupId"></param>
|
|
public bool TriggerStory(int groupId, Callback callback)
|
|
{
|
|
if (!storyEnabled)
|
|
return false;
|
|
if (_storyGroups.TryGetValue(groupId, out StoryGroup group))
|
|
{
|
|
if (group.CanTrigger())
|
|
{
|
|
|
|
group.Start(callback);
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var groupItem = ItemProxy.Instance.GetStaticItem<ItemStoryGroup>(groupId);
|
|
if (groupItem != null)
|
|
{
|
|
group = new StoryGroup(groupItem);
|
|
_storyGroups.Add(groupId, group);
|
|
group.Start(callback);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("没有找到剧情id" + groupId);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void CheckError()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="step"></param>
|
|
public void JumpStoryStep(int step)
|
|
{
|
|
_currGroup.JumpToStep(step);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void JumpStoryNext()
|
|
{
|
|
_currGroup.JumpToNext();
|
|
}
|
|
|
|
private static StoryProxy _Instance;
|
|
|
|
public static StoryProxy Instance
|
|
{
|
|
get { return _Instance; }
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
_Instance = this;
|
|
storyEnabled = PlayerPrefs.GetInt("story_switch", 1) > 0;
|
|
}
|
|
}
|
|
} |