Пример #1
0
        private void Start()
        {
            if (m_Map == null)
            {
                m_Map = GameObject.FindObjectOfType <MapGraph>();
            }

            if (m_Map == null)
            {
                Debug.LogError("EditorTestPathFinding -> Map was not found.");
                return;
            }

            m_Map.InitMap();
            m_Map.searchPath.onStep += MapPathfinding_OnStep;

            //if (m_TestCursorPrefab == null)
            //{
            //    Debug.LogError("EditorTestPathFinding -> Cursor Prefab is null.");
            //    return;
            //}

            //m_TestCursors = new List<GameObject>();

            if (m_TestClassPrefab == null)
            {
                Debug.LogError("EditorTestPathFinding -> Class Prefab is null.");
                return;
            }

            //m_TestClass = GameObject.Instantiate<MapClass>(
            //    m_TestClassPrefab,
            //    m_Map.transform.Find("MapObject"),
            //    false);
            //m_TestClass.map = m_Map;
            //m_TestClass.UpdatePosition(new Vector3Int(-1, -1, 0));
            m_TestClass              = m_Map.CreateMapObject(m_TestClassPrefab, new Vector3Int(-1, -1, 0)) as MapClass;
            m_TestClass.onMovingEnd += M_TestClass_onMovingEnd;
            //RecreateMoveConsumption();
            //m_CursorCells = new List<CellData>();

            // 读取一个角色
            m_TestClass.Load(0, RoleType.Unique);

            // 我们需要一个武器来显示攻击范围
            ItemModel model = ModelManager.models.Get <ItemModel>();

            m_TestClass.role.AddItem(model.CreateItem(0));
        }
Пример #2
0
        private void Start()
        {
            if (m_Map == null)
            {
                m_Map = GameObject.FindObjectOfType <MapGraph>();
            }

            if (m_Map == null)
            {
                Debug.LogError("EditorTestCombat -> Map was not found.");
                return;
            }

            //m_Combat = m_Map.gameObject.GetComponent<Combat>();
            //if (m_Combat == null)
            //{
            //    m_Combat = m_Map.gameObject.AddComponent<Combat>();
            //}

            m_CombatAnimaController = Combat.GetOrAdd(m_Map.gameObject);
            m_CombatAnimaController.onPlay.AddListener(CombatAnimaController_onPlay);
            m_CombatAnimaController.onStop.AddListener(CombatAnimaController_onStop);
            m_CombatAnimaController.onStep.AddListener(CombatAnimaController_onStep);

            m_Map.InitMap();

            if (m_TestClassPrefab == null)
            {
                Debug.LogError("EditorTestCombat -> Class Prefab is null.");
                return;
            }

            m_TestClass1 = m_Map.CreateMapObject(m_TestClassPrefab, new Vector3Int(5, 5, 0)) as MapClass;
            m_TestClass2 = m_Map.CreateMapObject(m_TestClassPrefab, new Vector3Int(6, 5, 0)) as MapClass;
            if (!m_TestClass1.Load(0, RoleType.Unique) || !m_TestClass2.Load(1, RoleType.Unique))
            {
                Debug.LogError("EditorTestCombat -> Load role Error.");
                return;
            }

            ItemModel model = ModelManager.models.Get <ItemModel>();

            m_TestClass1.role.AddItem(model.CreateItem(0));
            m_TestClass2.role.AddItem(model.CreateItem(1));

            //Debug.LogFormat("{0}.hp = {1}, {0}.atk = {4}, {2}.hp = {3}, {2}.atk = {5}",
            //    m_TestClass1.role.character.info.name,
            //    m_TestClass1.role.hp,
            //    m_TestClass2.role.character.info.name,
            //    m_TestClass2.role.hp,
            //    m_TestClass1.role.attack,
            //    m_TestClass2.role.attack);

            //m_Combat.LoadCombatUnit(m_TestClass1, m_TestClass2);
            //m_Combat.BattleBegin();
            //for (int i = 0; i < m_Combat.stepCount; i++)
            //{
            //    CombatVariable var0 = m_Combat.steps[i].atkVal;
            //    CombatVariable var1 = m_Combat.steps[i].defVal;
            //    Debug.LogFormat("({4}) -> Animation Type: ({0}, {1}), ({2}, {3})",
            //        var0.position.ToString(),
            //        var0.animaType.ToString(),
            //        var1.position.ToString(),
            //        var1.animaType.ToString(),
            //        i);
            //}
            //m_Combat.BattleEnd();

            //Debug.LogFormat("{0}.hp = {1}, {2}.hp = {3}",
            //    m_TestClass1.role.character.info.name,
            //    m_TestClass1.role.hp,
            //    m_TestClass2.role.character.info.name,
            //    m_TestClass2.role.hp);

            ReloadCombat();
        }