void StartLevelTransition(ExitDirection dir)
    {
        Vector3 exitDest, mid, enterSource;
        mid = Vector3.zero;
        var ll = GameObject.FindObjectOfType (typeof(LevelLoader)) as LevelLoader;
        if (ll != null) {
            switch (dir) {
            case ExitDirection.Left:
                exitDest = new Vector3 (20f, 0f, 0f);
                enterSource = new Vector3 (-20f, 0f, 0f);
                break;
            case ExitDirection.Right:
                exitDest = new Vector3 (-20f, 0f, 0f);
                enterSource = new Vector3 (20f, 0f, 0f);
                break;
            case ExitDirection.Top:
                exitDest = new Vector3 (0f, 0f, -15f);
                enterSource = new Vector3 (-20f, 0f, 15f);
                break;
            default:
                exitDest = new Vector3 (0f, 0f, 15f);
                enterSource = new Vector3 (-20f, 0f, -15f);
                break;
            }

            var oldLvl = ll.lvl;
            var player = GameObject.FindGameObjectWithTag ("Player");
            GameObject.Destroy (player);
            var newLvl = ll.LoadNextLevel (enterSource);
            StartCoroutine (LevelTransition (oldLvl, newLvl, exitDest));
        }
    }
 public static ExitDirection GetOppositeDirection(ExitDirection original)
 {
     switch(original)
     {
         case ExitDirection.North: return ExitDirection.South;
         case ExitDirection.East: return ExitDirection.West;
         case ExitDirection.South: return ExitDirection.North;
         case ExitDirection.West: return ExitDirection.East;
         case ExitDirection.Up: return ExitDirection.Down;
         case ExitDirection.Down: return ExitDirection.Up;
     }
     return ExitDirection.None;
 }
        public void TransitionToArea(CLRScriptBase script, ExitDirection exit)
        {
            string doorTag = "DOOR_NORTH";
            switch(exit)
            {
                case ExitDirection.North:
                    doorTag = "DOOR_NORTH";
                    break;
                case ExitDirection.East:
                    doorTag = "DOOR_EAST";
                    break;
                case ExitDirection.South:
                    doorTag = "DOOR_SOUTH";
                    break;
                case ExitDirection.West:
                    doorTag = "DOOR_WEST";
                    break;
                case ExitDirection.Up:
                    doorTag = "DOOR_UP";
                    break;
                case ExitDirection.Down:
                    doorTag = "DOOR_DOWN";
                    break;
            }
            if(script.GetIsObjectValid(script.GetLocalObject(AreaId, doorTag)) == CLRScriptBase.TRUE)
            {
                uint door = script.GetLocalObject(AreaId, doorTag);
                script.JumpToObject(door, CLRScriptBase.TRUE);
                return;
            }

            foreach(uint obj in script.GetObjectsInArea(AreaId))
            {
                if(script.GetTag(obj) == doorTag)
                {
                    script.SetLocalObject(AreaId, doorTag, obj);
                    script.JumpToObject(obj, CLRScriptBase.TRUE);
                    return;
                }
            }
            script.SendMessageToPC(script.OBJECT_SELF, "I can't find a door to jump you to.");
        }
        public RandomDungeonArea GetAdjacentArea(CLRScriptBase script, ExitDirection exit, RandomDungeonArea CurrentArea)
        {
            int X = CurrentArea.X;
            int Y = CurrentArea.Y;
            int Z = CurrentArea.Z;

            switch(exit)
            {
                case ExitDirection.North:
                    Y++;
                    break;
                case ExitDirection.East:
                    X++;
                    break;
                case ExitDirection.South:
                    Y--;
                    break;
                case ExitDirection.West:
                    X--;
                    break;
                case ExitDirection.Up:
                    Z++;
                    break;
                case ExitDirection.Down:
                    Z--;
                    break;
            }

            RandomDungeonArea targetArea = null;
            foreach(RandomDungeonArea area in AreasOfDungeon)
            {
                if(area.X == X && area.Y == Y && area.Z == Z)
                {
                    targetArea = area;
                    break;
                }
            }
            return targetArea;
        }
 private RandomDungeonArea getSingleExitArea(ExitDirection exit, string prefix)
 {
     foreach(RandomDungeonArea area in DungeonStore.AvailableAreas[prefix])
     {
         if(area.AreaExits.Contains(exit) && area.AreaExits.Count == 1)
         {
             return area;
         }
     }
     return null;
 }
 private void _setAreaCoordinates(RandomDungeonArea toExpand, RandomDungeonArea toAdd, ExitDirection exit)
 {
     switch (exit)
     {
         case ExitDirection.North:
             toAdd.X = toExpand.X;
             toAdd.Y = toExpand.Y + 1;
             toAdd.Z = toExpand.Z;
             break;
         case ExitDirection.East:
             toAdd.X = toExpand.X + 1;
             toAdd.Y = toExpand.Y;
             toAdd.Z = toExpand.Z;
             break;
         case ExitDirection.South:
             toAdd.X = toExpand.X;
             toAdd.Y = toExpand.Y - 1;
             toAdd.Z = toExpand.Z;
             break;
         case ExitDirection.West:
             toAdd.X = toExpand.X - 1;
             toAdd.Y = toExpand.Y;
             toAdd.Z = toExpand.Z;
             break;
         case ExitDirection.Up:
             toAdd.X = toExpand.X;
             toAdd.Y = toExpand.Y;
             toAdd.Z = toExpand.Z + 1;
             break;
         case ExitDirection.Down:
             toAdd.X = toExpand.X;
             toAdd.Y = toExpand.Y;
             toAdd.Z = toExpand.Z - 1;
             break;
     }
 }
示例#7
0
        private void Warp(ExitDirection exitDir)
        {
            if (Game1.locationRequest == null)
            {
                bool warped = false;

                string   targetDeepWoodsName   = null;
                Location?targetLocationWrapper = null;

                if (level.Value == 1 && exitDir == ExitDirection.TOP)
                {
                    targetDeepWoodsName   = "Woods";
                    targetLocationWrapper = WOODS_WARP_LOCATION;
                }
                else if (GetExit(exitDir) is DeepWoodsExit exit)
                {
                    targetDeepWoodsName = exit.TargetLocationName;
                    if (exit.TargetLocation.X == 0 && exit.TargetLocation.Y == 0)
                    {
                        if (Game1.getLocationFromName(targetDeepWoodsName) is DeepWoods exitDeepWoods)
                        {
                            exit.TargetLocation = new Location(exitDeepWoods.enterLocation.X, exitDeepWoods.enterLocation.Y);
                        }
                    }
                    targetLocationWrapper = exit.TargetLocation;
                }
                else if (CastEnterDirToExitDir(EnterDir) == exitDir)
                {
                    targetDeepWoodsName = parentName.Value;
                    if (ParentExitLocation.X == 0 && ParentExitLocation.Y == 0)
                    {
                        if (Game1.getLocationFromName(targetDeepWoodsName) is DeepWoods parentDeepWoods)
                        {
                            ParentExitLocation = parentDeepWoods.GetExit(EnterDirToExitDir(EnterDir)).Location;
                        }
                    }
                    targetLocationWrapper = ParentExitLocation;
                }

                ModEntry.Log($"Trying to warp from {this.Name}: (ExitDir: {exitDir}, Position: {Game1.player.Position.X}, {Game1.player.Position.Y}, targetDeepWoodsName: {targetDeepWoodsName}, targetLocation: {(targetLocationWrapper?.X ?? -1)}, {(targetLocationWrapper?.Y ?? -1)})", LogLevel.Trace);

                if (targetLocationWrapper.HasValue && targetDeepWoodsName != null)
                {
                    Location targetLocation = targetLocationWrapper.Value;

                    if (!(targetLocation.X == 0 && targetLocation.Y == 0))
                    {
                        if (exitDir == ExitDirection.LEFT)
                        {
                            targetLocation.X += 1;
                        }
                        else if (exitDir == ExitDirection.BOTTOM)
                        {
                            targetLocation.Y += 1;
                        }

                        if (targetDeepWoodsName != "Woods")
                        {
                            DeepWoodsManager.currentWarpRequestName     = targetDeepWoodsName;
                            DeepWoodsManager.currentWarpRequestLocation = new Vector2(targetLocation.X * 64, targetLocation.Y * 64);
                            if (!Game1.IsMasterGame)
                            {
                                DeepWoodsManager.AddBlankDeepWoodsToGameLocations(targetDeepWoodsName);
                            }
                        }

                        Game1.warpFarmer(targetDeepWoodsName, targetLocation.X, targetLocation.Y, false);
                        warped = true;
                    }
                }

                if (!warped)
                {
                    ModEntry.Log("Warp from " + this.Name + " failed. (ExitDir: " + exitDir + ")", LogLevel.Warn);
                }
            }
        }
示例#8
0
 private bool HasExit(ExitDirection exitDir)
 {
     return(GetExit(exitDir) != null);
 }
 public Teleporter GetTeleporterFromDirection(ExitDirection direction) => exitDirections[direction];
 public bool HasDirection(ExitDirection direction) => exitDirections.ContainsKey(direction);