shaoxiadiablo/Assets/AGame/Scripts/Proxy/Tutorial/TutorialTrigger.Command.cs

228 lines
6.4 KiB
C#
Raw Permalink Normal View History

2025-05-18 01:04:31 +08:00
// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-30
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "TutorialProxy" company="Kunpo"></copyright>
// <summary></summary>
// ***********************************************************************
using System.Collections;
using System.Collections.Generic;
using F;
using PureMVC.Interfaces;
using UnityEngine;
namespace G
{
/// <summary>
/// 类功能描述
/// </summary>
partial class TutorialTrigger
{
public void RegisterCommand()
{
GameCommand.Register(GlobalDefine.EVENT_INGAME_GET_ITEM, GetItemCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_STAGE_STATE, StageStateCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_LEVEL_SCENE, StageSceneCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_SETTLE_RESULT, SettleCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_MAIN_WINDOW, OpenWindowCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_GAME_WINDOW, OpenWindowCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_WINDOW_OPENED, OpenWindowCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_WINDOW_CLOSED, CloseWindowCommand.CreateCommand);
GameCommand.Register(GlobalDefine.EVENT_EQUIPMENT_FULL, BagFullCommand.CreateCommand);
}
public void UnregisterCommand()
{
GameCommand.Unregister(GlobalDefine.EVENT_INGAME_GET_ITEM);
GameCommand.Unregister(GlobalDefine.EVENT_STAGE_STATE);
GameCommand.Unregister(GlobalDefine.EVENT_LEVEL_SCENE);
GameCommand.Unregister(GlobalDefine.EVENT_SETTLE_RESULT);
GameCommand.Unregister(GlobalDefine.EVENT_MAIN_WINDOW);
GameCommand.Unregister(GlobalDefine.EVENT_GAME_WINDOW);
GameCommand.Unregister(GlobalDefine.EVENT_WINDOW_OPENED);
GameCommand.Unregister(GlobalDefine.EVENT_WINDOW_CLOSED);
GameCommand.Unregister(GlobalDefine.EVENT_EQUIPMENT_FULL);
}
public class GetItemCommand : GameCommand
{
public override void Execute(INotification notification)
{
TutorialGroup tutorial;
if ((tutorial = TutorialProxy.Instance.currTutorial) != null)
{
var condition = tutorial.currStage.condition;
if (condition != null && condition.type == 11)
{
if (notification.Body is ItemProp prop)
{
if (prop.id == condition.target)
{
TutorialProxy.Instance.CompleteStage();
}
}
}
}
}
static readonly GetItemCommand _Default = new GetItemCommand();
public static GetItemCommand CreateCommand()
{
return _Default;
}
}
public class BagFullCommand : GameCommand
{
public override void Execute(INotification notification)
{
TutorialProxy.Instance.TriggerCondition(12);
}
static readonly BagFullCommand _Default = new BagFullCommand();
public static BagFullCommand CreateCommand()
{
return _Default;
}
}
public class StageSceneCommand : GameCommand
{
public override void Execute(INotification notification)
{
TutorialProxy.Instance.TriggerCondition(1);
}
static readonly StageSceneCommand _Default = new StageSceneCommand();
public static StageSceneCommand CreateCommand()
{
return _Default;
}
}
public class StageStateCommand : GameCommand
{
public override void Execute(INotification notification)
{
if (notification.Type == "start")
{
if (notification.Body is ItemStage stage)
TutorialProxy.Instance.TriggerCondition(3, stage.id);
}
else if (notification.Type == "finish")
{
if (notification.Body is ItemStage stage)
TutorialProxy.Instance.TriggerCondition(4, stage.id);
}
}
static readonly StageStateCommand _Default = new StageStateCommand();
public static StageStateCommand CreateCommand()
{
return _Default;
}
}
public class SettleCommand : GameCommand
{
public override void Execute(INotification notification)
{
var result = notification.Body as BattleResult;
if (notification.Type == "success")
{
TutorialProxy.Instance.TriggerCondition(40, result.levelId);
}
else if (notification.Type == "fail")
{
TutorialProxy.Instance.TriggerCondition(41, result.levelId);
}
else
{
}
}
static readonly SettleCommand _Default = new SettleCommand();
public static SettleCommand CreateCommand()
{
return _Default;
}
}
public class OpenWindowCommand : GameCommand
{
public override void Execute(INotification notification)
{
if (notification.Name == GlobalDefine.EVENT_MAIN_WINDOW)
{
if (notification.Type == "new_level")
{
TutorialProxy.Instance.TriggerCondition(42, (int)notification.Body);
}
}
else if (notification.Name == GlobalDefine.EVENT_WINDOW_OPENED)
{
if (string.IsNullOrEmpty(notification.Type))
TutorialProxy.Instance.TriggerCondition(22, (int)notification.Body);
else
{
var windowHash = Animator.StringToHash(notification.Type);
TutorialProxy.Instance.TriggerCondition(22, windowHash);
#if UNITY_EDITOR
Debug.Log($"window hash {windowHash}");
#endif
}
}
else if (notification.Name == GlobalDefine.EVENT_GAME_WINDOW)
{
if (!string.IsNullOrEmpty(notification.Type))
TutorialProxy.Instance.TriggerCondition(22, Animator.StringToHash(notification.Type));
else
TutorialProxy.Instance.TriggerCondition(22, (int)notification.Body);
}
}
static readonly OpenWindowCommand _Default = new OpenWindowCommand();
public static OpenWindowCommand CreateCommand()
{
return _Default;
}
}
public class CloseWindowCommand : GameCommand
{
public override void Execute(INotification notification)
{
if (!string.IsNullOrEmpty(notification.Type))
{
var windowHash = Animator.StringToHash(notification.Type);
TutorialProxy.Instance.TriggerCondition(23, Animator.StringToHash(notification.Type));
#if UNITY_EDITOR
Debug.Log($"window hash {windowHash}");
#endif
}
else
TutorialProxy.Instance.TriggerCondition(23, (int)notification.Body);
}
static readonly CloseWindowCommand _Default = new CloseWindowCommand();
public static CloseWindowCommand CreateCommand()
{
return _Default;
}
}
}
}