Beispiel #1
0
        public MapClass CreateMapClass()
        {
            if (m_SelectedCls != null)
            {
                return(m_SelectedCls);
            }
            MapClass cls = MapClass.Instantiate <MapClass>(m_ClsPrefab, m_Map.mapObjectPool.transform, false);

            cls.map = m_Map;
            cls.Load(0);
            cls.UpdatePosition(m_CreatePosition);
            m_SelectedCls = cls;
            return(cls);
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public static bool CopySelectedMap(IWorkspace pWorkspace, string strCondition, out IMap pMap)
        {
            pMap = null;
            if (pWorkspace != null)
            {
                try
                {
                    //读取数据库表内容
                    Fan.Common.Gis.SysGisTable sysTable = new Fan.Common.Gis.SysGisTable(pWorkspace);
                    Exception err = null;
                    Dictionary <string, object> pDic = sysTable.GetRow(_MxdListTable, strCondition, out err);
                    if (pDic != null)
                    {
                        if (pDic.ContainsKey(_MxdListTable_MapField))
                        {
                            if (pDic[_MxdListTable_MapField] != null)  //这里仅能成功导出当初以文件类型导入的BLOB字段
                            {
                                object tempObj = pDic[_MxdListTable_MapField];
                                IMemoryBlobStreamVariant pMemoryValue;
                                pMemoryValue = (IMemoryBlobStreamVariant)tempObj;
                                object objValue;
                                pMemoryValue.ExportToVariant(out objValue);
                                byte[]     pbyte      = objValue as byte[];
                                IXMLStream pXMLStream = new XMLStream();
                                pXMLStream.LoadFromBytes(ref pbyte);
                                IStream        pStream        = pXMLStream as IStream;
                                IPersistStream pPersistStream = new MapClass();
                                pPersistStream.Load(pStream);
                                pMap = pPersistStream as IMap;

                                sysTable = null;
                                return(true);
                            }
                        }
                    }
                    sysTable = null;
                }
                catch (Exception err)
                { }
            }
            return(false);
        }
        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();
        }