// -------------------------------------------------------------------------------
 // loadTemplate
 // -------------------------------------------------------------------------------
 public void loadTemplate()
 {
     if (string.IsNullOrEmpty(name))
     {
         return;
     }
     template = (DungeonTileEvent)DictionaryTile.Get(name);
 }
 // -------------------------------------------------------------------------------
 // MapPing
 // -------------------------------------------------------------------------------
 public MapPing(Vector2 position, DungeonTileEvent tmpl)
 {
     Position = position;
     if (tmpl != null)
     {
         template = tmpl;
         name     = tmpl.name;
     }
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        // -------------------------------------------------------------------------------
        // AddMapPing
        // -------------------------------------------------------------------------------
        public void AddMapPing(string mapName, Vector2 pos, DungeonTileEvent tile)
        {
            pos = pos.Round(0);
            List <MapPing> floorData = this.GetFloorData(mapName);
            MapPing        info      = floorData.FirstOrDefault(x => x.Position.x == pos.x && x.Position.y == pos.y);

            if (info != null)
            {
                if (info.template == tile)
                {
                    return;
                }
                floorData.Remove(info);
            }

            floorData.Add(new MapPing(pos, tile));
        }