Exemple #1
0
        // -------------------------------------------------------------------------------
        //
        // -------------------------------------------------------------------------------
        public static bool IsOppositeDirection(Vector3 v1, Vector3 v2)
        {
            DirectionType dir1 = Vector3Helper.CardinalDirection(v1);
            DirectionType dir2 = Vector3Helper.CardinalDirection(v2);

            return(IsOppositeDirection(dir1, dir2));
        }
Exemple #2
0
 // -------------------------------------------------------------------------------
 //
 // -------------------------------------------------------------------------------
 private void OnTurned()
 {
     facingDirection = Vector3Helper.CardinalDirection(transform.forward);
     if (!Finder.battle.InBattle)
     {
         enabled = true;
     }
     changedDirection = true;
     OnPlayerTurned();
 }
Exemple #3
0
        // -------------------------------------------------------------------------------
        // LoadFloor
        // -------------------------------------------------------------------------------
        public void LoadFloor()
        {
            interactables.Clear();

            if (currentDungeonConfig != null)
            {
                map = LoadDungeon(currentDungeonConfig);
            }

            if (map != null)
            {
                LoadMapConfig();
                ClearMap();

                for (int x = 0; x < map.Size.x; x++)
                {
                    for (int y = 0; y < map.Size.y; y++)
                    {
                        ScriptableTile tile = map.GetTile(x, y);

                        if (tile is DungeonTileStart)
                        {
                            startPos = new Vector3(x, Finder.navi.baseHeightOffset, y);
                            startDir = Vector3Helper.CardinalDirection(((DungeonTileStart)tile).facingDirection);
                            CreateDungeonFloor(x, y, false, ((DungeonTileStart)tile).floorPrefab);
                            CreateDungeonCeiling(x, y, ((DungeonTileStart)tile).ceilingPrefab);
                        }
                         else if (tile is DungeonTileWall)
                        {
                            CreateDungeonFloor(x, y, true, ((DungeonTileWall)tile).floorPrefab);
                            CreateDungeonWall(x, y, ((DungeonTileWall)tile));
                            CreateDungeonCeiling(x, y, ((DungeonTileWall)tile).ceilingPrefab);
                        }
                        else if (tile is DungeonTileFloor)
                        {
                            CreateDungeonFloor(x, y, true, ((DungeonTileFloor)tile).floorPrefab, (DungeonTileFloor)tile);
                            CreateDungeonCeiling(x, y, ((DungeonTileFloor)tile).ceilingPrefab, (DungeonTileFloor)tile);
                        }
                        else if (tile is DungeonTileEvent)
                        {
                            CreateDungeonObject(x, y, (DungeonTileEvent)tile);
                            CreateDungeonFloor(x, y, false, ((DungeonTileEvent)tile).floorPrefab);
                            CreateDungeonCeiling(x, y, ((DungeonTileEvent)tile).ceilingPrefab);
                        }
                    }
                }
            }
            else
            {
                throw new InvalidOperationException("tile map could not be loaded from map config!");
            }
        }
Exemple #4
0
        // -------------------------------------------------------------------------------
        // CreateDungeonObject
        // -------------------------------------------------------------------------------
        private void CreateDungeonObject(int x, int y, DungeonTileEvent tile)
        {
            if (tile != null)
            {
                GameObject instance = (GameObject)GameObject.Instantiate(tile.objectPrefab);

                if (Vector3Helper.CardinalDirection(tile.facingDirection) != Vector3.zero)
                {
                    instance.transform.forward = Vector3Helper.CardinalDirection(tile.facingDirection);
                }

                instance.transform.position = new Vector3(x, tile.offsetHeight, y);

                if (tile.facingDirection != DirectionType.None && !tile.interactFromBothSides)
                {
                    instance.transform.position -= instance.transform.forward / 3;
                }

                instance.transform.parent = MapContainer;
                instance.name             = string.Format("{0}_{1}", x, y);
                interactables.Add(new Interactable {
                    FacePlayer = tile.facePlayer, transform = instance.transform, ID = x.ToString() + y.ToString()
                });

                DungeonObjectEvent co = instance.GetComponent <DungeonObjectEvent>();

                co.tile = tile;

                co.Location = new Location {
                    template = currentDungeonConfig, X = x, Y = y
                };

                if (Finder.party.InteractedObjects.Any(i => i.Location.Equals(co.Location)))
                {
                    co.SetInteraction(true);
                }

                if (tile.StartsDeactivated || Finder.party.DeactivatedObjects.Any(i => i.Location.Equals(co.Location)))
                {
                    co.Deactivate();
                }
                else
                {
                    co.Activate();
                }
            }
            else
            {
                Debug.LogErrorFormat("Error: No tile defined at position: {0}, {1}", x, y);
            }
        }
Exemple #5
0
 // -------------------------------------------------------------------------------
 //
 // -------------------------------------------------------------------------------
 public void OnMoved()
 {
     Finder.audio.PlaySFX(SFX.Footstep);
     NormalizeTransform();
     Finder.map.UpdateInteractableDirection();
     Finder.party.MapExplorationInfo.AddExploredSpace(Finder.map.MapName, new Vector2(Finder.party.transform.position.x, Finder.party.transform.position.z));
     facingDirection = Vector3Helper.CardinalDirection(transform.forward);
     if (!Finder.battle.InBattle)
     {
         enabled = true;
     }
     changedDirection = false;
     OnPlayerMoved();
 }
Exemple #6
0
        // ===============================================================================
        // TELEPORT & MOVEMENT
        // ===============================================================================

        // -------------------------------------------------------------------------------
        // TeleportPlayer
        // -------------------------------------------------------------------------------
        public void TeleportPlayer(Location location)
        {
            if (location == null || location.locationType == LocationType.None)
            {
                return;
            }

            if (location.template == null)
            {
                location.template = location.targetMap;
            }

            Finder.ui.DeactivateAll();

            // -- Teleport to Worldmap
            if (location.locationType == LocationType.Worldmap)
            {
                WarpWorldmap();
                return;
            }

            // -- Teleport to Town
            if (location.locationType == LocationType.Town)
            {
                WarpTown((TemplateMetaTown)location.template);
                return;
            }

            // -- Teleport to Outro
            if (location.locationType == LocationType.Outro)
            {
                WarpOutro();
                return;
            }

            // -- Teleport to Dungeon
            if (location.locationType == LocationType.Dungeon)
            {
                WarpDungeon((TemplateMetaDungeon)location.template, false);

                Finder.party.transform.position = new Vector3(location.X, Finder.navi.baseHeightOffset, location.Y);

                if (Vector3Helper.CardinalDirection(location.facingDirection) != Vector3.zero)
                {
                    Finder.party.transform.forward = Vector3Helper.CardinalDirection(location.facingDirection);
                }

                Finder.navi.enabled = true;
            }
        }
Exemple #7
0
        // -------------------------------------------------------------------------------
        // CreateDungeonWall
        // -------------------------------------------------------------------------------
        private void CreateDungeonWall(int x, int y, DungeonTileWall tile)
        {
            if (tile.wallPrefab == null)
            {
                return;
            }

            GameObject go = GameObject.Instantiate(tile.wallPrefab) as GameObject;

            go.transform.position = new Vector3(x, Constants.BASEHEIGHT_WALL, y);
            go.name             = string.Format("{0}_{1}", x, y);
            go.transform.parent = MapContainer;

            if (tile != null)
            {
                if (tile.facingDirection != DirectionType.None)
                {
                    go.transform.forward = Vector3Helper.CardinalDirection(tile.facingDirection);
                }
            }
        }
Exemple #8
0
        // -------------------------------------------------------------------------------
        //
        // -------------------------------------------------------------------------------
        private IEnumerator UpdateMap()
        {
            yield return(new WaitForEndOfFrame());

            float scaledHeight = mapImage.rectTransform.GetHeight();

            mapRenderer.Scale(scaledHeight, Finder.map.map);
            mapRenderer.DrawFloor(Finder.party.MapExplorationInfo);

            if (Vector3Helper.CardinalDirection(Finder.party.transform.forward) == DirectionType.North)
            {
                mapRenderer.DrawOverlay(Finder.party.transform, Finder.map.minimapSprites.playerNorth);
            }
            else if (Vector3Helper.CardinalDirection(Finder.party.transform.forward) == DirectionType.East)
            {
                mapRenderer.DrawOverlay(Finder.party.transform, Finder.map.minimapSprites.playerEast);
            }
            else if (Vector3Helper.CardinalDirection(Finder.party.transform.forward) == DirectionType.South)
            {
                mapRenderer.DrawOverlay(Finder.party.transform, Finder.map.minimapSprites.playerSouth);
            }
            else if (Vector3Helper.CardinalDirection(Finder.party.transform.forward) == DirectionType.West)
            {
                mapRenderer.DrawOverlay(Finder.party.transform, Finder.map.minimapSprites.playerWest);
            }

            foreach (MapPing ping in Finder.party.MapExplorationInfo.ExploredAreas[Finder.map.MapName])
            {
                ping.loadTemplate();
                if (ping.template != null && ping.template.minimapIcon != null)
                {
                    mapRenderer.DrawOverlay(ping.Position, ping.template.minimapIcon);
                }
            }

            mapImage.sprite = Sprite.Create(mapRenderer.Texture, new Rect(0, 0, mapRenderer.Texture.width, mapRenderer.Texture.height), Vector2.zero);
        }
Exemple #9
0
        // ===============================================================================
        // DUNGEON OBJECT CREATION
        // ===============================================================================

        // -------------------------------------------------------------------------------
        // CreateDungeonFloor
        // -------------------------------------------------------------------------------
        private void CreateDungeonFloor(int x, int y, bool canStartFight, GameObject prefab, DungeonTileFloor tile = null)
        {
            if (prefab == null)
            {
                return;
            }

            GameObject go = GameObject.Instantiate(prefab) as GameObject;

            go.name = string.Format("{0}_{1}", x, y);
            go.transform.position = new Vector3(x, Constants.BASEHEIGHT_FLOOR, y);
            go.transform.parent   = MapContainer;

            if (tile != null)
            {
                if (tile.facingDirection != DirectionType.None)
                {
                    go.transform.forward = Vector3Helper.CardinalDirection(tile.facingDirection);
                }
            }

            if (tile != null && canStartFight)
            {
                if (tile.facingDirection != DirectionType.None)
                {
                    go.transform.forward = Vector3Helper.CardinalDirection(tile.facingDirection);
                }
                go.AddComponent <OpenFloorCollisionHandler>();
                OpenFloorCollisionHandler co = go.GetComponent <OpenFloorCollisionHandler>();
                co.encounterRateModifier = tile.encounterRateModifier;
                co.monsterPoolID         = tile.monsterPoolID;
                co.monsterAmountMin      = tile.monsterAmountMin;
                co.monsterAmountMax      = tile.monsterAmountMax;
                co.monsterAmountScale    = tile.monsterAmountScale;
            }
        }