Esempio n. 1
0
    public static bool CanMove(GameObject obj, int checkDirection)       //returns true if movement of given object to given direction is possible
    {
        int[] coordinates = MapUtility.TranslateWorldToMapCoordinates(obj);
        bool  rValue      = false;

        switch (checkDirection)
        {
        case 0:
            rValue = MapUtility.CanMoveRight(coordinates);
            break;

        case 1:
            rValue = MapUtility.CanMoveLeft(coordinates);
            break;

        case 2:
            rValue = MapUtility.CanMoveUp(coordinates);
            break;

        case 3:
            rValue = MapUtility.CanMoveDown(coordinates);
            break;
        }

        return(rValue);
    }
Esempio n. 2
0
    public void LoadLevelCompleteMenu()
    {
        Time.timeScale        = 0;
        MapUtility.GamePaused = true;
        var    nextLevelIndex = MapUtility.GetLevelNumber(SceneManager.GetActiveScene().name, "") + 1;
        string nextLevel      = "Level " + nextLevelIndex;

        SaveManager.Instance().UnlockLevel(nextLevel);
        levelSelectionMenuObject.UpdateLevels();

        //se livello successivo è l'8, next level non interagibile
        if (nextLevelIndex == 8)
        {
            var panel           = LevelCompleteMenu.transform.GetChild(0);
            var buttonNextLevel = panel.GetChild(1);
            var coomingSoon     = panel.GetChild(2);

            buttonNextLevel.gameObject.SetActive(false);
            coomingSoon.gameObject.SetActive(true);
        }
        else
        {
            var panel           = LevelCompleteMenu.transform.GetChild(0);
            var buttonNextLevel = panel.GetChild(1);
            var coomingSoon     = panel.GetChild(2);

            buttonNextLevel.gameObject.SetActive(true);
            coomingSoon.gameObject.SetActive(false);
        }

        LevelCompleteMenu.SetActive(true);
    }
        public async Task <HttpResponseMessage> Get(EmployeeData empData)
        {
            //if (!string.IsNullOrEmpty(empData))
            //{
            //	var JsonDe = JsonConvert.DeserializeObject<EmployeeData>(empData);
            //}
            var allEmpDatadocs = await EmpDetailsCollection.Find(_ => true).ToListAsync();

            List <EmployeeData> allEmpDataList = BsonSerializer.Deserialize <List <EmployeeData> >(allEmpDatadocs.ToJson());

            EmployeeData loggedInEmpData = allEmpDataList.Where(e => e.Email == "*****@*****.**").FirstOrDefault();

            var filteredData = allEmpDataList.Where(e => e.TravelFreq == (string.IsNullOrEmpty(empData.TravelFreq) ? e.TravelFreq : empData.TravelFreq) &&
                                                    e.UserType == (string.IsNullOrEmpty(empData.UserType) ? e.UserType : empData.UserType) &&
                                                    e.VehicleNo == (string.IsNullOrEmpty(empData.VehicleNo) ? e.VehicleNo : empData.VehicleNo) &&
                                                    MapUtility.distance(Convert.ToDouble(e.Latitude), Convert.ToDouble(e.Longitude), Convert.ToDouble(loggedInEmpData.Latitude), Convert.ToDouble(loggedInEmpData.Longitude), "K") < empData.Radius).ToList();

            var jsonData = new
            {
                Result = "test"
            };

            var response = Request.CreateResponse(HttpStatusCode.OK, jsonData, GenerateJsonFormatting());

            response.Content.Headers.ContentType = GenerateMediaType();
            return(response);
        }
Esempio n. 4
0
        public async Task <HttpResponseMessage> GetFilteredData([FromBody] EmployeeData empData)
        {
            try
            {
                var projection = Builders <BsonDocument> .Projection.Exclude("_id");

                var allEmpDatadocs = await EmpDetailsCollection.Find(_ => true).Project(projection).ToListAsync();

                List <EmployeeData> allEmpDataList = BsonSerializer.Deserialize <List <EmployeeData> >(allEmpDatadocs.ToJson());

                EmployeeData loggedInEmpData = allEmpDataList.Where(e => e.Email == empData.Email).FirstOrDefault();

                var filteredData = allEmpDataList.Where(e => e.Active == "1" && e.UserType == (string.IsNullOrEmpty(empData.UserType) ? e.UserType : empData.UserType) &&
                                                        Util.GetEvenOdd(e.VehicleNo) == (string.IsNullOrEmpty(empData.VehicleNo) ? Util.GetEvenOdd(e.VehicleNo) : empData.VehicleNo) &&
                                                        e.Gender == (string.IsNullOrEmpty(empData.Gender) ? e.Gender : empData.Gender) &&
                                                        e.HasParking == (string.IsNullOrEmpty(empData.HasParking) ? e.HasParking : empData.HasParking) &&
                                                        MapUtility.distance(Convert.ToDouble(e.Latitude), Convert.ToDouble(e.Longitude), Convert.ToDouble(loggedInEmpData.Latitude),
                                                                            Convert.ToDouble(loggedInEmpData.Longitude), "K") < empData.Radius).ToList();

                var jsonData = new
                {
                    Result          = filteredData,
                    CurrentUserData = loggedInEmpData
                };

                var response = Request.CreateResponse(HttpStatusCode.OK, jsonData, GenerateJsonFormatting());
                response.Content.Headers.ContentType = GenerateMediaType();
                return(response);
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message, GenerateJsonFormatting()));
            }
        }
Esempio n. 5
0
    static public CellData operator /(CellData a, int num)
    {
        int curId = MapUtility.CoordinateToId(a.Xpos, a.Zpos, a.MapDataCollection.MapSizeX);
        int id    = curId - a.MapDataCollection.MapSizeX * num;

        return(a.MapDataCollection.GetCellById(id));
    }
Esempio n. 6
0
    void MoveToPositionJunction()       //if player is currently not moving, moves him current direction to next junction
    {
        try {
            movePosition = MapUtility.GetJunctionPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), currentDirection);
        }
        catch (Exception e) {
            e.GetType();
            movePosition = MapUtility.GetDeadEndPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), transform.gameObject, currentDirection);
        }

        Destroy(currentTarget);

        currentTarget = Instantiate(targetPrefab) as GameObject;

        currentTarget.transform.parent = GameFunctions.GetAxisOrigin().transform;

        if (!GameFunctions.IsDebbuging())
        {
            currentTarget.SetActive(false);
        }

        currentTarget.transform.localPosition = movePosition;



        iTween.MoveTo(transform.gameObject, iTween.Hash("position", movePosition, "speed", speed, "islocal", true, "easetype", "linear", "oncomplete", "StopMovingJunction", "name", id));
    }
Esempio n. 7
0
    protected void DrawQuad(MapController mapController, AssetCellData cellData)
    {
        if (isPress)
        {
            Vector3 curMousePos = Input.mousePosition;

            //Get cell index
            int curXIndex = -1;
            int curZIndex = -1;
            MapUtility.CalCellIndexByMousePosition(curMousePos, mapController.CenterPosition, mapController.MapSizeX, mapController.MapSizeZ, rayCastMapLayer, ref curXIndex, ref curZIndex);

            int lastXIndex = -1;
            int lastZIndex = -1;
            MapUtility.CalCellIndexByMousePosition(mousePos, mapController.CenterPosition, mapController.MapSizeX, mapController.MapSizeZ, rayCastMapLayer, ref lastXIndex, ref lastZIndex);

            //Get cell position
            Vector3 curPos  = mapController.GetCellPosition(curXIndex, curZIndex);
            Vector3 lastPos = mapController.GetCellPosition(lastXIndex, lastZIndex);

            //Calulate squre ui's position
            Vector3 centerPos = (curPos + lastPos) * 0.5f;
            centerPos = new Vector3(centerPos.x, cellData.Size.y * 0.5f, centerPos.z + 0.1f);
            Vector3 len = (curPos - lastPos).AbsValue() + Vector3.one;
            len = new Vector3(len.x, cellData.Size.y, len.z);

            squareUI.transform.position   = centerPos;
            squareUI.transform.localScale = len;
            squareUI.SetActive(true);
        }
        else
        {
            squareUI.SetActive(false);
        }
    }
Esempio n. 8
0
        public static bool Prefix(Sign __instance, Farmer who, bool justCheckingForActivity, ref bool __result)
        {
            if (justCheckingForActivity)
            {
                return(true);
            }
            var owner = MapUtility.Owner(__instance);

            MarketDay.Log(
                $"Prefix_Sign_checkForAction checking {__instance} {__instance.DisplayName} owner {owner} at {__instance.TileLocation}",
                LogLevel.Debug, true);

            if (owner is null || owner == $"Farmer:{who.Name}")
            {
                return(true);
            }

            MarketDay.Log(
                $"Prefix_Sign_checkForAction preventing action on object at {__instance.TileLocation} owned by {owner}",
                LogLevel.Debug, true);

            who.currentLocation.playSound("clank");
            __instance.shakeTimer = 500;
            __result = false;
            return(false);
        }
Esempio n. 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors();

            //StaticFile Allowance Initialized
            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc();

            //Mapping Initialized
            Mapper.Initialize(cfg =>
            {
                MapUtility.ConfigureMapping(cfg);
            });

            BuildAppSettings();

            if (bool.TryParse(Configuration["AppSettings:Migration:DbSeed"], out var seed) && seed)
            {
                DbInitializer.Seed(context);
            }
        }
Esempio n. 10
0
        public static bool Prefix(Object __instance, GameLocation location, ref bool __result)
        {
            var owner = MapUtility.Owner(__instance);

            MarketDay.Log(
                $"Prefix_Object_performUseAction checking {__instance} {__instance.DisplayName} owner {owner} at {__instance.TileLocation}",
                LogLevel.Debug, true);

            if (owner is null)
            {
                return(true);
            }
            if (owner == $"Farmer:{Game1.player.Name}" || MarketDay.Config.PeekIntoChests)
            {
                return(true);
            }

            MarketDay.Log(
                $"Prefix_Object_performUseAction preventing use of object at {__instance.TileLocation} owned by {owner}",
                LogLevel.Debug, true);

            location.playSound("clank");
            __instance.shakeTimer = 500;
            __result = false;
            return(false);
        }
Esempio n. 11
0
        public static bool Prefix(Object __instance, GameLocation location, ref bool __result)
        {
            var owner = MapUtility.Owner(__instance);

            MarketDay.Log(
                $"Prefix_Object_performToolAction checking {__instance} {__instance.DisplayName} owner {owner} at {__instance.TileLocation}",
                LogLevel.Debug, true);

            if (MarketDay.Config.RuinTheFurniture)
            {
                return(true);
            }
            if (owner is null)
            {
                return(true);
            }

            MarketDay.Log(
                $"Prefix_Object_performToolAction preventing damage to object at {__instance.TileLocation} owned by {owner}",
                LogLevel.Debug, true);
            location.playSound("clank");
            __instance.shakeTimer = 100;
            __result = false;
            return(false);
        }
Esempio n. 12
0
    // 初期化
    public void Initialize()
    {
        // AROWマップデータの読み込み
        var filePath = Path.Combine(Application.streamingAssetsPath, AROW_FILE_NAME);

#if !UNITY_EDITOR && UNITY_ANDROID
        var request = UnityEngine.Networking.UnityWebRequest.Get(filePath);
        request.SendWebRequest();

        while (!request.downloadHandler.isDone)
        {
        }

        mapDataBytes = request.downloadHandler.data;
#else
        mapDataBytes = File.ReadAllBytes(filePath);
#endif
        arowMapObjectModel = ArowMapObjectModel.LoadByData(mapDataBytes);
        var mapRect = MapRectInt.FromDictionary(arowMapObjectModel.InfoList.FullInfoList);
        worldCenter = MapUtility.CalculateWorldCenter(mapRect.East, mapRect.North, mapRect.West, mapRect.South);

        foreach (MAP_CREATE i in Enum.GetValues(typeof(MAP_CREATE)))
        {
            isEndOfFunction.Add(i, false);
        }

        OrthographicSize = (mapRect.North - mapRect.South) / 2f * MapUtility.WorldScale.x;
    }
Esempio n. 13
0
        /// <summary> Either retrieves map dimensions from loaded map, or loads map dimensions from disc. </summary>
        public Vector3I GetOrLoadDimensions()
        {
            var temp = Map;

            if (temp != null)
            {
                return(temp.Bounds.Dimensions);
            }

            lock ( SyncRoot ) {
                if (Map != null)
                {
                    return(Map.Bounds.Dimensions);
                }
                if (!File.Exists(MapFileName))
                {
                    return(Vector3I.Zero);
                }

                try {
                    temp = MapUtility.LoadHeader(MapFileName);
                    return(temp.Bounds.Dimensions);
                } catch (Exception ex) {
                    Logger.Log(LogType.Error,
                               "World.GetOrLoadDimensions: Failed to load map header ({0}): {1}",
                               MapFileName, ex);
                }
                return(Vector3I.Zero);
            }
        }
Esempio n. 14
0
    static GameObject DrawMapObjectDataTopLeftCellPosition(MapObject mapObject, MapObject.ObjectData o, Vector3 topLeftCellPos, int xIndex, int zIndex, Transform parent = null)
    {
        Object obj = Resources.Load(o.PrefabName);

        if (obj != null)
        {
            GameObject go = GameObject.Instantiate(obj) as GameObject;
            go.name = go.name.Substring(0, go.name.LastIndexOf('('));
            AssetCellData assetData = go.GetComponent <AssetCellData>();
            assetData.Rotate(o.Rotation.eulerAngles.y);
            go.transform.parent        = parent;
            go.transform.localPosition = MapUtility.CalCellPosition(null, topLeftCellPos, xIndex, zIndex, assetData.Size);
            go.transform.localPosition = new Vector3(go.transform.localPosition.x, o.Height, go.transform.localPosition.z);
            go.transform.rotation      = o.Rotation;
            go.layer = LayerMask.NameToLayer("Map");

            o.Go              = go;
            assetData.MapObj  = mapObject;
            assetData.ObjData = o;

            return(go);
        }

        return(null);
    }
Esempio n. 15
0
        // Makes sure that the map file exists, is properly named, and is loadable.
        static void CheckMapFile([NotNull] string worldName)
        {
            if (worldName == null)
            {
                throw new ArgumentNullException("worldName");
            }

            // Check the world's map file
            string fullMapFileName = Path.Combine(Paths.MapPath, worldName + ".fcm");
            string fileName        = Path.GetFileName(fullMapFileName);

            if (Paths.FileExists(fullMapFileName, false))
            {
                if (!Paths.FileExists(fullMapFileName, true))
                {
                    // Map file has wrong capitalization
                    FileInfo[] matches = Paths.FindFiles(fullMapFileName);
                    if (matches.Length == 1)
                    {
                        // Try to rename the map file to match world's capitalization
                        Paths.ForceRename(matches[0].FullName, fileName);
                        if (Paths.FileExists(fullMapFileName, true))
                        {
                            Logger.Log(LogType.Warning,
                                       "WorldManager.CheckMapFile: Map file for world \"{0}\" was renamed from \"{1}\" to \"{2}\"",
                                       worldName, matches[0].Name, fileName);
                        }
                        else
                        {
                            Logger.Log(LogType.Error,
                                       "WorldManager.CheckMapFile: Failed to rename map file of \"{0}\" from \"{1}\" to \"{2}\"",
                                       worldName, matches[0].Name, fileName);
                            return;
                        }
                    }
                    else
                    {
                        Logger.Log(LogType.Warning,
                                   "WorldManager.CheckMapFile: More than one map file exists matching the world name \"{0}\". " +
                                   "Please check the map directory and use /WLoad to load the correct file.",
                                   worldName);
                        return;
                    }
                }
                // Try loading the map header
                try {
                    MapUtility.LoadHeader(fullMapFileName);
                } catch (Exception ex) {
                    Logger.Log(LogType.Warning,
                               "WorldManager.CheckMapFile: Could not load map file for world \"{0}\": {1}",
                               worldName, ex);
                }
            }
            else
            {
                Logger.Log(LogType.Warning,
                           "WorldManager.CheckMapFile: Map file for world \"{0}\" was not found.",
                           worldName);
            }
        }
Esempio n. 16
0
    static public bool DrawCell(MapObject mapObject, Vector3 centerPos, int MapSizeX, int MapSizeZ, Transform parent = null)
    {
        Vector3 topLeftCellPos = MapUtility.CalTopLeftCellPosition(centerPos, MapSizeX, MapSizeZ);

        DrawCellByTopLeftCellPosition(mapObject, topLeftCellPos, MapSizeX, MapSizeZ, parent);
        return(true);
    }
Esempio n. 17
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.GetComponent <PlayerMotion>() != null)
        {
            iTween.StopByName(id);
        }

        if (other.gameObject.GetComponent <LeftTeleport>() != null)
        {
            iTween.StopByName(id);
            float[] newPosition = MapUtility.TranslateMapToLevelCoordinates(new int[] { 14, 26 });

            transform.localPosition = new Vector3(newPosition[1], 2.55f, newPosition[0]);
            currentDirection        = Directions.Left;
            MoveToPositionJunction();
        }
        if (other.gameObject.GetComponent <RightTeleport>() != null)
        {
            float[] newPosition = MapUtility.TranslateMapToLevelCoordinates(new int[] { 14, 1 });

            transform.localPosition = new Vector3(newPosition[1], 2.55f, newPosition[0]);
            currentDirection        = Directions.Right;
            MoveToPositionJunction();
        }
    }
Esempio n. 18
0
    Directions PickRandomAvailableDirection()
    {
        List <Directions> availableDirs1 = new List <Directions>();

        for (int i = 0; i < 4; i++)
        {
            if (MapUtility.CanMove(transform.gameObject, i) && MapUtility.OppositeDirection((Directions)i) != currentDirection)
            {
                availableDirs1.Add((Directions)i);
            }
        }

        System.Random rand = new System.Random();

        int count = availableDirs1.Count;

        if (count > 0)
        {
            return(availableDirs1[rand.Next(availableDirs1.Count)]);
        }
        else
        {
            return(MapUtility.OppositeDirection(currentDirection));
        }
    }
Esempio n. 19
0
    public static bool CanMove(int[] coordinates, int checkDirection)       //returns true if movement from given cell to given direction is possible
    {
        bool rValue = false;

        switch (checkDirection)
        {
        case 0:
            rValue = MapUtility.CanMoveRight(coordinates);
            break;

        case 1:
            rValue = MapUtility.CanMoveLeft(coordinates);
            break;

        case 2:
            rValue = MapUtility.CanMoveUp(coordinates);
            break;

        case 3:
            rValue = MapUtility.CanMoveDown(coordinates);
            break;
        }

        return(rValue);
    }
Esempio n. 20
0
        public Map LoadMap() {
            var tempMap = Map;
            if( tempMap != null ) return tempMap;

            lock( SyncRoot ) {
                if( Map != null ) return Map;

                if( File.Exists( MapFileName ) ) {
                    try {
                        Map = MapUtility.Load( MapFileName );
                    } catch( Exception ex ) {
                        Logger.Log( LogType.Error,
                                    "World.LoadMap: Failed to load map ({0}): {1}",
                                    MapFileName, ex );
                    }
                }

                // or generate a default one
                if( Map == null ) {
                    Server.Message( "&WMapfile is missing for world {0}&W. A new map has been created.", ClassyName );
                    Logger.Log( LogType.Warning,
                                "World.LoadMap: Map file missing for world {0}. Generating default flatgrass map.",
                                Name );
                    Map = MapGenerator.GenerateFlatgrass( 128, 128, 64 );
                }

                return Map;
            }
        }
Esempio n. 21
0
    public static Dictionary <Vector2Int, Assets.src.TileMap.TileData> GetMoveableTiles(int x, int y, int distance)
    {
        var tileDict = new Dictionary <Vector2Int, Assets.src.TileMap.TileData>();

        var startX = x - distance;
        var startY = y - distance;
        var endX   = x + distance;
        var endY   = y + distance;


        for (int drawX = startX; drawX <= endX; drawX++)
        {
            for (int drawY = startY; drawY <= endY; drawY++)
            {
                var currentTile = MapUtility.GetTile(drawX, drawY);

                if (currentTile == null)
                {
                    break;
                }

                if (currentTile.IsWalkable)
                {
                    tileDict.Add(new Vector2Int(drawX, drawY), currentTile);
                }
            }
        }

        return(tileDict);
    }
Esempio n. 22
0
    //x and z are the center of cell
    public bool CanBuildOnTheMap(int x, int z, float height, Vector3 collider)
    {
        int xIndex = -1;
        int zIndex = -1;

        MapUtility.CalCellIndexByCenter(x, z, collider, ref xIndex, ref zIndex);
        return(canBuildOnTheMapInternal(xIndex, zIndex, height, collider));
    }
Esempio n. 23
0
    public static void OccupyTile(Character character, Vector2Int position)
    {
        var tile = MapUtility.GetTile(position.x, position.y);

        tile.OccupyTile(character);

        Debug.Log($"tile {position} is occupied by {character.name}");
    }
Esempio n. 24
0
    public void WriteCellData(int x, int z, Vector3 assetSize, UnitType unitType, float height = 0)
    {
        int xIndex = -1;
        int zIndex = -1;

        MapUtility.CalCellIndexByCenter(x, z, assetSize, ref xIndex, ref zIndex);
        writeCellDataInternal(xIndex, zIndex, assetSize, unitType, height);
    }
Esempio n. 25
0
    void MoveToPositionJunction(int[] startingPosition)       //if player is currently not moving, moves him current direction to next junction
    {
        Vector3 movePosition = MapUtility.GetJunctionPosition(startingPosition, currentDirection);

        targetCoordinates = MapUtility.TranslateWorldToMapCoordinates(movePosition);

        iTween.MoveTo(transform.gameObject, iTween.Hash("position", movePosition, "speed", speed, "islocal", true, "easetype", "linear", "oncomplete", "StopMovingJunction", "name", id));
    }
Esempio n. 26
0
    /// <summary>
    /// 依照3d位置,取得cell的資料
    /// </summary>
    /// <param name="pos"></param>
    /// <returns></returns>
    public CellData GetCell(Vector3 pos)
    {
        int x = 0;
        int z = 0;

        MapUtility.GetCellIndexBy3dPosition(pos, CenterPosition, MapSizeX, MapSizeZ, ref x, ref z);
        return(MapDataCollection.GetCell(x, z));
    }
Esempio n. 27
0
    void MoveToPositionDeadend()       //if player is currently not moving, moves him current direction to next junction
    {
        Vector3 movePosition = MapUtility.GetDeadEndPosition(MapUtility.TranslateWorldToMapCoordinates(transform.gameObject), transform.gameObject, currentDirection);

        targetCoordinates = MapUtility.TranslateWorldToMapCoordinates(movePosition);

        iTween.MoveTo(transform.gameObject, iTween.Hash("position", movePosition, "speed", speed, "islocal", true, "easetype", iTween.EaseType.linear, "oncomplete", "StopMovingDeadend", "name", id));
    }
Esempio n. 28
0
    private static void ThrowDamageThing(PlayerStats player)
    {
        if (MapManager.map[Targeting.Position.x, Targeting.Position.y].item == null && MapManager.map[Targeting.Position.x, Targeting.Position.y].isWalkable && MapManager.map[Targeting.Position.x, Targeting.Position.y].enemy == null && MapManager.map[Targeting.Position.x, Targeting.Position.y].type != "Door")
        {
            MapManager.map[Targeting.Position.x, Targeting.Position.y].item     = Info.CurrentItem.gameObject;
            MapManager.map[Targeting.Position.x, Targeting.Position.y].baseChar = Info.CurrentItem.iso.I_symbol;
            if (ColorUtility.TryParseHtmlString(Info.CurrentItem.iso.I_color, out Color color))
            {
                MapManager.map[Targeting.Position.x, Targeting.Position.y].exploredColor = color;
            }
        }
        else
        {
            foreach (var p in MapUtility.GetSimpleNeighbours(Targeting.Position))
            {
                if (MapManager.map[p.x, p.y].item == null && MapManager.map[p.x, p.y].isWalkable && MapManager.map[p.x, p.y].enemy == null && MapManager.map[p.x, p.y].type != "Door")
                {
                    MapManager.map[p.x, p.y].item = Info.CurrentItem.gameObject;
                    MapManager.map[Targeting.Position.x, Targeting.Position.y].baseChar = Info.CurrentItem.iso.I_symbol;
                    if (ColorUtility.TryParseHtmlString(Info.CurrentItem.iso.I_color, out Color color))
                    {
                        MapManager.map[Targeting.Position.x, Targeting.Position.y].exploredColor = color;
                    }
                    break;
                }
            }
        }
        if (MapManager.map[Targeting.Position.x, Targeting.Position.y].enemy == null)
        {
            return;
        }
        var enemy = MapManager.map[Targeting.Position.x, Targeting.Position.y].enemy;
        var npc   = enemy.GetComponent <RoamingNPC>();
        int roll  = UnityEngine.Random.Range(1, 101);

        int calcRoll;

        calcRoll = (roll + player.__dexterity - npc.dex - npc.AC) -
                   Mathf.Max(Mathf.Abs(PlayerMovement.playerMovement.position.x - Targeting.Position.x),
                             Mathf.Abs(PlayerMovement.playerMovement.position.x - Targeting.Position.x));

        if (roll <= 20)
        {
            MissEnemyWakeUp(npc);
            return;
        }
        int damage = 0;

        if (calcRoll > 50 || roll >= 80) //Do we hit?
        {
            damage = Info.GetDamage();
            DealDamageToEnemy(npc, damage);
        }
        else //WE MISSED BUT WE WAKE UP ENEMY
        {
            MissEnemyWakeUp(npc);
        }
    }
Esempio n. 29
0
        static bool ConvertOneMap([NotNull] FileSystemInfo fileSystemInfo)
        {
            if (fileSystemInfo == null)
            {
                throw new ArgumentNullException("fileSystemInfo");
            }

            try {
                Map map;
                if (importer != null)
                {
                    if (!importer.ClaimsName(fileSystemInfo.FullName))
                    {
                        return(false);
                    }
                    Console.Write("Loading {0}... ", fileSystemInfo.Name);
                    map = importer.Load(fileSystemInfo.FullName);
                }
                else
                {
                    Console.Write("Checking {0}... ", fileSystemInfo.Name);
                    map = MapUtility.Load(fileSystemInfo.FullName);
                }

                string targetFileName;
                if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    targetFileName = fileSystemInfo.Name + '.' + exporter.FileExtension;
                }
                else
                {
                    targetFileName = Path.GetFileNameWithoutExtension(fileSystemInfo.Name) + '.' +
                                     exporter.FileExtension;
                }

                string targetPath = Path.Combine(outputDirName, targetFileName);
                if (!overwrite && File.Exists(targetPath))
                {
                    Console.WriteLine();
                    if (!ShowYesNo("File \"{0}\" already exists. Overwrite?", targetFileName))
                    {
                        return(false);
                    }
                }
                Console.Write("Saving {0}... ", Path.GetFileName(targetFileName));
                exporter.Save(map, targetPath);
                Console.WriteLine("ok");
                return(true);
            } catch (NoMapConverterFoundException) {
                Console.WriteLine("skip");
                return(false);
            } catch (Exception ex) {
                Console.WriteLine("ERROR");
                Console.Error.WriteLine("{0}: {1}", ex.GetType().Name, ex.Message);
                return(false);
            }
        }
Esempio n. 30
0
    /// <summary>
    /// 依照3d位置,取得此cell的3d位置
    /// </summary>
    /// <param name="xIndex"></param>
    /// <param name="zIndex"></param>
    /// <param name="assetSize"></param>
    /// <returns></returns>
    public Vector3 GetCellPosition(int xIndex, int zIndex, Vector3 assetSize)
    {
        if (xIndex < 0 || zIndex < 0 || xIndex >= MapSizeX || zIndex >= MapSizeZ)
        {
            return(Vector3.zero);
        }

        return(MapUtility.CalCellPosition(MapDataCollection, MapUtility.CalTopLeftCellPosition(CenterPosition, MapSizeX, MapSizeZ), xIndex, zIndex, assetSize));
    }