少年修仙传客户端代码仓库
client_Hale
2019-04-11 9f89e3be35da42eb9ccb44e6589d62f320aa444c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
 
public class CreateRoleProcessor : MonoBehaviour
{
    [SerializeField] CreateRoleBehaviour m_Warrior;
    [SerializeField] CreateRoleBehaviour m_Magic;
 
    [SerializeField] CameraParams m_CameraParams;
 
    Animator cameraAnimator;
    Camera createRoleCamera;
 
    public void LoadNecessaryResources()
    {
        if (cameraAnimator == null || createRoleCamera == null)
        {
            var prefab = SceneLoader.LoadCreateRole(m_CameraParams.prefabName);
            var instance = GameObject.Instantiate(prefab);
            cameraAnimator = instance.GetComponent<Animator>();
            createRoleCamera = instance.GetComponentInChildren<Camera>(true);
        }
    }
 
    public void DoEnterShow()
    {
        WindowCenter.Instance.Close<CreateRoleWin>();
        cameraAnimator.Play(m_CameraParams.enterShow);
        m_Warrior.gameObject.SetActive(true);
        m_Warrior.DoEnterShow();
    }
 
    public void SwitchToWarrior()
    {
        WindowCenter.Instance.Close<CreateRoleWin>();
        cameraAnimator.Play(m_CameraParams.magicToWarrior);
        m_Magic.ReleaseEffects();
        m_Warrior.ReleaseEffects();
 
        StopCoroutine("Co_SwitchToWarrior");
        StartCoroutine("Co_SwitchToWarrior");
    }
 
    public void SwitchToMagic()
    {
        WindowCenter.Instance.Close<CreateRoleWin>();
        cameraAnimator.Play(m_CameraParams.warriorToMagic);
        m_Magic.ReleaseEffects();
        m_Warrior.ReleaseEffects();
 
        StopCoroutine("Co_SwitchToMagic");
        StartCoroutine("Co_SwitchToMagic");
    }
 
    IEnumerator Co_SwitchToWarrior()
    {
        m_Warrior.gameObject.SetActive(true);
        yield return WaitingForSecondConst.WaitMS1000;
 
        m_Magic.gameObject.SetActive(false);
        m_Warrior.DoRoutineShow();
    }
 
    IEnumerator Co_SwitchToMagic()
    {
        yield return WaitingForSecondConst.WaitMS1000;
        m_Warrior.gameObject.SetActive(false);
        m_Magic.gameObject.SetActive(true);
        m_Magic.DoRoutineShow();
    }
 
    public void Dispose()
    {
        m_Warrior.Dispose();
        m_Magic.Dispose();
    }
 
    [System.Serializable]
    public struct CameraParams
    {
        public string prefabName;
        public string enterShow;
        public string warriorToMagic;
        public string magicToWarrior;
    }
 
 
}