136 lines
4.3 KiB
C#
136 lines
4.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Continentis.MainGame.Card;
|
|
using Continentis.MainGame.Combat;
|
|
using NaughtyAttributes;
|
|
using SLSFramework.UModAssistance;
|
|
using UnityEngine;
|
|
using Object = UnityEngine.Object;
|
|
using Random = UnityEngine.Random;
|
|
|
|
namespace Continentis.MainGame.Character
|
|
{
|
|
public enum Fraction
|
|
{
|
|
Player,
|
|
Ally,
|
|
Enemy,
|
|
Neutral
|
|
}
|
|
|
|
public interface ICardOwner
|
|
{
|
|
DeckSubmodule deckSubmodule { get; }
|
|
}
|
|
|
|
public partial class CharacterBase : ICardOwner, IGameElement
|
|
{
|
|
public Guid elementID { get; set; }
|
|
|
|
public CharacterData data;
|
|
public CharacterLogicBase logicBase;
|
|
|
|
public Fraction fraction;
|
|
public CombatTeam team;
|
|
|
|
public int actionCountThisRound;
|
|
|
|
[ShowNativeProperty]
|
|
public AttributeSubmodule attributeSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public EventSubmodule eventSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public EquipmentSubmodule equipmentSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public DeckSubmodule deckSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public IntentionSubmodule intentionSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public StatusSubmodule statusSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public CombatBuffSubmodule combatBuffSubmodule { get; private set; }
|
|
|
|
[ShowNativeProperty]
|
|
public RecordSubmodule recordSubmodule { get; private set; }
|
|
|
|
public CharacterBase(CharacterData data, Fraction fraction)
|
|
{
|
|
(this as IGameElement).Initialize();
|
|
|
|
this.data = data;
|
|
this.fraction = fraction;
|
|
|
|
switch (fraction)
|
|
{
|
|
case Fraction.Player:
|
|
this.team = CombatMainManager.Instance.characterController.playerTeam;
|
|
break;
|
|
case Fraction.Enemy:
|
|
this.team = CombatMainManager.Instance.characterController.enemyTeam;
|
|
break;
|
|
default:
|
|
this.team = null;
|
|
break;
|
|
}
|
|
|
|
attributeSubmodule = new AttributeSubmodule(this);
|
|
equipmentSubmodule = new EquipmentSubmodule(this);
|
|
eventSubmodule = new EventSubmodule(this);
|
|
deckSubmodule = new DeckSubmodule(this);
|
|
intentionSubmodule = new IntentionSubmodule(this);
|
|
statusSubmodule = new StatusSubmodule(this);
|
|
combatBuffSubmodule = new CombatBuffSubmodule(this);
|
|
recordSubmodule = new RecordSubmodule(this);
|
|
|
|
this.logicBase = GenerateCharacterLogic(data);
|
|
this.logicBase.Initialize(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成卡牌逻辑实例
|
|
/// </summary>
|
|
public static CharacterLogicBase GenerateCharacterLogic(CharacterData data)
|
|
{
|
|
string typeID = ModManager.GetTypeID(data.modName, "Characters", "", data.className);
|
|
Type logicType = ModManager.GetType(typeID);
|
|
|
|
if(logicType == null)
|
|
{
|
|
return new CharacterLogicBase();
|
|
}
|
|
|
|
if (Activator.CreateInstance(logicType) is CharacterLogicBase logic)
|
|
{
|
|
return logic;
|
|
}
|
|
|
|
Debug.LogError($"Card class '{typeID}' not found or could not be instantiated.");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public partial class CharacterBase
|
|
{
|
|
public CombatCharacterViewBase characterView;
|
|
}
|
|
|
|
public partial class CharacterBase
|
|
{
|
|
public CombatCharacterViewBase GenerateCharacterView(Vector3 position)
|
|
{
|
|
GameObject prefab = data.combatCharacterView;
|
|
CombatCharacterViewBase characterView = Object.Instantiate(prefab, position, Quaternion.identity).GetComponent<CombatCharacterViewBase>();
|
|
characterView.InitializeAnimations();
|
|
characterView.character = this;
|
|
this.characterView = characterView;
|
|
return characterView;
|
|
}
|
|
}
|
|
} |