// ***********************************************************************
// Assembly : Unity
// Author : Kimch
// Created : 2020-07-09
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
//
//
// ***********************************************************************
namespace G
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 剧情代理
///
public class StoryProxy : F.GameProxy
{
private StoryGroup _currGroup;
readonly Dictionary _storyGroups = new Dictionary();
///
///
///
public bool storyEnabled
{
get;
set;
} = true;
///
///
///
///
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(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()
{
}
///
///
///
///
public void JumpStoryStep(int step)
{
_currGroup.JumpToStep(step);
}
///
///
///
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;
}
}
}