public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
 {
     validPoints.Clear();
     foreach (Point2 dir in legalMoves)
     {
         Point2 checkPoint = origin + dir;
         if (!checkPointOutOfBounds(checkPoint))
         {
             Tile tileAtPoint = mapProperties.getTile(checkPoint);
             if (checkTileNeutral(tileAtPoint))
             {
                 validPoints.Add(checkPoint);
             }
             else
             {
                 while (checkTileOwned(tileAtPoint) && !checkTileContainsEntity(tileAtPoint))
                 {
                     validPoints.Add(checkPoint);
                     checkPoint += dir;
                     if (checkPointOutOfBounds(checkPoint))
                     {
                         break;
                     }
                     tileAtPoint = mapProperties.getTile(checkPoint);
                 }
             }
         }
     }
     return validPoints;
 }
 public override List<Point2> getAffectedTiles(Point2 origin, Point2 affectedTile, MapProperties mapProperties)
 {
     List<Point2> affectedTiles = new List<Point2>();
     affectedTiles.Add(origin);
     affectedTiles.Add(affectedTile);
     return affectedTiles;
 }
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            MapProperties mapProperties = mapPropertiesFactory.CreateMapProperties(width, height, seed, useRandomSeed,
                                                                                   randomFillPercent, smoothingIterationCount, squareSize);

            map = mapFactory.CreateMap(mapProperties);

            ProcessMap(map, wallThreshold, roomThreshold);

            // todo move to map factory
            int[,] borderedMap = new int[width + borderSize * 2, height + borderSize * 2];

            for (int i = 0; i < borderedMap.GetLength(0); i++)
            {
                for (int j = 0; j < borderedMap.GetLength(1); j++)
                {
                    if (i >= borderSize && i < width + borderSize && j >= borderSize && j < height + borderSize)
                    {
                        borderedMap[i, j] = map[i - borderSize, j - borderSize];
                    }
                    else
                    {
                        borderedMap[i, j] = 1;
                    }
                }
            }

            MeshGenerator meshGenerator = GetComponent <MeshGenerator>();
            meshGenerator.GenerateMesh(borderedMap, squareSize);
        }
    }
        void FindProperties(MaterialProperty[] props)
        {
            m_Tint        = FindProperty("_Tint", props);
            m_AlbedoMap   = new MapProperties("_MainTex", props);
            m_AlbedoColor = FindProperty("_AlbedoColor", props);
            m_AlbedoFade  = FindProperty("_MainTex_Fade", props);

            m_BumpScale = FindProperty("_BumpScale", props);
            m_BumpMap   = new MapProperties("_BumpMap", props);

            m_Smoothness    = FindProperty("_Smoothness", props);
            m_SmoothnessMap = new MapProperties("_SmoothnessMap", props);

            m_Metallic    = FindProperty("_Metallic", props);
            m_MetallicMap = new MapProperties("_MetallicMap", props);

            m_EmissionMode = FindProperty("_EmissionMode", props);
            m_Emission     = FindProperty("_Emission", props);
            m_EmissionMap  = new MapProperties("_EmissionMap", props);

            m_CutoutThreshold = FindProperty("_CutoutThreshold", props, false);
            if (m_CutoutThreshold != null)
            {
                m_CutoutMap = new MapProperties("_CutoutMap", props);
            }

            m_Alpha = FindProperty("_Alpha", props, false);
            if (m_Alpha != null)
            {
                m_AlphaMap = new MapProperties("_AlphaMap", props);
            }
        }
Exemple #5
0
    private void UpdateCameraParameters(Vector3 origin, float horizontalScale, float verticalScale)
    {
        GameObject mapProperties = GameObject.FindGameObjectWithTag(MapProperties.TAG);

        if (mapProperties == null)
        {
            mapProperties     = new GameObject("Map Properties");
            mapProperties.tag = MapProperties.TAG;
            mapProperties.AddComponent <MapProperties>();
        }

        MapProperties prop = mapProperties.GetComponent <MapProperties>() as MapProperties;

        prop.HorizontalScale = horizontalScale;
        prop.VerticalScale   = verticalScale;
        prop.Origin          = origin;

        //GameObject camera = GameObject.FindGameObjectWithTag("MainCamera") as GameObject;

        //if (camera)
        //{
        //    MapProperties prop = camera.GetComponent<MapProperties>() as MapProperties;
        //    prop.HorizontalScale = horizontalScale;
        //    prop.VerticalScale = verticalScale;
        //    prop.Origin = origin;
        //}
    }
 /// <summary>
 /// Copies the specified mapping.
 /// </summary>
 /// <param name="mapping">The mapping.</param>
 public void Copy(IMapping mapping)
 {
     if (mapping is null)
     {
         return;
     }
     foreach (var prop in mapping.IDProperties.Where(x => !IDProperties.Any(y => y.Name == x.Name)))
     {
         CopyProperty(prop);
     }
     foreach (var prop in mapping.ReferenceProperties.Where(x => !ReferenceProperties.Any(y => y.Name == x.Name)))
     {
         CopyProperty(prop);
     }
     foreach (var prop in mapping.MapProperties.Where(x => !MapProperties.Any(y => y.Name == x.Name)))
     {
         CopyProperty(prop);
     }
     foreach (var prop in mapping.ManyToManyProperties.Where(x => !ManyToManyProperties.Any(y => y.Name == x.Name)))
     {
         CopyProperty(prop);
     }
     foreach (var prop in mapping.ManyToOneProperties.Where(x => !ManyToOneProperties.Any(y => y.Name == x.Name)))
     {
         CopyProperty(prop);
     }
 }
Exemple #7
0
    // Called by the master client when the game begins
    void OnGameStart()
    {
        Inhibitor.onInhibitorDestroyed += OnInhibitorDestroyed;

        // Set health bar colours
        healthImage.color = GameUIHandler.Instance.enemyHealthColour;
        if (PhotonNetwork.player.GetTeam() == team)
        {
            healthImage.color = GameUIHandler.Instance.allyHealthColour;
        }

        // Health regen
        if (PhotonNetwork.isMasterClient)
        {
            StartCoroutine(RegenHealth());
        }

        // Map Properties
        mapProperties = MapManager.Instance.GetMapProperties();

        // Damage over time
        if (mapProperties.nexusDamagePerSec > 0)
        {
            if (PhotonNetwork.isMasterClient)
            {
                StartCoroutine(DamageOverTime());
            }
        }

        ready = true;
    }
    public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
    {
        validPoints.Clear();
        Point2 checkPoint;
        foreach (Point2 dir in legalMoves)
        {
            checkPoint = origin;
            for (int i = 0; i < attackRange; i++)
            {
                checkPoint += dir;
                if (checkPointOutOfBounds(checkPoint))
                {
                    break;
                }
                print(mapProperties);

                Tile tileAtPoint = mapProperties.getTile(checkPoint);
                if (checkTileContainsObstacle(tileAtPoint))
                {
                    break;
                }
                validPoints.Add(checkPoint);
            }
        }
        return validPoints;
    }
        private int CountSurroundingWalls(int column, int row, int[,] targetMap, MapProperties mapProperties)
        {
            int wallCount = 0;

            for (int neighbourColumn = column - 1; neighbourColumn <= column + 1; neighbourColumn++)
            {
                for (int neighbourRow = row - 1; neighbourRow <= row + 1; neighbourRow++)
                {
                    if (IsInsideBorder(neighbourColumn, mapProperties.Width) &&
                        IsInsideBorder(neighbourRow, mapProperties.Height))
                    {
                        if (neighbourColumn != column || neighbourRow != row)
                        {
                            wallCount += targetMap[neighbourColumn, neighbourRow];
                        }
                    }
                    else
                    {
                        wallCount += 1;
                    }
                }
            }

            return(wallCount);
        }
    public static List <MapProperties> GetMapData(string Type)
    {
        DBManager           ObjDBManager = new DBManager();
        List <SqlParameter> parm         = new List <SqlParameter>
        {
            new SqlParameter("@Type", Type)
        };

        DataTable dt = ObjDBManager.ExecuteDataTable("GetMapData", parm);

        List <MapProperties> list = new List <MapProperties>();


        for (int b = 0; b < dt.Rows.Count; b++)
        {
            MapProperties objMapProperties = new MapProperties();
            objMapProperties.Id        = dt.Rows[b]["Id"].ToString();
            objMapProperties.Name      = dt.Rows[b]["Name"].ToString();
            objMapProperties.Category  = dt.Rows[b]["Category"].ToString();
            objMapProperties.Latitude  = dt.Rows[b]["Latitude"].ToString();
            objMapProperties.Longitude = dt.Rows[b]["Longitude"].ToString();
            list.Add(objMapProperties);
        }
        return(list);
    }
Exemple #11
0
        /// <summary>
        /// Reinitilize child objet
        /// </summary>
        public void Blank()
        {
            TileCountPerSegment = 6;
            SegmentCountPerMap  = 64;
            TileLenght          = 42;
            MapProperties       = new MapProperties();
            DwTerrainSegment    = new KSegment[64, 64];

            for (int segmentY = 0; segmentY < SegmentCountPerMap; segmentY++)
            {
                for (int segmentX = 0; segmentX < SegmentCountPerMap; segmentX++)
                {
                    DwTerrainSegment[segmentX, segmentY] = new KSegment();
                    for (int titleY = 0; titleY < TileCountPerSegment; titleY++)
                    {
                        for (int titleX = 0; titleX < TileCountPerSegment; titleX++)
                        {
                            DwTerrainSegment[segmentX, segmentY].HsVector[titleX, titleY] = new KVertex();
                        }
                    }
                }
            }

            DwProps.Clear();
            DwGrass.Clear();
            DwVectorAttr.Clear();
            DwWater.Clear();
            DwGrassColony.Clear();
            DwEventArea.Clear();
        }
Exemple #12
0
 /// <summary>
 /// Determines whether the mapping contains a property.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <returns><c>true</c> if the mapping contains the specified property; otherwise, <c>false</c>.</returns>
 public bool ContainsProperty(string propertyName)
 {
     return(IDProperties.Any(x => x.Name == propertyName) ||
            ReferenceProperties.Any(x => x.Name == propertyName) ||
            MapProperties.Any(x => x.Name == propertyName) ||
            ManyToManyProperties.Any(x => x.Name == propertyName) ||
            ManyToOneProperties.Any(x => x.Name == propertyName));
 }
        public void TestSameNameDifferentType()
        {
            MapProperties map = new MapProperties();

            map.OnAssigning = OnAssigning;
            var xx = map.Map <ObjectMock, ObjectMock3>(Builder <ObjectMock> .CreateNew().Build(),
                                                       new ObjectMock3());
        }
        public void TestSourceIsObject()
        {
            MapProperties map = new MapProperties();

            map.OnAssigning = OnAssigning;
            var xx = map.Map <ObjectMock, ObjectMock>(Builder <ObjectMock> .CreateNew().Build(),
                                                      new ObjectMock());
        }
Exemple #15
0
 /// <summary>
 /// Copies the property.
 /// </summary>
 /// <param name="prop">The property.</param>
 public void CopyProperty(IMapProperty prop)
 {
     if (prop is null)
     {
         return;
     }
     MapProperties.Add(prop.Convert <TClassType>(this));
 }
        private int FillCell(int column, int row, Random random, MapProperties mapProperties)
        {
            var isPartOfVerticalBorder   = IsOnBorder(column, mapProperties.Width);
            var isPartOfHorizontalBorder = IsOnBorder(row, mapProperties.Height);

            var isPartOfBorder = isPartOfVerticalBorder || isPartOfHorizontalBorder;

            return(isPartOfBorder ? 1 : random.Next(0, 100) < mapProperties.RandomFillPercent ? 1 : 0);
        }
Exemple #17
0
    // Based on MapProperties config, will give a player XP at the start of the game
    void GiveStartingXP()
    {
        MapProperties properties = MapManager.Instance.GetMapProperties();

        while (champion.currentLevel < properties.startingLevel)
        {
            photonView.RPC("GiveXP", PhotonTargets.AllBuffered, 1, true);
        }
        photonView.RPC("Heal", PhotonTargets.AllBuffered, 999f); // resolves a bug where levelling up will reduce the health bar (as max health increases too)
    }
        public void GetAsParameter(MapProperties inputObject, object expectedResult)
        {
            var Result = TestObject.GetAsParameter(inputObject);

            Assert.Equal(DbType.Int64, Result.DatabaseType);
            Assert.Equal(ParameterDirection.Input, Result.Direction);
            Assert.Equal("MappedClass_ID_", Result.ID);
            Assert.Equal(expectedResult, Result.InternalValue);
            Assert.Equal("@", Result.ParameterStarter);
        }
 private int[,] SmoothMap(int[,] targetMap, MapProperties mapProperties)
 {
     int[,] previousIterationMap = targetMap;
     for (int i = 0; i < mapProperties.SmoothingIterationCount; i++)
     {
         int[,] smoothedMap   = SmoothMapOnce(previousIterationMap, mapProperties);
         previousIterationMap = smoothedMap;
     }
     return(previousIterationMap);
 }
Exemple #20
0
        void ParsePropertyElement()
        {
            if (currentParentElement == CCTileMapProperty.None)
            {
                CCLog.Log("CCTileMapInfo: ParsePropertyElement: Parent element is unsupported. Cannot add property named '{0}' with value '{1}'",
                          currentAttributeDict[PropertyElementName], currentAttributeDict[PropertyElementValue]);
            }
            else if (currentParentElement == CCTileMapProperty.Map)
            {
                // The parent element is the map
                string value = currentAttributeDict[PropertyElementValue];
                string key   = currentAttributeDict[PropertyElementName];
                MapProperties.Add(key, value);
            }
            else if (currentParentElement == CCTileMapProperty.Layer)
            {
                int             layersCount = Layers != null ? Layers.Count : 0;
                CCTileLayerInfo layer       = layersCount > 0 ? Layers[layersCount - 1] : null;

                string value = currentAttributeDict[PropertyElementValue];
                string key   = currentAttributeDict[PropertyElementName];
                // Add the property to the layer
                layer.Properties.Add(key, value);
            }
            else if (currentParentElement == CCTileMapProperty.ObjectGroup)
            {
                int objGroupsCount = ObjectGroups != null ? ObjectGroups.Count : 0;
                CCTileMapObjectGroup objectGroup = objGroupsCount > 0 ? ObjectGroups[objGroupsCount - 1] : null;
                string value = currentAttributeDict[PropertyElementValue];
                string key   = currentAttributeDict[PropertyElementName];
                objectGroup.Properties.Add(key, value);
            }
            else if (currentParentElement == CCTileMapProperty.Object)
            {
                // The parent element is the last object
                int objGroupsCount = ObjectGroups != null ? ObjectGroups.Count : 0;
                CCTileMapObjectGroup objectGroup = objGroupsCount > 0 ? ObjectGroups[objGroupsCount - 1] : null;

                List <Dictionary <string, string> > objects = objectGroup.Objects;
                int objCount = objects != null ? objects.Count : 0;
                Dictionary <string, string> dict = objCount > 0 ? objects[objCount - 1] : null;

                string propertyName  = currentAttributeDict[PropertyElementName];
                string propertyValue = currentAttributeDict[PropertyElementValue];
                dict.Add(propertyName, propertyValue);
            }
            else if (currentParentElement == CCTileMapProperty.Tile)
            {
                Dictionary <string, string> dict = TileProperties[ParentGID];

                string propertyName  = currentAttributeDict[PropertyElementName];
                string propertyValue = currentAttributeDict[PropertyElementValue];
                dict.Add(propertyName, propertyValue);
            }
        }
Exemple #21
0
 // Subscribe to delegates and assign references when the game starts.
 void Start()
 {
     GameHandler.onGameEnd += OnGameEnd;
     trueRot        = Quaternion.identity;
     photonView     = GetComponent <PhotonView>();
     navMeshAgent   = GetComponent <NavMeshAgent>();
     playerChampion = GetComponent <PlayerChampion>();
     defaultAttack  = GetComponent <DefaultAttack>();
     playerAnimator = GetComponent <PlayerAnimator>();
     champion       = playerChampion.Champion;
     mapProperties  = MapManager.Instance.GetMapProperties();
 }
Exemple #22
0
        /// <summary>
        /// Sets a property as a map type.
        /// </summary>
        /// <typeparam name="TDataType">The type of the data type.</typeparam>
        /// <param name="expression">Expression pointing to the property</param>
        /// <returns>The map object</returns>
        /// <exception cref="ArgumentNullException">expression</exception>
        public Map <TClassType, TDataType> Map <TDataType>(System.Linq.Expressions.Expression <Func <TClassType, TDataType> > expression)
            where TDataType : class
        {
            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            var ReturnValue = new Map <TClassType, TDataType>(expression, this);

            MapProperties.Add(ReturnValue);
            return(ReturnValue);
        }
 public override bool performAction(Point2 tilePoint, MapProperties mapProperties)
 {
     foreach (Point2 p in validPoints)
     {
         if (tilePoint == p)
         {
             List<Point2> affectedTiles = getAffectedTiles(getEntity().getCurrentTile().getLocation(), p, mapProperties);
             mapProperties.getTile(affectedTiles[0]).setEntity(null);
             mapProperties.getTile(affectedTiles[1]).setEntity(getEntity());
             return true;
         }
     }
     return false;
 }
Exemple #24
0
    // Set up initial variables when the game starts
    void Start()
    {
        lockedToPlayer = true;
        photonView     = target.GetComponent <PhotonView>();

        // Map Properties to determine whether this is third person or top-down
        mapProperties = MapManager.Instance.GetMapProperties();
        if (mapProperties.display == CameraDisplays.ThirdPerson)
        {
            transform.parent           = target;
            transform.localPosition    = new Vector3(0, 0, 0);
            transform.localEulerAngles = new Vector3(0, -90, 0);
        }
    }
Exemple #25
0
    static public void BuildMap(string mapName, float x, float y)
    {
        MapPath       = MapDataFolder + mapName;
        MapName       = mapName;
        mapProperties = MapPropertiesReader.GetMapProperties(MapPath);
        MapLayers     = mapProperties.Layers;
        MapViews      = mapProperties.Views;
        X             = x;
        Y             = y;

        CreateMapContainer();

        BuildMapViews();
        BuildMapLayers();
    }
    public override bool performAction(Point2 tilePoint, MapProperties mapProperties)
    {
        List<Point2> affectedTiles = getAffectedTiles(getEntity().getCurrentTile().getLocation(), tilePoint, mapProperties);
        foreach (Point2 p in affectedTiles)
        {
            Tile tileAtPoint = mapProperties.getTile(p);
            if (checkTileContainsEnemy(tileAtPoint))
            {
                tileAtPoint.getCurrentEntity().takeDamage();
            }
            tileAtPoint.setTileType(getEntity().entityType);

        }
        return true;
    }
Exemple #27
0
        /// <summary>
        ///		Initializes this instance and sets up the window and all its controls.
        /// </summary>
        public MapPropertiesWindow(MapProperties properties)
        {
            // Initializes all the controls on this window.
            InitializeComponent();

            // Retrieve the map properties from the editor window.
            _mapProperties = new MapProperties(properties);
            SyncProperties();

            // Create the navigation nodes and add them to the navigation tree.
            _nodes[0] = new System.Windows.Forms.TreeNode("General");
            _nodes[1] = new System.Windows.Forms.TreeNode("Debug");
            _nodes[2] = new System.Windows.Forms.TreeNode("Security");
            _nodes[3] = new System.Windows.Forms.TreeNode("Infomation");
            optionTreeView.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { _nodes[0], _nodes[1], _nodes[2], _nodes[3] });
        }
Exemple #28
0
    /*  General Code  */

    void Start()
    {
        PhotonView    = GetComponent <PhotonView>();
        mapProperties = MapManager.Instance.GetMapProperties();
        if (PhotonNetwork.player.IsLocal)
        {
            GetComponent <Entity>().team = PhotonView.owner.GetTeam();
            gameUIHandler = GameObject.Find("GameManager").GetComponent <GameUIHandler>();

            // Tell other players to rename this player's character to be the name of the champion
            gameObject.name = PhotonNetwork.player.CustomProperties["championName"].ToString();
            PhotonView.RPC("Rename", PhotonTargets.AllBuffered, PhotonNetwork.player.CustomProperties["championName"].ToString());
            usernameText.text = PhotonView.owner.NickName;

            // Create a new champion class for this player so that we can store their details
            Champion = ScriptableObject.CreateInstance <Champion>();
            Champion.Init(ChampionRoster.Instance.GetChampion(gameObject.name), PhotonNetwork.player.NickName);
            Champion.health = oldHealth = Champion.maxHealth;
            Champion.mana   = Champion.maxMana;

            // Update UI to show full health and mana, etc
            if (PhotonView.isMine)
            {
                // Hide username/healthbar if in third person
                if (mapProperties.display == PlayerCamera.CameraDisplays.ThirdPerson)
                {
                    canvas.SetActive(false);
                }

                Entity.onEntityDeath += OnEntityDeath;

                // Set up ability indicators and particle effects
                AbilityHandler.Instance.SetupAbilityIndicators(gameObject);
                EffectsHandler.Instance.SetupEffects(gameObject, PhotonView);

                gameUIHandler.UpdateAbilities(Champion);
                gameUIHandler.UpdateStats(Champion);
                gameUIHandler.SetCharacterIcon(Champion);
                Respawn();
                UIHandler.Instance.HideLobbyUI();
            }

            // Tell other players to update the health and mana bar of this player
            PhotonView.RPC("UpdatePlayerHealth", PhotonTargets.AllBuffered, new object[] { Champion.health, Champion.maxHealth });
            PhotonView.RPC("UpdatePlayerMana", PhotonTargets.AllBuffered, new object[] { Champion.mana, Champion.maxMana });
        }
    }
    private void Start()
    {
        this.cameraContainer = new GameObject("Camera Container");
        this.cameraContainer.transform.position = this.transform.position;
        this.transform.SetParent(this.cameraContainer.transform);

        // add GPS script
        this.gps = this.cameraContainer.AddComponent <GPS>();
        // get Map Properties: scale and origin...
        this.mapPropertiesGO = GameObject.FindGameObjectWithTag(MapProperties.TAG);
        this.mapProperties   = this.mapPropertiesGO.GetComponent <MapProperties>() as MapProperties;

        // set initial rotation
        this.cameraContainer.transform.rotation = Quaternion.Euler(90f, 0f, 0f);

        this.gyroscopeEnabled = this.EnableGyroscope();
    }
        public void TestChildExclude()
        {
            MapProperties map  = new MapProperties();
            var           mock = Builder <ObjectMock> .CreateNew().Build();

            mock.prop4            = new Mocks.ObjectMock2();
            mock.prop4.exludeProp = "ssss";
            var result = map.Map <ObjectMock, ObjectMock3>(mock,
                                                           new ObjectMock3(), new List <string> {
                "exludeProp"
            });

            if (!string.IsNullOrWhiteSpace(result.prop4.exludeProp))
            {
                Assert.Fail();
            }
        }
 public override List<Point2> getAffectedTiles(Point2 origin, Point2 effectedTile, MapProperties mapProperties)
 {
     Point2 checkPoint = origin;
     List<Point2> affectedTiles = new List<Point2>();
     foreach (Point2 p in legalMoves)
     {
         checkPoint = origin + p;
         if (!checkPointOutOfBounds(checkPoint))
         {
             Tile tileAtPoint = mapProperties.getTile(checkPoint);
             if (!checkTileContainsObstacle(tileAtPoint))
             {
                 affectedTiles.Add(checkPoint);
             }
         }
     }
     return affectedTiles;
 }
    public static MapProperties Load(string mapPath)
    {
        TextAsset xml = Resources.Load <TextAsset>(mapPath + "_properties");

        if (xml == null)
        {
            ErrorLogger.Log("Map Properties file not found: " + mapPath + "_properties.xml", "When referencing maps in your area xml file, make sure that same name exists in the map data directory");
        }
        XmlSerializer serializer = new XmlSerializer(typeof(MapProperties));

        StringReader reader = new StringReader(xml.text);

        MapProperties properties = serializer.Deserialize(reader) as MapProperties;

        reader.Close();

        return(properties);
    }
        private int[,] RandomFillMap(MapProperties mapProperties)
        {
            int width  = mapProperties.Width;
            int height = mapProperties.Height;

            string seed   = mapProperties.UseRandomSeed ? Stopwatch.GetTimestamp().ToString() : mapProperties.Seed;
            Random random = new Random(seed.GetHashCode());

            int[,] result = new int[width, height];
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    result[i, j] = FillCell(i, j, random, mapProperties);
                }
            }

            return(result);
        }
Exemple #34
0
    public void SaveMap(string mapName)
    {
        MapProperties save = mapProperties();

        BinaryFormatter bf = new BinaryFormatter();

        if (!File.Exists(Application.dataPath + "/Maps/" + mapName + ".igm"))
        {
            FileStream file = File.Create(Application.dataPath + "/Maps/" + mapName + ".igm");
            bf.Serialize(file, save);
            file.Close();

            Debug.Log("Game Saved");
        }
        else
        {
            Debug.Log("Warning! Did not save! Map name already exists!");
        }
    }
Exemple #35
0
    public void ClearGameObjects()
    {
        MapProperties            mapP = new MapProperties();
        Dictionary <string, int> keys = mapP.prefabKeys;

        foreach (GameObject go in UnityEngine.Object.FindObjectsOfType <GameObject>())
        {
            if (go.activeInHierarchy)
            {
                foreach (var item in keys)
                {
                    if (item.Key == go.tag)
                    {
                        UnityEngine.Object.Destroy(go);
                    }
                }
            }
        }
    }
Exemple #36
0
        /// <summary>
        /// Constructor, creates grid representation and transformations.
        /// </summary>
        /// <param name="mapResolution">Map resolution in meters per pixel</param>
        /// <param name="size">Map size in pixels</param>
        /// <param name="offset">Offset if meters</param>
        public GridMap(float mapResolution, Point size, Vector2 offset)
        {
            Properties = new MapProperties(mapResolution, size, offset);

            // Construct map array
            mapArray = new LogOddsCell[Dimensions.X * Dimensions.Y];
            for (int i = 0; i < mapArray.Length; ++i)
            {
                mapArray[i].Reset();
            }

            // Construct transformation matrix
            // TODO Not quite sure if offset is needed
            mapTworld = Matrix3x2.CreateScale(Properties.ScaleToMap) * Matrix3x2.CreateTranslation(Properties.Offset.X, Properties.Offset.Y);
            if (!Matrix3x2.Invert(mapTworld, out worldTmap))
            {
                throw new Exception("Map to world matrix is not invertible");
            }
        }
 public override List<Point2> getAffectedTiles(Point2 origin, Point2 effectedTile, MapProperties mapProperties)
 {
     List<Point2> affectedTiles = new List<Point2>();
     Point2 dir = effectedTile - origin;
     dir.normalizeValues();
     Point2 checkPoint = origin;
     for (int i = 0; i < attackRange; i++)
     {
         checkPoint += dir;
         if (checkPointOutOfBounds(checkPoint))
         {
             break;
         }
         Tile tileAtPoint = mapProperties.getTile(checkPoint);
         if (checkTileContainsObstacle(tileAtPoint))
         {
             break;
         }
         affectedTiles.Add(tileAtPoint.getLocation());
     }
     return affectedTiles;
 }
 public override void onActionClicked(MapProperties mapProperties)
 {
     throw new NotImplementedException();
 }
 public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
 {
     validPoints.Clear();
     return validPoints;
 }
        public void Attach( DependencyObject associatedObject )
        {
            if ( DesignMode.DesignModeEnabled )
            {
                return;
            }

            AssociatedObject = associatedObject;
            _map = (MapControl) associatedObject;
            _labelsOverlay = new Image();
            _labelsOverlay.ImageOpened += ( _, __ ) =>
            {
                Geopoint topLeft;
                _map.GetLocationFromOffset( new Point( 0, 0 ), out topLeft );
                MapControl.SetLocation( _labelsOverlay, topLeft );
                _labelsOverlay.Visibility = Visibility.Visible;
            };
            _map.Children.Add( _labelsOverlay );

            _map.Loaded += ( _, __ ) =>
            {
                _vm = (MainViewModel) _map.DataContext;

                OnFloorChanged( _vm.Properties.Floor );
                OnItemsChanged( _vm.SearchResults );

                _properties = _vm.Properties;

                _vm.Properties.ListenToProperty( x => x.Center, UpdateLabelsOverlay );
                _vm.Properties.ListenToProperty( x => x.Floor, UpdateLabelsOverlay );
                _vm.Properties.ListenToProperty( x => x.ZoomLevel, UpdateLabelsOverlay );
                UpdateLabelsOverlay();

                _vm.Properties.ListenToProperty( x => x.Floor, () => OnFloorChanged( _vm.Properties.Floor ) );
                _vm.ListenToProperty( x => x.SearchResults, () => OnItemsChanged( _vm.SearchResults ) );

                var buildingsDataSource = EpflTileSources.GetForBuildings( _vm.Properties );
                _map.TileSources.Add( new MapTileSource( buildingsDataSource ) );
            };

            // HACK: Force the map to always face North, so that buildings labels are shown properly.
            _map.HeadingChanged += ( _, __ ) => _map.Heading = 0;
        }
Exemple #41
0
 public abstract void onActionClicked(MapProperties mapProperties);
Exemple #42
0
 public abstract List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties);
Exemple #43
0
 public abstract List<Point2> getAffectedTiles(Point2 origin, Point2 effectedTile, MapProperties mapProperties);
Exemple #44
0
 public abstract bool performAction(Point2 tilePoint, MapProperties mapProperties);