示例#1
0
 /// <summary>
 /// 构造战斗角色行为状态机
 /// </summary>
 /// <param name="characterLogic">角色逻辑</param>
 /// <param name="initial">初始状态</param>
 public BattleCharacterBehaviourStateMachine(BattleCharacterLogic characterLogic, BattleCharacterBehaviourStateBase initial)
 {
     this.CharacterLogic = characterLogic;
     initial.SetMachine(this).OnEnter();// 初始化初始状态
     this.StateList = new List <BattleCharacterBehaviourStateBase>()
     {
         initial
     };                                                                         // 添加初始状态
 }
示例#2
0
        private void Awake()
        {
            // 在这里加载资源与初始化

            // 设置UI组与缓存组
            GUIManager.GetInstance.CacheCanvas = GameObject.Find("CacheCanvas").transform;
            if (!GUIManager.GetInstance.CacheCanvas)
            {
                Debug.LogError("未找到CacheCanvas!");
            }
            GUIManager.GetInstance.UIParent = GameObject.Find("BattleUI").transform;
            if (!GUIManager.GetInstance.UIParent)
            {
                Debug.LogError("未找到UIParent!");
            }
            // 加载UI集,临时写法
            foreach (var ui in this.tempViewList)
            {
                GUIManager.GetInstance.AddUISet(ui.GetType().Name, ui);
            }

            if (this.Camera == null)
            {
                this.camera = new BattleCamera();
            }
            if (this.Member == null)
            {
                this.member = new BattleMember();
            }
            if (this.CharacterLogic == null)
            {
                this.characterLogic = new BattleCharacterLogic();
            }

            this.CharacterLogic.Initialization(this);

            // 由关卡场景传入成员列表
            var m1 = (Resources.Load <TutorInfo>("_Data/TutorInfo"));

            m1.Transform = GameObject.Find("P1").transform;
            var m2 = Instantiate(Resources.Load <TestEnemyInfo>("_Data/TestEnemyInfo"));

            m2.Transform = GameObject.Find("ILtan1").transform;
            m2.name      = "IL1";
            var m3 = Instantiate(Resources.Load <TestEnemyInfo>("_Data/TestEnemyInfo"));

            m3.Transform = GameObject.Find("ILtan2").transform;
            m3.name      = "IL2";

            this.Member.CharaList[0] = m1;
            this.Member.EnemyList.Add(m2);
            this.Member.EnemyList.Add(m3);
        }