Ejemplo n.º 1
0
    //导入;
    public void InputFile(string filename)
    {
        string path = "Assets/Resources/text/map/" + filename + ".txt";
        MapObj mo   = DeserializeFromFile <MapObj> (path);

        mapgrid.data = mo.data;
    }
Ejemplo n.º 2
0
    protected override bool OnBeforeCollision(Fixture fixtureA, Fixture fixtureB)
    {
        if (null == b2Body)
        {
            return(false);
        }
        if (!m_isActive)
        {
            return(false);
        }
        Fixture other = (fixtureA.Body == b2Body) ? fixtureB : fixtureA;
        MapObj  obj   = other.Body.UserData as MapObj;

        if (obj == null)
        {
            return(false);
        }

        //UnityEngine.Debug.Log("人物碰撞 Before");
        MapCollider collider = other.Body.UserData as MapCollider;

        // 是单向通过
        if (collider != null && collider.isOneWay)
        {
            float vDot = Vector2.Dot(m_linearVelocity, collider.oneWayDir);
            if (vDot > 0.5f)
            {
                return(false); // 移动方向和可通行方向相同 可通过
            }
        }

        return(true);
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds all items in <paramref name="unit"/>'s inventory with a category in <c>Categories</c> and lowers their min range by <c>Value</c>.
        /// </summary>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            foreach (UnitInventoryItem item in unit.Inventory)
            {
                if (item == null)
                {
                    continue;
                }

                //The item must have a listed category
                if (!this.Categories.Contains(item.Item.Category))
                {
                    continue;
                }

                //Items with a minimum range of 0 are not affected
                if (item.Item.Range.Minimum == 0)
                {
                    continue;
                }

                //If this modifier is less than the one we're currently using, apply it
                if (this.Value < item.MinRangeModifier)
                {
                    item.MinRangeModifier = this.Value;
                }
            }
        }
Ejemplo n.º 4
0
    protected override void OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
    {
        //UnityEngine.Debug.Log("OnCollision : ");
        Fixture other = (fixtureA.Body == b2Body) ? fixtureB : fixtureA;
        MapObj  obj   = other.Body.UserData as MapObj;

        if (obj == null)
        {
            return;
        }
        //UnityEngine.Debug.Log("人物碰撞 On");
        //MapCollider collider = other.Body.UserData as MapCollider;
        //if (collider != null)
        //{
        //    // 是传感器 特殊处理
        //    if (collider.m_isSensor)
        //    {
        //        // 速度改变
        //        collider.SaveOldSpeedRatio(m_velocityRatio);
        //        m_velocityRatio = collider.speedRatio;
        //        // 移动方向固定
        //        if (collider.isStuckDir == true)
        //        {
        //            m_bIsStuck = true;
        //        }
        //        // 外加力
        //        if (collider.forceDir.LengthSquared() > 0.1f)
        //        {
        //            m_force = m_force + collider.forceDir;
        //        }
        //    }
        //}
    }
Ejemplo n.º 5
0
 // 绘制当前选中物体信息面板
 static void DrawSelectObjInfoBox(GUIStyle boxSink, GUIStyle btnSink)
 {
     if (Selection.activeTransform)
     {
         Vector2    centerBoxPos = new Vector2(Screen.width / 2 - centerBoxSize.x / 2, 10);
         GameObject selectObj    = Selection.activeTransform.gameObject;
         MapObj     selectScript = selectObj.GetComponent <MapObj>();
         // 当前选中物体
         GUILayout.BeginArea(new Rect(centerBoxPos.x, centerBoxPos.y, centerBoxSize.x, centerBoxSize.y), "当前选中物体", boxSink);
         GUILayout.Space(30);
         EditorGUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUILayout.Label("Name: " + selectObj.name);
         GUILayout.Label("ID: " + selectScript.id);
         GUILayout.FlexibleSpace();
         EditorGUILayout.EndHorizontal();
         GUILayout.Space(10);
         if (GUILayout.Button("删除当前选中物体", btnSink))
         {
             // 地图
             if (selectObj.Equals(editor.curMap))
             {
                 if (EditorUtility.DisplayDialog("警告", "当前选中的是地图! 是否确认删除?", "Ok", "Cancel"))
                 {
                     editor.DeleteMap();
                 }
             }
             else
             {
                 DestroyImmediate(selectObj);
             }
         }
         GUILayout.EndArea();
     }
 }
        /// <summary>
        /// Locates enemy units and adds tiles within <c>Radius</c> tiles of their origin to <paramref name="unit"/>'s movement range.
        /// </summary>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //If unit is not on the map, don't apply
            if (!unit.Location.IsOnMap())
            {
                return;
            }

            //Unit must have an HP percentage below the configured value
            if (unit.Stats.HP.Percentage > this.HPPercentage)
            {
                return;
            }

            if (unit.Location.UnitSize > 1)
            {
                throw new SkillEffectMultitileUnitsNotSupportedException(this.Name);
            }

            //Locate valid enemy units and select tiles near them
            IList <Tile> tiles = units.Where(u => u.AffiliationObj.Grouping != unit.AffiliationObj.Grouping &&
                                             u.Location.IsOnMap() &&
                                             (u.Location.OriginTiles.Any(o1 => unit.Location.OriginTiles.Any(o2 => o1.Coordinate.DistanceFrom(o2.Coordinate) <= this.TeleportationRange)) || this.TeleportationRange == 99))
                                 .SelectMany(u => map.GetTilesInRadius(u.Location.OriginTiles, this.Radius))
                                 .ToList();

            AddTeleportTargetsToUnitRange(unit, tiles);
        }
Ejemplo n.º 7
0
    // static int[] bedRoom;

    public static void initMapData()
    {
        // 15 x 17 room
        int[] firstWaveMapData =
        {
            0,   0,  0,  0, -1, -1, -1, -1, -1, -1,  0,  0,  0,  0,  0,
            0,   0,  0,  0, -1,  0,  4,  3,  4, -1, -1, -1,  0,  0,  0,
            0,   0,  0,  0, -1, -2, -1, -1,  0,  0,  0, -1,  0,  0,  0,
            0,   0,  0,  0, -1,  0, -1, -1, -1, -1, -2, -1, -1, -1,  0,
            0,  -1, -1, -1, -1,  0, -1, -1, -1, -1,  0,  0,  0, -1,  0,
            -1, -1,  0,  0,  0,  0, -2, -2,  0, -1, -1, -1,  0, -1,  0,
            -1,  0, -2, -1, -1, -1, -1, -1, -1, -1, -2,  0,  0, -1, -1,
            -1,  0,  0,  0,  0, -1, -1, -1, -1, -1, -1, -1,  0,  0, -1,
            -1, -1, -1, -1,  0, -1,  0,  0,  0, -2,  0,  0,  0,  0, -1,
            0,   0,  0, -1, -2, -1, -1,  0, -1, -1, -1, -1, -1, -1, -1,
            0,   0,  0, -1,  0, -1, -1,  0, -1,  0,  0,  0,  0,  0,  0,
            0,   0,  0, -1,  0,  0,  0, -2, -1,  0,  0,  0,  0,  0,  0,
            0,   0,  0, -1, -1, -1, -1,  0, -1, -1, -1, -1,  0,  0,  0,
            0,   0,  0,  0,  0,  0, -1, -2,  5,  0,  5, -1,  0,  0,  0,
            0,   0,  0,  0,  0,  0, -1, -1, -1, -1,  0, -1,  0,  0,  0,
            0,   0,  0,  0,  0,  0,  0,  0,  0, -1,  1, -1,  0,  0,  0,
            0,   0,  0,  0,  0,  0,  0,  0,  0, -1, -1, -1,  0,  0, 0
        };

        firstWave = new MapObj(15, 17, firstWaveMapData, MapNameData.FIRST_MAP);
    }
Ejemplo n.º 8
0
    static void DrawGameObjectName(Transform transform, GizmoType gizmoType)
    {
        if (!MapEdit.isDrawObjInfo)
        {
            return;
        }
        MapObj        obj   = transform.GetComponent <MapObj>();
        StringBuilder str   = new StringBuilder();
        Color         color = Color.white;

        if (obj)
        {
            str.Append("ID: " + obj.id);
            str.Append("\n");
            color = obj.nameColor;
        }
        if (obj == null || obj.id < 10000)
        {
            return;
        }

        str.Append("name: " + transform.gameObject.name);
        str.Append("\n");
        str.Append("pos: " + transform.position.ToString());
        str.Append("\n");

        GUIStyle style = new GUIStyle("textfield");

        style.normal.textColor = color;
        style.fixedHeight      = 50;
        Handles.Label(transform.position + new Vector3(0, 2f, 0), str.ToString(), style);
    }
        public Respuesta <T> ObtenerCentroEducativos <T>(string sentencia, Respuesta <T> respuesta)
        {
            try
            {
                List <T> list;
                T        obj = obj = Activator.CreateInstance <T>();

                using (miconexion = new MySqlConnection(WebConfigurationManager.AppSettings["CadenaConexion"]))
                {
                    miconexion.Open();
                    micomando = new MySqlCommand(string.Format(sentencia), miconexion);
                    if (miconexion.State != ConnectionState.Open)
                    {
                        respuesta.Log = "Error al conectar con la base de datos";
                        return(respuesta);
                    }
                    else
                    {
                        micomando.ExecuteNonQuery();
                        adapter = new MySqlDataAdapter(micomando);
                        //reader = micomando.ExecuteReader();
                        dt = new DataTable();
                        adapter.Fill(dt);

                        if (dt.Rows.Count < 1)
                        {
                            respuesta.Log = "No se encontraron resultados";
                            return(respuesta);
                        }
                        else
                        {
                            MapObj mapObj = new MapObj();

                            list = new List <T>();
                            list = mapObj.DataTableMapToList <T>(dt);
                            if (list.Count < 1)
                            {
                                respuesta.Log = "Error al realizar el mapeo";
                                return(respuesta);
                            }
                            else
                            {
                                respuesta.MyListGen = list;
                                respuesta.Log       = "Consulta de " + obj.GetType().ToString().Split('.').Last() + " ejecutada correctamente";
                                return(respuesta);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                respuesta.Log = "-- Excepxion econtrada: --  " + ex;
                return(respuesta);
                //MessageBox.Show("Este es su error" + Ex.ToString(), "JESUCRISTO te ama", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Finds all items in <paramref name="unit"/>'s inventory with a category in <c>Categories</c> and sets their max range to <c>Value</c>.
        /// </summary>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            foreach (UnitInventoryItem item in unit.Inventory)
            {
                if (item == null)
                {
                    continue;
                }

                //The item must have a listed category
                if (!this.Categories.Contains(item.Item.Category))
                {
                    continue;
                }

                //Items with a max range of 99 are not affected
                if (item.Item.Range.Maximum == 99)
                {
                    continue;
                }

                //Calculate the difference between the set value and the item's base max range
                int modifier = this.Value - item.Item.Range.Maximum;

                //If there is a difference and it's larger than what we're already applying, use it
                if (modifier > 0 && modifier > item.MaxRangeModifier)
                {
                    item.MaxRangeModifier = modifier;
                }
            }
        }
Ejemplo n.º 11
0
    // 创建物体
    void CreateGameObj()
    {
        if (curMap == null)
        {
            EditorUtility.DisplayDialog("创建失败!", "未找到地图, 请先创建一个新地图或者选择一个可编辑的地图", "ok", "cancel");
            return;
        }
        MapObj[] children = curMap.transform.GetComponentsInChildren <MapObj>();
        foreach (var child in children)
        {
            if (child.id == curObjID)
            {
                EditorUtility.DisplayDialog("创建失败!", "当前ID已存在,请重新输入唯一ID", "ok", "cancel");
                return;
            }
        }

        GameObject go = Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>(objsPath + "/" + objsLists[selectObjIndex] + ".prefab"));

        go.transform.parent   = curMap.transform;
        go.transform.position = curObjPos;
        go.name = objsLists[selectObjIndex];
        MapObj objScript = go.GetComponent <MapObj>();

        objScript           = objScript ? objScript : go.AddComponent <MapObj>();
        objScript.id        = curObjID;
        objScript.nameColor = curObjColor;
        curObjID++;
        // 取消聚焦
        GUI.FocusControl(null);
    }
Ejemplo n.º 12
0
    void CreateNewMap()
    {
        if (MapIsExistByName(newMapName) && !EditorUtility.DisplayDialog("警告!", newMapName + "已存在, 确定覆盖?", "ok", "cancel"))
        {
            return;
        }
        if (MapIsExistByID(newMapID))
        {
            EditorUtility.DisplayDialog("创建失败!", newMapID + " ID 已存在,请重新输入唯一ID", "ok", "cancel");
            return;
        }

        if (curMap)
        {
            DestroyImmediate(curMap);
        }
        // 实例化
        curMap = Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>(mapTempsPath + "/" + mapTempLists[selectMapTempIndex] + ".prefab"));
        curMap.transform.position = Vector3.zero;
        curMap.name = newMapName;
        MapObj script = curMap.AddComponent <MapObj>();

        script.id = newMapID;
        // 保存
        PrefabUtility.SaveAsPrefabAsset(curMap, mapsPath + "/" + curMap.name + ".prefab");
        CreateMapJson();
        AssetDatabase.Refresh();
        UpdateSelectMapUI();
    }
Ejemplo n.º 13
0
    public void SpawnMap()
    {
        //实例化Map节点
        map = new MapObj();

        //生成显示Player信息的CameraUI层
        infoHUD = new HUD();
    }
Ejemplo n.º 14
0
        /// <summary>
        /// Adds the items in <c>Values</c> as modifiers to the stats in <c>Stats</c> for <paramref name="unit"/>'s paired partner, if one exists.
        /// </summary>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //Validate that the unit is in the back of a pairup
            if (unit.Location.PairedUnitObj == null || !unit.Location.IsBackOfPair)
            {
                return;
            }

            ApplyUnitStatModifiers(unit.Location.PairedUnitObj, $"{unit.Name}'s {skill.Name}", this.Stats, this.Values);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// If <paramref name="unit"/>'s HP percentage is equal to or above the value of <c>HPPercentage</c>, adds the values in <c>Values</c> as modifiers to the items in <c>Stats</c>.
        /// </summary>
        /// <exception cref="UnmatchedStatException"></exception>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //HP percentage must be equal to or above threshold
            if (unit.Stats.HP.Percentage < this.HPPercentage)
            {
                return;
            }

            ApplyUnitStatModifiers(unit, skill.Name, this.Stats, this.Values);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Broadcast the message in the block around the specified map object.
        /// </summary>
        /// <param name="aObj">The map object.</param>
        /// <param name="aMsg">The message to broadcast.</param>
        public void BroadcastBlockMsg(MapObj aObj, Msg aMsg)
        {
            var players = (from entity in Entities.Values
                           where entity.IsPlayer() && MyMath.CanSee(aObj.X, aObj.Y, entity.X, entity.Y, MyMath.NORMAL_RANGE)
                           select(Player) entity);

            foreach (var player in players)
            {
                player.Send(aMsg);
            }
        }
        /// <summary>
        /// Marks all tiles within <c>this.Radius</c> tiles of <paramref name="unit"/>'s origin as obstructed.
        /// </summary>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //If unit is not on the map, don't apply
            if (!unit.Location.IsOnMap())
            {
                return;
            }

            List <Tile> radius = map.GetTilesInRadius(unit.Location.OriginTiles, this.Radius);

            radius.ForEach(t => t.UnitData.ObstructingUnits.Add(unit));
        }
Ejemplo n.º 18
0
    void ApplyPackDropItem(List <DropItemInfo> itemList)
    {
        //lz-2017.01.03 crash bug 错误 #8002
        if (null == itemList)
        {
            return;
        }
        if (null == GameUI.Instance || null == GameUI.Instance.mMainPlayer)
        {
            return;
        }

        Pathea.SkAliveEntity skEntity = GameUI.Instance.mMainPlayer.GetCmpt <Pathea.SkAliveEntity>();
        if (skEntity == null || null == skEntity.Entity)
        {
            return;
        }

        mDropReq.Clear();
        foreach (DropItemInfo itemInfo in itemList)
        {
            if (null != itemInfo && null != itemInfo.mDropItemObj)
            {
                mDropReq.Add(itemInfo.mDropItemObj.instanceId);
            }
        }
        MapObj[]   mapObjs = new MapObj[1];
        RaycastHit hitInfo;
        int        count = 0;

        while (count++ < 100)
        {
            if (skEntity.Entity)
            {
                Vector3 offsetPos = new Vector3(Random.Range(-2f, 2f), 2f, Random.Range(-2f, 2f));
                if (Physics.Raycast(skEntity.Entity.position + offsetPos, Vector3.down, out hitInfo, 10f, mItemDroplayer))
                {
                    if (!hitInfo.collider.isTrigger && hitInfo.distance < 10f)
                    {
                        mapObjs[0]       = new MapObj();
                        mapObjs[0].pos   = hitInfo.point;
                        mapObjs[0].objID = skEntity.GetId();
                        break;
                    }
                }
            }
        }
        if (mapObjs[0] != null)
        {
            PlayerNetwork.mainPlayer.CreateMapObj((int)DoodadType.DoodadType_Drop, mapObjs);
        }
    }
Ejemplo n.º 19
0
    //导出;
    public void OutputFile(string filename)
    {
        string path = Application.dataPath + "/Resources/text/map/" + filename + ".txt";
        MapObj mo   = new MapObj();

        mo.gridw    = mapgrid.gridw;
        mo.xgridnum = mapgrid.xgridnum;
        mo.ygridnum = mapgrid.ygridnum;
        mo.mapw     = mapgrid.mapw;
        mo.maph     = mapgrid.maph;
        mo.data     = mapgrid.data;
        SerializeToFile <MapObj> (path, mo);
        AssetDatabase.Refresh();
    }
Ejemplo n.º 20
0
    protected override void OnAfterCollision(Fixture fixtureA, Fixture fixtureB, Contact contact, ContactVelocityConstraint impulse)
    {
        //UnityEngine.Debug.Log("OnAfterCollision : ");
        if (null == b2Body)
        {
            return;
        }
        Fixture other = (fixtureA.Body == b2Body) ? fixtureB : fixtureA;
        MapObj  obj   = other.Body.UserData as MapObj;

        if (obj == null)
        {
            return;
        }
    }
Ejemplo n.º 21
0
        /// <summary>
        /// Searches the <paramref name="units"/> list for hostile units within <c>Radius</c> tiles. If it finds one, adds the values in <c>Values</c> as modifiers to the items in <c>Stats</c>.
        /// </summary>
        /// <exception cref="UnmatchedStatException"></exception>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //If unit is not on the map, don't apply
            if (!unit.Location.IsOnMap())
            {
                return;
            }

            //Apply modifiers to enemies in range
            foreach (Unit enemy in units.Where(u => u.AffiliationObj.Grouping != unit.AffiliationObj.Grouping && //different affiliation grouping
                                               u.Location.IsOnMap() &&
                                               u.Location.OriginTiles.Any(o1 => unit.Location.OriginTiles.Any(o2 => o2.Coordinate.DistanceFrom(o1.Coordinate) <= this.Radius))))
            {
                ApplyUnitCombatStatModifiers(enemy, $"{unit.Name}'s {skill.Name}", this.Stats, this.Values);
            }
        }
        /// <summary>
        /// If <paramref name="unit"/> originates on a tile with a terrain type in <c>TerrainTypeGrouping</c>, then the values in <c>Values</c> are added as modifiers to the items in <c>Stats</c>.
        /// </summary>
        /// <exception cref="UnmatchedStatException"></exception>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //If unit is not on the map, don't apply
            if (!unit.Location.IsOnMap())
            {
                return;
            }

            //The terrain type must be in the defined grouping
            if (!unit.Location.OriginTiles.Any(o => o.TerrainTypeObj.Groupings.Contains(this.TerrainTypeGrouping)))
            {
                return;
            }

            ApplyUnitStatModifiers(unit, skill.Name, this.Stats, this.Values);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// If <paramref name="unit"/> has an item equipped with a category in <c>Categories</c>, then the values in <c>Values</c> are added as modifiers to the items in <c>Stats</c>.
        /// </summary>
        /// <exception cref="UnmatchedStatException"></exception>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            UnitInventoryItem equipped = unit.Inventory.SingleOrDefault(i => i != null && i.IsEquipped);

            if (equipped == null)
            {
                return;
            }

            //The equipped item's category must be in the category list
            if (!this.Categories.Contains(equipped.Item.Category))
            {
                return;
            }

            ApplyUnitCombatStatModifiers(unit, skill.Name, this.Stats, this.Values);
        }
        /// <summary>
        /// Searches the <paramref name="units"/> list for friendly units within <c>Radius</c> tiles. If it finds one, adds the values in <c>Values</c> as modifiers to the items in <c>Stats</c>.
        /// </summary>
        /// <exception cref="UnmatchedStatException"></exception>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //If unit is not on the map, don't apply
            if (!unit.Location.IsOnMap())
            {
                return;
            }

            //Apply modifiers to unit if allies in range
            if (units.Any(u => u.Name != unit.Name && //different unit name
                          u.AffiliationObj.Grouping == unit.AffiliationObj.Grouping &&   //same affiliation grouping
                          u.Location.IsOnMap() &&
                          u.Location.OriginTiles.Any(o1 => unit.Location.OriginTiles.Any(o2 => o2.Coordinate.DistanceFrom(o1.Coordinate) <= this.Radius))))
            {
                ApplyUnitStatModifiers(unit, skill.Name, this.Stats, this.Values);
            }
        }
        /// <summary>
        /// Marks all tiles within <c>this.Radius</c> tiles of <paramref name="unit"/>'s origin as obstructed when <paramref name="unit"/>'s HP percentage is above <c>this.HPPercentage</c>.
        /// </summary>
        public override void Apply(Unit unit, Skill skill, MapObj map, IList <Unit> units)
        {
            //If unit is not on the map, don't apply
            if (!unit.Location.IsOnMap())
            {
                return;
            }

            //Unit HP percentage must be equal to or above the threshold
            if (unit.Stats.HP.Percentage < this.HPPercentage)
            {
                return;
            }

            List <Tile> radius = map.GetTilesInRadius(unit.Location.OriginTiles, this.Radius);

            radius.ForEach(t => t.UnitData.ObstructingUnits.Add(unit));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Calculates the anchor and origin tiles for <paramref name="unit"/>.
        /// </summary>
        /// <param name="applyTileBinding">Should be true for any unit that's not in pair-up.</param>
        private static void AddUnitToMap(Unit unit, MapObj map, bool applyTileBinding)
        {
            //Ignore hidden units
            if (unit.Location.Coordinate.X < 1 || unit.Location.Coordinate.Y < 1)
            {
                return;
            }

            for (int y = 0; y < unit.Location.UnitSize; y++)
            {
                for (int x = 0; x < unit.Location.UnitSize; x++)
                {
                    Tile tile = map.GetTileByCoord(unit.Location.Coordinate.X + x, unit.Location.Coordinate.Y + y);

                    //Make sure this unit is not placed overlapping another
                    if (tile.UnitData.Unit != null && unit.Name != tile.UnitData.Unit.Name && applyTileBinding)
                    {
                        throw new UnitTileOverlapException(unit, tile.UnitData.Unit, tile.Coordinate);
                    }

                    unit.Location.OriginTiles.Add(tile);
                    unit.Ranges.Movement.Add(tile.Coordinate);

                    if (applyTileBinding)
                    {
                        tile.UnitData.Unit         = unit;
                        tile.UnitData.IsUnitOrigin = true;

                        if (x == 0 && y == 0)
                        {
                            //Mark the anchor tile
                            unit.Location.AnchorTile   = tile;
                            tile.UnitData.IsUnitAnchor = true;
                        }
                    }

                    //Apply terrain type effects from the origin tile.
                    ApplyTileTerrainTypeToUnit(unit, tile);
                    ApplyTileTerrainEffectsToUnit(unit, tile);
                }
            }
        }
        private MapObj GetFilledRandomMapObj(string OmitPropName)
        {
            MapObj mapObj = new MapObj();

            if (OmitPropName != "MapInfoID")
            {
                mapObj.MapInfoID = GetRandomInt(1, 11);
            }
            if (OmitPropName != "MapInfoDrawType")
            {
                mapObj.MapInfoDrawType = (MapInfoDrawTypeEnum)GetRandomEnumType(typeof(MapInfoDrawTypeEnum));
            }
            if (OmitPropName != "MapInfoDrawTypeText")
            {
                mapObj.MapInfoDrawTypeText = GetRandomString("", 5);
            }
            //CSSPError: property [CoordList] and type [MapObj] is  not implemented

            return(mapObj);
        }
Ejemplo n.º 28
0
    protected override bool OnBeforeCollision(Fixture fixtureA, Fixture fixtureB)
    {
        //UnityEngine.Debug.Log("OnBeforeCollision : ");
        if (null == b2Body)
        {
            return(false);
        }
        if (!m_isActive)
        {
            return(false);
        }
        Fixture other = (fixtureA.Body == b2Body) ? fixtureB : fixtureA;
        MapObj  obj   = other.Body.UserData as MapObj;

        if (obj == null)
        {
            return(false);
        }

        return(true);
    }
Ejemplo n.º 29
0
    public void setMap(MapObj map, utils utilsSys)
    {
        _curMap = map;

        float aspect = CanvasCtrl.deviceWidth / CanvasCtrl.deviceHeight;

        this._gridWidth  = Mathf.FloorToInt(CanvasCtrl.deviceWidth / (_curMap.width + 2));
        this._gridHeight = Mathf.CeilToInt(CanvasCtrl.deviceHeight / (_curMap.height + 2) * aspect);

        this._offsetX = Mathf.CeilToInt(this._gridWidth);
        this._offsetY = Mathf.CeilToInt(_curMap.height / 2 * this._gridHeight);

        GameManagerGlobalData.isFirstTimeGenerateMap = true;
        parseMapData();

        // 更新新的地图数据以及捆绑剧情处理函数
        if (utilsSys != null)
        {
            utilsSys.updateCurMap();
        }
    }
Ejemplo n.º 30
0
    // 绘制地图信息面板
    static void DrawMapInfoBox(GUIStyle boxSink, GUIStyle btnSink)
    {
        GUI.Box(new Rect(0, 0, 200, 220), "地图信息", boxSink);
        GUI.Box(new Rect(0, 0, 200, 220), "地图信息", boxSink);
        GUILayout.Label("当前编辑的地图 : " + MapEdit.editor.curMap.name);
        GUILayout.Label("ID:  " + editor.curMap.GetComponent <MapObj>().id);
        GUILayout.Label("子物体: " + editor.curMap.transform.childCount);

        mPos = GUILayout.BeginScrollView(mPos, GUILayout.Width(200), GUILayout.Height(130));
        foreach (Transform child in editor.curMap.transform)
        {
            MapObj childScript = child.GetComponent <MapObj>();
            GUILayout.BeginHorizontal();
            GUILayout.Label(childScript.id + ": " + child.name);
            if (GUILayout.Button("删除", btnSink))
            {
                DestroyImmediate(child.gameObject);
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndScrollView();
    }