blob: 3293db48b53b3fc58282ed1cc85553a7f57ce82b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WK.Data;
namespace WK
{
public class CharacterBuilder
{
protected GameObject m_Root;
protected CharacterMetadata m_Metadata;
public PlayerController Build(CharacterMetadata metadata)
{
m_Metadata = metadata;
PlayerController controller = BuildPhase_Controller();
m_Root = BuildPhase_RootGameObject();
controller.SetGameObject(m_Root);
CharacterBehaviour behaviour = BuildPhase_Behaviour();
controller.SetBehaviour(behaviour);
return controller;
}
protected virtual GameObject BuildPhase_RootGameObject()
{
GameObject go = new GameObject();
TransformUtils.ResetLocal(go.transform);
go.name = m_Metadata.uid;
GameObject prefab = ResourceManager.Instance.LoadAssetFullPath<GameObject>(m_Metadata.prefab);
GameObject model = GameObject.Instantiate<GameObject>(prefab);
model.transform.SetParent(go.transform);
return go;
}
protected virtual CharacterBehaviour BuildPhase_Behaviour()
{
CharacterBehaviour behaviour = CommonFunction.CreateInstance(m_Metadata.behaviour) as CharacterBehaviour;
return behaviour;
}
protected virtual PlayerController BuildPhase_Controller()
{
return null;
}
}
}
|