Example #1
0
        void Update()
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;

            if (Physics.Raycast(ray, out hitInfo))
            {
                var ourHitObject = hitInfo.collider.transform.parent.gameObject;

                if (ourHitObject.GetComponentInChildren <HexData>() != null)
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        selectedHex = ourHitObject.GetComponentInChildren <HexData>();
                    }
                    if (selectedHex != null && Input.GetMouseButtonDown(0))
                    {
                        MoveUnit(selectedHex);
                    }
                    if (Input.GetMouseButtonDown(1))
                    {
                        Debug.Log("Click!");
                        var neigh = mapData.GenerateNeighboursData(ourHitObject.name);
                        foreach (var n in neigh)
                        {
                            Debug.Log(n);
                        }
                    }
                }
            }
        }
Example #2
0
        private void LoadStuff(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            Stats.Current = Stats.LoadFromFile("statistics");
            worker.ReportProgress(20);

            Settings.Current = Settings.LoadFromFile("settings");
            worker.ReportProgress(40);

            HexData.LoadData(@"Resources\HexData");
            worker.ReportProgress(60);

            if (ClientManager.Connect())
            {
                ClientManager.Login();
                ClientManager.CompareVersion();
            }
            else
            {
                Notification.Show("Konnte nicht mit Server verbinden");
            }
            worker.ReportProgress(80);

            if (Stats.Current.FirstStart.Ticks == 0)
            {
                Stats.Current.FirstStart = DateTime.Now;
            }

            WindowState = Settings.Current.Fullscreen ? WindowState.Fullscreen : WindowState.Normal;

            worker.ReportProgress(100);
        }
    void TriangulateBoundaryTriangle(
        Vector3 begin, HexCell beginCell,
        Vector3 left, HexCell leftCell,
        Vector3 boundary, Color boundaryColor
        )
    {
        Vector3 v2 = HexData.AddRealismNoiseToBaseMesh(HexData.StepOffset(begin, left, 1));
        Color   c2 = HexData.StepOffset(beginCell.Colour, leftCell.Colour, 1);

        terrain.AddTriangleUnperturbed(HexData.AddRealismNoiseToBaseMesh(begin), v2, boundary);
        terrain.AddTriangleColor(beginCell.Colour, c2, boundaryColor);

        for (int i = 2; i < HexData.terraceSteps; i++)
        {
            Vector3 v1 = v2;
            Color   c1 = c2;
            v2 = HexData.AddRealismNoiseToBaseMesh(HexData.StepOffset(begin, left, i));
            c2 = HexData.StepOffset(beginCell.Colour, leftCell.Colour, i);
            terrain.AddTriangleUnperturbed(v1, v2, boundary);
            terrain.AddTriangleColor(c1, c2, boundaryColor);
        }

        terrain.AddTriangleUnperturbed(v2, HexData.AddRealismNoiseToBaseMesh(left), boundary);
        terrain.AddTriangleColor(c2, leftCell.Colour, boundaryColor);
    }
Example #4
0
 private void Awake()
 {
     HexData = new HexData(Game.GameConfig.hexSize);
     Chunks  = new Dictionary <Vector3, Chunk>();
     //Tiles = new Dictionary<Vector3, HexTile>();
     Generator = new WorldGenerator(Chunks);
 }
Example #5
0
    public void SetData(HexData data)
    {
        // Destroy existing entity.
        foreach (GameObject child in this.children)
        {
            Destroy(child);
        }
        this.children.Clear();

        this.entityType = data.entityType;
        this.entityData = data.entityData;

        switch (data.entityType)
        {
        case EntityType.Vacant:
            this.children.Add(Instantiate(PrefabBank.instance.greenHex, this.transform.position, Quaternion.identity));
            break;

        case EntityType.Obstacle:
            this.children.Add(Instantiate(PrefabBank.instance.redHex, this.transform.position, Quaternion.identity));
            break;

        case EntityType.Player:
            this.InstantiatePlayer(data.entityData);
            break;

        case EntityType.Item:
            this.InstantiateItem(data.entityData);
            break;
        }
    }
Example #6
0
 public CH34xSerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface) : base(device, connection)
 {
     hexData       = new HexData();
     rtsCtsEnabled = false;
     dtrDsrEnabled = false;
     mInterface    = device.GetInterface(iface >= 0 ? iface : 0);
 }
    void TriangulateCornerTerraces(
        Vector3 begin, HexCell beginCell,
        Vector3 left, HexCell leftCell,
        Vector3 right, HexCell rightCell
        )
    {
        Vector3 v3 = HexData.StepOffset(begin, left, 1);
        Vector3 v4 = HexData.StepOffset(begin, right, 1);
        Color   c3 = HexData.StepOffset(beginCell.Colour, leftCell.Colour, 1);
        Color   c4 = HexData.StepOffset(beginCell.Colour, rightCell.Colour, 1);

        terrain.AddTriangle(begin, v3, v4);
        terrain.AddTriangleColor(beginCell.Colour, c3, c4);

        for (int i = 2; i < HexData.terraceSteps; i++)
        {
            Vector3 v1 = v3;
            Vector3 v2 = v4;
            Color   c1 = c3;
            Color   c2 = c4;
            v3 = HexData.StepOffset(begin, left, i);
            v4 = HexData.StepOffset(begin, right, i);
            c3 = HexData.StepOffset(beginCell.Colour, leftCell.Colour, i);
            c4 = HexData.StepOffset(beginCell.Colour, rightCell.Colour, i);
            terrain.AddQuad(v1, v2, v3, v4);
            terrain.AddQuadColour(c1, c2, c3, c4);
        }

        terrain.AddQuad(v3, v4, left, right);
        terrain.AddQuadColour(c3, c4, leftCell.Colour, rightCell.Colour);
    }
    public void CreateHex(int h, int w, int matIndex, Vector3 pos = new Vector3())
    {
        float shift;
        if (IsOdd (h)){
            shift = rowShift;
        }
        else{
            shift = 0f;
        }
        var mat = hexGroup.hexes [matIndex].mat;

        hexGraph [h, w] = new HexData ();
        hexGraph [h, w].tile = Instantiate (hex) as GameObject;
        var tile = hexGraph[h, w].tile;
        tile.transform.parent = this.transform;
        //Debug.Log (pos);
        if (pos != new Vector3()) {
            tile.transform.position = pos;
        }
        else{
            tile.transform.position = new Vector3((w * 1.0f) + shift, 0f, (h * 0.87f));
        }
        tile.gameObject.GetComponent<MeshRenderer>().material = mat;
        //hexGraph[h, w].mat = mat;
        hexGraph[h, w].matIndex = matIndex;
        hexGraph[h, w].position = tile.transform.position;
        hexGraph[h, w].rotation = tile.transform.rotation;
    }
Example #9
0
    private StageData GenerateRandomStage(int seed)
    {
        Random.InitState(seed);
        int           stripCount     = Random.Range((this.minStrips - 1) / 2, (this.maxStrips - 1) / 2) * 2 + 1; // Should be odd?
        int           min            = Mathf.Max(this.minLongestStripLength, stripCount / 2 + 1);
        int           maxStripLength = Random.Range(min, this.maxLongestStripLength + 1);
        HoneycombData honey          = HoneycombData.Generate(stripCount, maxStripLength);

        // For each hex, give it random contents.
        foreach (StripData stripData in honey.strips)
        {
            foreach (HexData data in stripData.hexes)
            {
                this.RandomizeHex(data);
            }
        }

        // Pick a random starting location.
        // Do this last so it replaces whatever was at the hex's location.
        int     strip   = Random.Range(0, stripCount);
        int     hex     = Random.Range(0, honey.GetStripLength(strip));
        HexData hexData = honey.strips[strip].hexes[hex];

        hexData.entityType = EntityType.Player;
        hexData.entityData = HexData.PLAYER_DATA_HEAD;

        StageData stageData = new StageData();

        stageData.name             = "Random stage from seed " + seed;
        stageData.growthPerSegment = this.possibleGrowthPerSegment[Random.Range(0, this.possibleGrowthPerSegment.Length)];
        stageData.honeycomb        = honey;
        return(stageData);
    }
Example #10
0
    public void GenerateNew(List <TileData> tileDatas)
    {
        HexData hexData = new HexData(Game.instance.gameConfig.hexSize);

        tiles = new Dictionary <Vector3, Tile>();
        for (int r = -Game.instance.gameConfig.chunkSize / 2; r <= Game.instance.gameConfig.chunkSize / 2; r++)
        {
            for (int q = -Game.instance.gameConfig.chunkSize / 2; q <= Game.instance.gameConfig.chunkSize / 2; q++)
            {
                Vector3 pos = new Vector3(
                    r * hexData.Width() + q * (.5f * hexData.Width()),
                    0,
                    q * (hexData.Height() * .75f)
                    );
                GameObject tileGO = Instantiate(tilePrefab, transform);
                tileGO.transform.localPosition = pos;
                tileGO.transform.localScale    = tileGO.transform.localScale * hexData.Size();
                tileGO.name = "Tile (" + q + ", " + r + ")";
                Tile tile = tileGO.GetComponent <Tile>();
                tile.coords   = new Vector3(r, q, -r - q) + this.coords;
                tile.chunk    = this;
                tile.biome    = tileDatas[0].biome;
                tile.tileType = tileDatas[0].tileType;
                tileDatas.RemoveAt(0);
                tile.SetColor(new Color(0, .5f, 0, .5f));
                tiles.Add(new Vector3(r, q, -r - q), tile);
            }
        }
        hasGenerated = true;
    }
Example #11
0
    public Hex(int c, int r)
    {
        hexData        = new HexData();
        hexData.column = c;
        hexData.row    = r;
        hexData.sum    = -(c + r);

        hexData.terrain = Terrain.Plains;
    }
Example #12
0
    void HexInstantiation(GameObject Hex, float x, float y, int ID)
    {
        GameObject HexChild = Instantiate(Hex, new Vector3(x, y, 0), Quaternion.identity); //Create the hex given to it

        HexChild.transform.parent = HexParent.transform;                                   //Set the just-created hex as a child
        HexDataScript             = HexChild.GetComponent <HexData>();                     //Get the HexData script from the newly instantiated child
        HexDataScript.HexID       = ID;                                                    //Give it an ID
        HexChild.name             = ID.ToString();
    }
Example #13
0
        public void Parse183SessionProgress()
        {
            const string HexData =
                "5349502f322e30203138332053657373696f6e2050726f67726573730d0a416c6c6f773a20494e564954452c4259452c52454749535445522c41434b2c4f5054494f4e532c43414e43454c2c494e464f2c5355425343524942452c4e4f544946592c52454645522c5550444154450d0a43616c6c2d49443a2033646534363232302d343038622d343065302d386164612d3436393366616530386437394031302e302e352e32350d0a436f6e746163743a203c7369703a31353439394031302e302e382e34343a353036303e0d0a436f6e74656e742d547970653a206d756c7469706172742f6d697865643b626f756e646172793d756e697175652d626f756e646172792d310d0a435365713a203220494e564954450d0a46726f6d3a203c7369703a31313939323937313732314031302e302e352e32353a353036303b757365723d70686f6e653e0d0a526571756972653a2031303072656c0d0a525365713a20310d0a53657373696f6e2d49443a2030316538316263313366363434356262646130313161633866376431323564330d0a537570706f727465643a2074696d65722c7265706c616365730d0a546f3a203c7369703a31353439394031302e302e382e34343a353036303b757365723d70686f6e653e3b7461673d363833312d463133330d0a5669613a205349502f322e302f5544502031302e302e352e32353a353036303b72656365697665643d31302e302e352e32353b6272616e63683d7a39684734624b3766653864316366323864333831383631660d0a436f6e74656e742d4c656e6774683a203430380d0a0d0a2d2d756e697175652d626f756e646172792d310d0a436f6e74656e742d547970653a206170706c69636174696f6e2f7364700d0a0d0a763d300d0a6f3d2d2039203020494e204950342031302e302e382e34340d0a733d2d0d0a633d494e204950342031302e302e382e34340d0a743d3020300d0a6d3d617564696f203130303136205254502f4156502038203130310d0a613d7274706d61703a382050434d412f383030300d0a613d7274706d61703a3130312074656c6570686f6e652d6576656e742f383030300d0a613d666d74703a31303120302d31350d0a613d7074696d653a32340d0a613d73656e64726563760d0a0d0a2d2d756e697175652d626f756e646172792d310d0a436f6e74656e742d547970653a206170706c69636174696f6e2f495355503b76657273696f6e3d6974752d7439322b3b626173653d6e7876330d0a436f6e74656e742d446973706f736974696f6e3a207369676e616c3b68616e646c696e673d6f7074696f6e616c0d0a0d0a06120001290101000d0a2d2d756e697175652d626f756e646172792d312d2d0d0a";

            var binaryData = HexData.ToByteArray().ToArray();

            SipMessage.Parse(binaryData);
        }
Example #14
0
        void MoveUnit(HexData target)
        {
            var source = GameObject.Find("Hex_" + selectedUnit.GetComponent <MoveableUnit>().tileX + "_" + selectedUnit.GetComponent <MoveableUnit>().tileY);

            if (Input.GetMouseButtonDown(0))
            {
                movementControls.LoadPath(selectedUnit.GetComponent <MoveableUnit>().maxMoves, source.name, target.transform.parent.name);
            }
        }
        public PL2303SerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface) : base(device, connection)
        {
            hexData = new HexData();
            if (iface > 1)
            {
                throw new ArgumentException("Multi-interface PL2303 devices not supported!");
            }

            mInterface = device.GetInterface(iface >= 0 ? iface : 0);
        }
Example #16
0
    void Awake()
    {
        instance = this;

        gameConfig = JsonConvert.DeserializeObject <GameConfig>(File.ReadAllText(Directory.GetParent(Application.dataPath).FullName + "/Game/GameConfig.json").Replace(@"\", "/"));
        hexData    = new HexData(Game.instance.gameConfig.hexSize);
        world      = GameObject.Find("World").GetComponent <World>();

        ChunkManagement.OnChunksManaged += SpawnPlayer;
    }
Example #17
0
 private void RandomizeHex(HexData data)
 {
     if (Random.value < this.itemChance)
     {
         // Make item.
         data.entityType = EntityType.Item;
         if (Random.value < this.plusOneChance)
         {
             data.entityData = 1;
             return;
         }
         if (Random.value < this.thenPlusTwoChance)
         {
             data.entityData = 2;
             return;
         }
         if (Random.value < this.thenPlusThreeChance)
         {
             data.entityData = 3;
             return;
         }
         if (Random.value < this.thenPlusSixChance)
         {
             data.entityData = 6;
             return;
         }
         if (Random.value < this.thenMinusOneChance)
         {
             data.entityData = -1;
             return;
         }
         if (Random.value < this.thenMinusTwoChance)
         {
             data.entityData = -2;
             return;
         }
         if (Random.value < this.thenMinusThreeChance)
         {
             data.entityData = -3;
             return;
         }
         data.entityData = -6;
         return;
     }
     if (Random.value < this.thenObstacleChance)
     {
         // Make obstacle.
         data.entityType = EntityType.Obstacle;
         data.entityData = 0;
         return;
     }
     // Make vacant.
     data.entityType = EntityType.Vacant;
     data.entityData = HexData.VACANT_DATA;
 }
Example #18
0
    private void Awake()
    {
        instance = this;

        hexData = new HexData(Game.instance.gameConfig.hexSize);
        chunks  = new Dictionary <Vector3, Chunk>();

        hexCalc = new HexCalc();
        seed    = Random.Range(1, 1000000);
        simplex = new Simplex(seed);
    }
Example #19
0
 void Start()
 {
     if (!Game.instance.gameConfig.DEBUG)
     {
         Destroy(gameObject);
     }
     hexCalc  = new HexCalc();
     hexData  = new HexData(Game.instance.gameConfig.hexSize);
     textMesh = GetComponent <TextMesh>();
     tile     = GetComponentInParent <Tile>();
 }
    public void AddTriangle(Vector3 v1, Vector3 v2, Vector3 v3)
    {
        int vertexIndex = vertices.Count;

        vertices.Add(HexData.AddRealismNoiseToBaseMesh(v1));
        vertices.Add(HexData.AddRealismNoiseToBaseMesh(v2));
        vertices.Add(HexData.AddRealismNoiseToBaseMesh(v3));
        triangles.Add(vertexIndex);
        triangles.Add(vertexIndex + 1);
        triangles.Add(vertexIndex + 2);
    }
Example #21
0
    public static LevelData GenerateLevel(DataTypes.BiomeType biome)
    {
        LevelData levelData = new LevelData()
        {
            levelId          = -1,
            levelName        = "RandomLevel",
            biomeType        = biome,
            gridCellSize     = new Vector3(1.2f, 1, 1),
            gridCellPosition = Vector3.zero,
            pointMultiplier  = 1,
            isBossLevel      = false,
            movementType     = BossMovement.None
        };


        int childCount = (int)(55f / chanceOfSpawn);//UnityEngine.Random.Range(30, 12 * 26);

        Debug.Log("childCount" + childCount);
        for (int i = 0; i < childCount; i++)
        {
            if (UnityEngine.Random.value > chanceOfSpawn || Mathf.FloorToInt((float)i / (float)xRange) - 5 > 13)
            {
                continue;
            }

            hexType = getBiomeHexType(biome, 0.15f);//getRandomHexType();

            if (DataTypes.IsBiome(hexType))
            {
                health = Mathf.FloorToInt(UnityEngine.Random.Range(1, 4));
            }
            else if (hexType == DataTypes.HexType.Growth)
            {
                health = 3;
            }
            else
            {
                health = 1;
            }

            HexData hexData = new HexData()
            {
                hexType        = hexType,
                health         = health,
                points         = 50,
                hexScaleFactor = Vector3.one,
                cellLocation   = getCellLocation(i)
            };
            levelData.hexData.Add(hexData);
        }

        return(levelData);
    }
    public static EdgeVertices TerraceLerp(
        EdgeVertices a, EdgeVertices b, int step)
    {
        EdgeVertices result;

        result.v1 = HexData.StepOffset(a.v1, b.v1, step);
        result.v2 = HexData.StepOffset(a.v2, b.v2, step);
        result.v3 = HexData.StepOffset(a.v3, b.v3, step);
        result.v4 = HexData.StepOffset(a.v4, b.v4, step);
        result.v5 = HexData.StepOffset(a.v5, b.v5, step);
        return(result);
    }
Example #23
0
    public Vector2i?RegisterPawn(PawnControler pawnControler)
    {
        Vector2i gridCoordinate = HexagonUtils.ConvertOrthonormalToHexaSpace(pawnControler.transform.position);

        if (HexData.Contains(gridCoordinate))
        {
            HexData[gridCoordinate].LocalPawns.Add(pawnControler);
            return(gridCoordinate);
        }

        return(null);
    }
Example #24
0
 public void SetData(StripData data)
 {
     if (this.hexes.Count != data.hexes.Length)
     {
         Debug.LogError("Cannot set strip data: data has wrong number of hexes.");
         return;
     }
     for (int i = 0; i < this.hexes.Count; ++i)
     {
         HexData hexData = data.hexes[i];
         this.hexes[i].SetData(hexData);
     }
 }
    HexData copyHexData(HexData hexData)
    {
        HexData returnable = new HexData();

        returnable.hexType = hexData.hexType;
        returnable.health  = hexData.health;
        returnable.points  = hexData.points;

        returnable.hexScaleFactor = new Vector2(hexData.hexScaleFactor.x, hexData.hexScaleFactor.y);
        returnable.cellLocation   = new Vector3Int(hexData.cellLocation.x, hexData.cellLocation.y, hexData.cellLocation.z);

        return(returnable);
    }
Example #26
0
    public void LoadHexMap()
    {
        foreach (GameObject hex in hexGameObjects)
        {
            DestroyImmediate(hex);
        }

        string fullFilePath = Application.dataPath + "/Maps/" + "WarMap" + ".hexmap";

        if (!File.Exists(fullFilePath))
        {
            fullFilePath = Application.persistentDataPath + "/Maps/" + "WarMap" + ".hexmap";
        }

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.OpenRead(fullFilePath);

        MapData mapData = (MapData)bf.Deserialize(file);

        hexData        = new Hex[mapWidth, mapHeight];
        hexGameObjects = new GameObject[mapWidth, mapHeight];

        int widthStart = 0;

        for (int j = 0; j < mapHeight; ++j)
        {
            for (int i = widthStart; i < mapWidth + widthStart; ++i)
            {
                HexData loadedHex = mapData.hexData[i - widthStart, j];
                Hex     h         = new Hex(loadedHex.column, loadedHex.row);
                h.SetTerrain(mapData.hexData[i - widthStart, j].terrain);

                GameObject hex = Instantiate(HexPrefab, h.Position(), Quaternion.identity, this.transform);

                MeshRenderer mesh = hex.GetComponentInChildren <MeshRenderer>();
                mesh.material = HexMaterials[(int)loadedHex.terrain];

                hexData[i - widthStart, j]        = h;
                hexGameObjects[i - widthStart, j] = hex;
            }

            if (j % 2 != 0)
            {
                widthStart -= 1;
            }
        }

        file.Close();
    }
Example #27
0
        public static HexData SaveHexModel(HexModel hexModel)
        {
            HexData hexData = new HexData
            {
                Column   = hexModel.Column,
                Row      = hexModel.Row,
                TileData = new TileData(
                    new TileColorData(hexModel.TileColorModel.GetDrawingColor()),
                    new TileImageData(hexModel.TileImageModel.Id)),
                DegreExploration = hexModel.DegreExploration,
                Description      = hexModel.Description
            };

            return(hexData);
        }
Example #28
0
    private void MovePlayerSegmentOntoHex(Hex hex, bool isHead)
    {
        HexData data = this.currentData.strips[hex.stripNumber].hexes[hex.hexNumber];

        // Check if the hex has an item. If so, apply its effects.
        if (data.entityType == EntityType.Item)
        {
            this.currentData.player.totalGrowth     = System.Math.Max(0, this.currentData.player.totalGrowth + data.entityData);
            this.currentData.player.itemsCollected += 1;
        }

        // Turn the hex into a player hex.
        data.entityType = EntityType.Player;
        data.entityData = (isHead ? HexData.PLAYER_DATA_HEAD : HexData.PLAYER_DATA_BODY);
    }
Example #29
0
        public void DecodeHex()
        {
            string hex = HexData?.Trim();

            if (!string.IsNullOrWhiteSpace(hex))
            {
                hex = hex.Replace(" ", "").Replace("-", "").Replace("\r", "").Replace("\n", "");
                int len = hex.Length / 2;
                var tmp = new byte[len];
                for (int i = 0; i < len; i++)
                {
                    tmp[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
                }
                Data = tmp;
            }
        }
Example #30
0
    //Return true if entity is visible(enemy_visibility_range) to enemy based on enemies current x and z
    public bool canSeeHex(HexData hex)
    {
        Debug.Log(hex + " = hex | " + hex.x + " | " + hex.z);
            foreach(HexData h in hexManagerS.getAdjacentHexes(hex, sight_range)){
                if(h.x == hex.x && h.z == hex.z)
                {
                    //opponent is in sight range of enemy
                    Debug.Log ("canSeeHex: opponent is in sight range");
                    return true;
                }
                //Debug.Log ("...checking hex...");
            }

        //opponent isn't in sight range of enemy
        Debug.Log ("canSeeHex: opponent is not in sight range");
        return false;
    }
Example #31
0
    private void Turn(bool isClockwise)
    {
        List <int> orderedIndex = new List <int>();

        List <HexGUI> orderedSelectedHexGUIs = new List <HexGUI>();

        for (int a = 0; a < selectedCoordinates.Count; a++)
        {
            float x     = a == 0 ? int.MinValue : int.MaxValue;
            float y     = int.MaxValue;
            int   index = -1;

            for (int i = 0; i < selectedCoordinates.Count; i++)
            {
                if (orderedIndex.Contains(i))
                {
                    continue;
                }

                if ((a == 0 && selectedCoordinates[i].x > x || a > 0 && selectedCoordinates[i].x < x) || selectedCoordinates[i].x == x && selectedCoordinates[i].y < y)
                {
                    x     = selectedCoordinates[i].x;
                    y     = selectedCoordinates[i].y;
                    index = i;
                }
            }

            orderedIndex.Add(index);
        }

        for (int i = 0; i < orderedIndex.Count; i++)
        {
            orderedSelectedHexGUIs.Add(Utility.guiManager.mapGUI.getHex(selectedCoordinates[orderedIndex[i]]));
        }

        if (!isClockwise)
        {
            orderedSelectedHexGUIs.Reverse();
        }

        HexData thirdHexData = orderedSelectedHexGUIs[2].getHexData();

        orderedSelectedHexGUIs[2].ChangeHexa(orderedSelectedHexGUIs[1].getHexData());
        orderedSelectedHexGUIs[1].ChangeHexa(orderedSelectedHexGUIs[0].getHexData());
        orderedSelectedHexGUIs[0].ChangeHexa(thirdHexData);
    }
Example #32
0
    // Removes the player from the given hex. If the player's head is removed, a body segment will become their head.
    // Assumes the shrinkage is valid and the player has at least one other segment remaining.
    public void ShrinkPlayer(Hex hex)
    {
        this.PushUndoData();

        HexData hexData = this.currentData.strips[hex.stripNumber].hexes[hex.hexNumber];

        // Check if we are shrinking the head.
        if (hexData.entityType == EntityType.Player && hexData.entityData == HexData.PLAYER_DATA_HEAD)
        {
            // Make a body segment the new head.
            this.SetNewPlayerHead();
        }

        // Remove the player from the hex.
        this.RemovePlayerFromHexData(hexData);

        this.UpdateGameFromData();
    }
Example #33
0
    //Find path from start node to destination node
    //Distance function returns distance between two adjacent nodes
    //Estimate function returns distance between any node and destination node
    //Neighbors function returns adjacent traversible hexes for given hex input (Very hefty method)
    public static Path FindPath(HexData start,
		HexData destination, EntityE entity,
		Func<HexData, HexData, double> distance,
		Func<HexData, HexData, double> estimate,
		Func<HexData, HexData, EntityE, List<HexData>> neighbours)
    {
        //set of already checked HexData
           	 		var closed = new HashSet<HexData>();
            //queued HexData in open set
           			var queue = new PriorityQueue<double, Path>();
            //start by adding enemy's hex to queue
            queue.Enqueue(0, new Path (start));

           			while (!queue.IsEmpty)
            {
                //get first element on list
                var path = queue.Dequeue();
                //check to see if this element is in the set of already checked hexes, i.o the closed set
           			if (closed.Contains(path.ThisStep))
                    continue;
                //check to see if this element is our destination hex
                if (path.ThisStep.Equals(destination))
           			return path;  //return full path to destination

                //if element isn't the destination hex and isn't in closed set, add it to closed set
                closed.Add(path.ThisStep);

                //Go through neighbors (adjacent hexes) of current element
                foreach(HexData n in neighbours(path.ThisStep, destination, entity))
                {
                    //compute distance between current element and it's neighbor
                    double d = distance(path.ThisStep, n);
                    //New step added without modifying current path
                    var newPath = path.AddStep(n, d);
                    //add new path to queue
                    queue.Enqueue(newPath.TotalCost + estimate(n, destination), newPath);
                }
        }
        return null;
    }
Example #34
0
 public static void updateHexVisionState(HexData in_hex, Vision in_vision)
 {
     hexes[in_hex.x, in_hex.z].vision_state = in_vision;
 }
Example #35
0
    public static VectorLine outlineHex(HexData hex)
    {
        MeshFilter ms = (MeshFilter)hex.hex_object.GetComponent("MeshFilter");
        Vector3[] verts = new Vector3[(ms.mesh.vertices.Length + 1)];
        //		VectorLine
        for(int i = 0; i <  ms.mesh.vertices.Length; ++i)
            verts[i] = ms.mesh.vertices[i] + y_adj_hex + hex.hex_object.transform.position;

        verts[ms.mesh.vertices.Length] = ms.mesh.vertices[0] + y_adj_hex + hex.hex_object.transform.position;

        for(int i = 0; i < verts.Length; ++i)
            verts[i].y = 1;

        return new VectorLine("border", verts, null, 8F,LineType.Continuous, Joins.Weld);
        //		VectorLine.MakeLine("border", verts).Draw3DAuto();
    }
Example #36
0
    //True if enemy can can get to specified opponent
    bool canGetToOpponent(HexData enemy, HexData opponent, EntityE entity_opponent, bool knows_opponents_location, ref List<HexData> path_to_opp)
    {
        if(knows_opponents_location){
            //if enemy already "knows opponents location" then don't worry about visibility just get path to opponent
            Debug.Log ("canGetToOpponent: knows enemy location, get path:" + entity_opponent);
            path_to_opp = extractPath(hexManagerS.getTraversablePath(enemy, opponent, EntityE.Node, getTraverseAPCostPathVersion, getAdjacentTraversableHexes));

            if(path_to_opp.Count == 0){
                Debug.Log ("canGetToOpponent: knows enemy location, but can't find path");
                return false;
            }else{
                Debug.Log ("canGetToOpponent: knows enemy location, and found path");
                return true;
            }
        }
        else
        {
            Debug.Log ("canGetToOpponent: doesn't know enemy location, see if enemy is visible in sight range: " + entity_opponent);
            //TODO: TESTING****using old method*********
            if(canSeeHex(opponent)){
            //if(canSeeHex(opponent)){ ****
                Debug.Log ("canGetToOpponent: doesn't know enemy location, get path to " + entity_opponent);
                path_to_opp = extractPath(hexManagerS.getTraversablePath(enemy, opponent, EntityE.Node, getTraverseAPCostPathVersion, getAdjacentTraversableHexes));
                if(path_to_opp.Count == 0){
                    Debug.Log ("canGetToOpponent: enemy is visible, but can't find path");
                    return false;
                }else{
                    Debug.Log ("canGetToOpponent: enemy is visible, and found path");
                    return true;
                }
            }else{
                Debug.Log ("canGetToOpponent: doesn't know enemy location, and enemy not visible");
                return false;
            }
        }
    }
Example #37
0
 public Path getPathFromMechTo(HexData destination)
 {
     Debug.LogWarning("getPathFromMechTo");
     return hexManagerS.getTraversablePath(
                                             hexManagerS.getHex(x, z),
                                             hexManagerS.getHex(destination.x, destination.z),
                                             EntityE.Player,
                                             getTraverseAPCostPathVersion,
                                             getAdjacentTraversableHexesPathVersion);
 }
Example #38
0
    public bool makeMove(HexData hex)
    {
        if(!canTraverse(hex))
            throw new MissingComponentException("Can't move to this spot, invalid location!");

        //TODO add visual engine.move hooks

        //update players hex tags
        x = hex.x;
        z = hex.z;
        return true;
    }
Example #39
0
    //Return adjacent hexes for the given entity position
    public static HexData[] getAdjacentHexes(int x, int z)
    {
        //if we're out of bounds or if we're trying to get adjacency from a perimeter hex, return false
        if(x < 0 || x > x_max || z < 0 || z > z_max || getHex(x, z).hex_type == Hex.Perimeter)
        {
            throw new KeyNotFoundException("Accessing out of bounds!");
        }

        //ALWAYS BUILD THIS ARRAY "CLOCKWISE" STARTING AT NORTH
        HexData[] output = new HexData[6];

        //Get North						//Get Northeast
        output[0] = hexes[x, z +1];		output[1] = hexes[x+1, z];
        output[0].direction_from_central_hex = Facing.North;
        output[1].direction_from_central_hex = Facing.NorthEast;

        //Get Southeast                 //Get South
        output[2] = hexes[x+1, z-1];	output[3] = hexes[x, z-1];
        output[2].direction_from_central_hex = Facing.SouthEast;
        output[3].direction_from_central_hex = Facing.South;

        //Get Southwest					//Get Northwest
        output[4] = hexes[x-1, z];		output[5] = hexes[x-1, z+1];
        output[4].direction_from_central_hex = Facing.SouthWest;
        output[5].direction_from_central_hex = Facing.NorthWest;

        return output;
    }
Example #40
0
 public bool canTraverse(HexData hex)
 {
     return canTraverse(hex.x, hex.z);
 }
Example #41
0
    public void updateFoWState()
    {
        hex_data = hexManagerS.getHex(hex_data.x, hex_data.z);

        switch(hex_data.vision_state)
        {
            case Vision.Live:
            renderer.material.SetColor("_Color", Color.white);
                break;
            case Vision.Visited:
            renderer.material.SetColor("_Color", Color.gray);
                break;
            case Vision.Unvisted:
            renderer.material.SetColor("_Color", Color.black);
                break;
        }
    }
Example #42
0
    //Get path to base
    public static Path getTraversablePath(HexData start, HexData destination, EntityE ignore_entity, 
		Func<HexData, HexData, double> traversal_cost_func, 
		Func<HexData, HexData, EntityE, List<HexData>> neighbor_hex_func)
    {
        //Send hex of base and hex of enemy to aStar
        var path = aStar.FindPath(start, destination, ignore_entity, traversal_cost_func, calcCostToDestinationHex, neighbor_hex_func);
        //		if(path != null){
        //			last_path_cost = path.TotalCost;
        //			Debug.Log ("getTraversablePath: path cost = " + last_path_cost);
        //		}
        return path;
    }
Example #43
0
    public static HexData fillEntityData(HexData hex)
    {
        hex.added_occupier = EntityE.None;

        if(isEntityPos(hex, EntityE.Player))
            hex.added_occupier = EntityE.Player;

        else if(isEntityPos(hex, EntityE.Base))
            hex.added_occupier = EntityE.Base;

        else if(isEntityPos(hex, EntityE.Enemy))
            hex.added_occupier = EntityE.Enemy;

        else
            foreach(entityNodeS node in resource_node_list)
                if(hex.x == node.x && hex.z == node.z)
                {
                    hex.added_occupier = EntityE.Node;
                }
        return hex;
    }
Example #44
0
 //Same has other canTraversHex except check to see if the indicated hex can be moved onto without considering excluded entity into calculations
 //assumption is that if you send in "null" you will get to default case otherwise send it NODE
 public static bool canTraverseHex(HexData hex, EntityE exclude)
 {
     return canTraverseHex(hex.x, hex.z, exclude);
 }
Example #45
0
 //Check to see if the indicated hex can be moved onto, ie, its not occupied by an enemy, player, or base
 public static bool canTraverseHex(HexData hex)
 {
     return canTraverseHex(hex.x, hex.z);
 }
Example #46
0
 public static bool isEntityPos(HexData hex, EntityE entity)
 {
     return isEntityPos(hex.x, hex.z, entity);
 }
Example #47
0
 public static Combatable getCombatableAt(HexData hex)
 {
     return getCombatableAt(hex.x, hex.z);
 }
Example #48
0
    public static void setRoute(PathDisplay in_path, string _display_text, HexData _display_text_at)
    {
        display_text_at = _display_text_at;
        display_text = _display_text;

        if(current_path_display != null)
        {
            if(!current_path_display.Equals(in_path))
            {
                current_path_display.hidePath();
                current_path_display.destroySelf();
            }
        }
        current_path_display = in_path;

        if(current_path_display != null)
        {
            current_path_display.displayPath();
        }
    }
    public HexData[,] ResizeMD(HexData[,] hD, int h, int w)
    {
        HexData[,] newHexGraph = new HexData[h, w];
        //Debug.Log ("New Size: " + newHexGraph.GetLength (0) + ", " + newHexGraph.GetLength (1)+"\nOld Size: "+hexGraph.GetLength(0)+", "+hexGraph.GetLength(1));

        int hG0 = hD.GetLength (0);
        int hG1 = hD.GetLength (1);
        int nHG0 = newHexGraph.GetLength (0);
        int nHG1 = newHexGraph.GetLength (1);
        int iLength = Math.Max (hG0, nHG0);
        int kLength = Math.Max (hG1, nHG1);

        for (int i = 0; i < iLength; i++) {
            for (int k = 0; k < kLength; k++){
                //Debug.Log (i+"  :  "+k);
                if(i < hG0 && i < nHG0 && k < hG1 && k < nHG1){
                    newHexGraph[i, k] = hD[i, k];
                    //Debug.Log ("Keep: "+i+":"+k+" : ");//+newHexGraph[i, k].tile.name);//.mat);
                }
                else{
                    if(i < hG0 && k < hG1){
                        //Debug.Log ("Destroy: "+i+":"+k+" : "+hD[i,k].tile.name);
                        Destroy (hD[i, k].tile);
                    }
                }
            }
        }
        //Debug.Log (newHexGraph.GetLength (0) + "  " + newHexGraph.GetLength (1));
        return hD = newHexGraph;
    }
Example #50
0
    public static bool LoadFromString(string level_data)
    {
        string[] level_lines = level_data.Split(new string[] {"\n","\r\n"},StringSplitOptions.None);
        int index = 0;

        //INITIALIZE FILE TO READ\
        //		StreamReader reader;
        //		FileInfo filer = new FileInfo(Application.dataPath + "/Level_Files/" + level_name + ".pcl");
        //		if(filer != null && filer.Exists)
        //		{
        //		   reader = filer.OpenText();  // returns StreamReader
        //		}
        //		else
        //		{
        //			print ("FILE DOES NOT EXIST!");
        //			return false;
        //		}

        //BEGIN PARSING DATA
        //PARSE HEADER INFO
        print ("DEBUG " + level_lines[index]);
        if(!level_lines[index++].Equals("LEVEL{"))
        {
            print("l1 ILL FORMATED!");
            return false;
        }
        if(getIntR(level_lines[index++]) != level_editor_format_version) //EDITOR VER
        {
            print ("EDITOR VERSION MISMATCH!");
            return false;
        }
        hexManagerS.level_name   = getStringR(level_lines[index++]); //NAME
        int version    		= getIntR(level_lines[index++]);    //VERSION

        int total_count, game_count, border_count;
        hexManagerS.x_max = getIntR(level_lines[index++]);
        hexManagerS.z_max = getIntR(level_lines[index++]);

        int load_x_min = getIntR(level_lines[index++]);
        int load_x_max = getIntR(level_lines[index++]);

        int load_z_min = getIntR(level_lines[index++]);
        int load_z_max = getIntR(level_lines[index++]);

        hexManagerS.hexes = new HexData[hexManagerS.x_max, hexManagerS.z_max];

        --hexManagerS.x_max;
        --hexManagerS.z_max;

        total_count 	= getIntR(level_lines[index++]);  		//total count
        game_count 		= getIntR(level_lines[index++]);		//game count
        border_count 	= getIntR(level_lines[index++]);  		//border count

        //BEGIN PARSING hexManagerS.hexes
        if(!level_lines[index++].Contains("HEXES{"))
        {
            print("hexManagerS.hexes ILL FORMATED");
            return false;
        }
        while(getHexR(level_lines[index++])) //next line is a HEX{
        {
            int x = getIntR(level_lines[index++]) - load_x_min;
            int z = getIntR(level_lines[index++]) - load_z_min;

            Vector3 pos = hexManagerS.CoordsGameTo3D(x,z);
            GameObject new_hex = (GameObject) Instantiate(hexManagerS.hex_display, pos, Quaternion.identity);
            engineHexS new_hex_script = (engineHexS) new_hex.GetComponent("engineHexS");

        //			print ("making hex: " + x + ", " + z);
            Hex hex_type = (Hex) Enum.Parse(typeof(Hex), getStringR(level_lines[index++]));
            HexData new_hex_data = new HexData(x, z, hex_type, new_hex, new_hex_script, Vision.Unvisted);
            new_hex_script.assignHexData_IO_LOADER_ONLY(new_hex_data);
            new_hex_script.SetVisiual();

            hexManagerS.hexes[x, z] = new_hex_data;

            new_hex_script.updateFoWState();

            if(pos.x < enginePlayerS.camera_min_x_pos)
                enginePlayerS.camera_min_x_pos = pos.x;
            if(pos.x > enginePlayerS.camera_max_x_pos)
                enginePlayerS.camera_max_x_pos = pos.x;

            if(pos.z > enginePlayerS.camera_max_z_pos)
                enginePlayerS.camera_max_z_pos = pos.z;

            if(pos.z < enginePlayerS.camera_min_z_pos)
                enginePlayerS.camera_min_z_pos = pos.z;

            if(!getCBR(level_lines[index++]))
            {
                print("MALFORMED HEX!");
                return false;
            }
        }

        //		print (reader.ReadLine());
        //BEGIN PARSING ENTITES
        if(!level_lines[index++].Contains("ENTITIES{"))
        {
            print("ENTITIES ILL FORMATED");
            return false;
        }
        while(getEntR(level_lines[index++])) //next line is a HEX{
        {
            int x = getIntR(level_lines[index++]) - load_x_min;
            int z = getIntR(level_lines[index++]) - load_z_min;
            EntityE ent_type = (EntityE) Enum.Parse(typeof(EntityE), getStringR(level_lines[index++]));
            print (ent_type);
            if(ent_type == EntityE.Player)
            {
        //				print ("MOVING CAMERA ONTO PLAYER!");
                GameObject maincam = GameObject.FindGameObjectWithTag("MainCamera");
                maincam.transform.position = new Vector3(hexManagerS.CoordsGameTo3D(x,z).x, 60, hexManagerS.CoordsGameTo3D(x,z).z);
            }
            switch(ent_type)
            {
                case EntityE.Base:
        //				print("base case");
                    int base_starting_health_percentage = getIntR(level_lines[index++]);
                    if(!entityManagerS.instantiateBase(x, z, base_starting_health_percentage))
                        throw new System.Exception("There is already one base, cannot have two! D: Go edit the level file you're loading to only have one!");
                    break;

                case EntityE.Player:
        //				print("player case");
                    int mech_starting_health_percentage = getIntR(level_lines[index++]);
                    if(!entityManagerS.instantiatePlayer(x, z, mech_starting_health_percentage))
                        throw new System.Exception("There is already one player mech, cannot have two! D: Go edit the level file you're loading to only have one!");

        //					hexManagerS.getAdjacentHexes(entityManagerS.getBase().sentityManagerS.getBase().sight_range)updateFoWState()
                    break;

                case EntityE.Enemy:
        //				print("enemy case");
                    bool enemy_knows_base_loc = getBoolR(level_lines[index++]);
                    bool enemy_knows_mech_loc = getBoolR(level_lines[index++]);
                    if(!entityManagerS.instantiateEnemy(x, z, enemy_knows_base_loc, enemy_knows_mech_loc))
                        throw new System.Exception("Issue adding enemy!");
                    break;

                case EntityE.Node:
        //					print("node case");
                    Node node_type                = getNodeR(level_lines[index++]);
                    NodeLevel node_starting_level = getNodeLevelR(level_lines[index++]);
                    entityManagerS.instantiateResourceNode(x, z, node_type, node_starting_level);
                    break;
            }

            if(!getCBR(level_lines[index++]))
            {
                print("MALFORMED HEX!");
                return false;
            }

                    enginePlayerS.setMech();
        }
        //
        //		Component[] meshFilters = GetComponentsInChildren<MeshFilter>();
        //        CombineInstance[] combine = new CombineInstance[meshFilters.length];
        //        int i = 0;
        //        while (i < meshFilters.length) {
        //            combine[i].mesh = meshFilters[i].sharedMesh;
        //            combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
        //            meshFilters[i].gameObject.active = false;
        //            i++;
        //        }
        //        transform.GetComponent<MeshFilter>().mesh = new Mesh();
        //        transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
        //        transform.gameObject.active = true;

        hexManagerS.setNodePresenseOnHexes();
        return true;
    }
Example #51
0
    void OnMouseOver()
    {
        if(hex_data.vision_state != Vision.Unvisted)
        {

            draw_mode = true;

            if(!border.active)
                border.active = true;
            if(!glow.active)
                glow.active = true;

            border.SetColor(enginePlayerS.select_color);
            border.Draw3DAuto();
            glow.Draw3DAuto();

            HexData mech_hex = hexManagerS.getHex(entityManagerS.getMech().x, entityManagerS.getMech().z);

            //if mech standing on this hex
            if(mech_hex.Equals(hex_data))
            {

                //if the mech is on this hex, and this hex has a node as well
                if(node_occupier)
                {
        //					Debug.LogWarning("STANDING ON HEX WITH NODE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                    genTextString(SelectLevel.Scavenge, entityManagerS.getMech().getScavengeAPCost());

                    if(entityManagerS.getMech().current_ap > entityManagerS.getMech().getScavengeAPCost() && node_data.node_level != NodeLevel.Empty)
                        border.SetColor(enginePlayerS.scavenge_color);
                    else
                    {
                        genTextString(SelectLevel.Scavenge, -999);
                        border.SetColor(enginePlayerS.disable_color);
                    }
                    enginePlayerS.setRoute(null, display_text, hex_data);
                    return;
                }
                enginePlayerS.setRoute(null, "", hex_data);

                return;
            }

        //			if()

            //if the path is no longer starting from where the player mechu currently is...
            if(!mech_location_when_path_made.Equals(mech_hex) || path_display == null || path_display.path_line == null)
            {
                if(path_display != null)
                    path_display.destroySelf();

                path_from_mech = entityManagerS.getMech().getPathFromMechTo(hexManagerS.getHex (hex_data.x, hex_data.z));
                path_display = pathDrawS.getPathLine(path_from_mech);
                mech_location_when_path_made = mech_hex;
            }

            //if the mech could possibly walk here
            if(path_display != null && entityManagerS.getMech().canTraverse(hex_data))
            {
                genTextString(SelectLevel.Travel, (int) path_from_mech.TotalCost);
                enginePlayerS.setRoute(path_display, display_text, hex_data);
            }
            else
            {
                genTextString(SelectLevel.Disabled, -1);
                enginePlayerS.setRoute(null, display_text, hex_data);
            }
        }
    }
Example #52
0
    public List<HexData> getAdjacentTraversableHexesPathVersion(HexData hex, HexData destination, EntityE entity)
    {
        List<HexData> result_hexes = new List<HexData>(); //hold resulting hexes

        //Get adjacent tiles around player mech
        HexData[] adjacent_hexes = hexManagerS.getAdjacentHexes(hex.x, hex.z);
        //Debug.Log(adjacent_hexes.Length + " found adjacent");

        //See which of the adjacent hexes are traversable
        for(int i = 0; i < adjacent_hexes.Length; i++){
            if(entityManagerS.isEntityPos(adjacent_hexes[i], entity) || (canTraverse(adjacent_hexes[i]) && adjacent_hexes[i].vision_state != Vision.Unvisted))
            {
                //add hex to traversable array
                result_hexes.Add(adjacent_hexes[i]);
            }
        }

        //Debug.Log ("Number of result_hexes " + result_hexes.Count);
        return result_hexes;

        //		return getAdjacentTraversableHexes();
    }
Example #53
0
    public bool makeMove(HexData hex)
    {
        facing_direction = hex.direction_from_central_hex;
        if(!canTraverse(hex))
            throw new MissingComponentException("Can't move to this spot, invalid location!");

        //subtract ap cost from total
        current_ap -= getTraverseAPCost(hex.hex_type);

        //update enemy hex tags
        moveInWorld(hex.x, hex.z, 2F);
        x = hex.x;
        z = hex.z;
        return true;
    }
Example #54
0
 public double getTraverseAPCostPathVersion(HexData hex_start, HexData hex_end)
 {
     return (double) getTraverseAPCost(hex_end.hex_type);
 }
Example #55
0
    public static List<HexData> getAdjacentHexes(HexData center, int sight_range)
    {
        List<HexData> hexes_in_range = new List<HexData>();

        //get the hex standing on
        HexData current_hex = center;
        hexes_in_range.Add(current_hex);

        //enter loop for surrounding hexes
        for(int ring = 1; ring <= sight_range; ring++)
        {

            //draw the first "northeast" edge hex
            current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.NorthEast);
            hexes_in_range.Add(current_hex);

            //draw the "northeast" portion
            for(int edge_hexes_drawn = 1; edge_hexes_drawn < ring; ++edge_hexes_drawn)
            {
                current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.SouthEast);// = AddHexSE(overwrite, border_mode, clicked_hex_type, brush_size, current_hex.transform.position, draw_hex_type, xcrd(current_hex), zcrd(current_hex));
                hexes_in_range.Add(current_hex);
            }

            //draw the "southeast" portion
            for(int edge_hexes_drawn = 0; edge_hexes_drawn < ring; ++edge_hexes_drawn)
            {
                current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.South);
                hexes_in_range.Add(current_hex);
            }

            //draw the "south" portion
            for(int edge_hexes_drawn = 0; edge_hexes_drawn < ring; ++edge_hexes_drawn)
            {
                current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.SouthWest);
                hexes_in_range.Add(current_hex);
            }

            //draw the "southwest" portion
            for(int edge_hexes_drawn = 0; edge_hexes_drawn < ring; ++edge_hexes_drawn)
            {
                current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.NorthWest);
                hexes_in_range.Add(current_hex);
            }

            //draw the "northwest" portion
            for(int edge_hexes_drawn = 0; edge_hexes_drawn < ring; ++edge_hexes_drawn)
            {
                current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.North);
                hexes_in_range.Add(current_hex);
            }

            //draw the "north" portion
            for(int edge_hexes_drawn = 0; edge_hexes_drawn < ring; ++edge_hexes_drawn)
            {
                current_hex = hexManagerS.getHex(current_hex.x, current_hex.z, Facing.NorthEast);
                hexes_in_range.Add(current_hex);
            }
        }

        Debug.LogWarning("hexes_in_range size = " + hexes_in_range.Count);
        return hexes_in_range;
    }
Example #56
0
 public void moveToHex(HexData location, bool _standing_on_top_of_node)
 {
     current_ap -= location.traversal_cost;
     setLocation(location.x, location.z);
     moveInWorld(location.x, location.z, 6F);
     setFacingDirection(location.direction_from_central_hex);
     updateFoWStates();
     is_standing_on_node = _standing_on_top_of_node;
 }
Example #57
0
 //Get path to base
 //    public static Path getTraversablePathAsListRemoveFrontBack (HexData start, HexData destination, EntityE ignore_entity,
 //        Func<HexData, HexData, double> traversal_cost_func,
 ////		Func<HexData, HexData, double> destination_cost_estimate_func,
 //        Func<HexData, HexData, EntityE, List<HexData>> neighbor_hex_func)
 //    {
 //        //Send hex of base and hex of enemy to aStar
 //        var path = aStar.FindPath(start, destination, ignore_entity, traversal_cost_func, calcEstimate, neighbor_hex_func);
 //    }
 //    #region IPathFind implementation
 public static double calcCostToDestinationHex(HexData hex_start, HexData hex_end)
 {
     //TODO: may need to be adjusted later
     return Math.Abs(hex_start.x - hex_end.x) + Math.Abs(hex_start.z - hex_end.z);
 }
Example #58
0
 public void assignHexData_IO_LOADER_ONLY(HexData _hex_data)
 {
     hex_data = _hex_data;
 }
Example #59
0
 //alternative can traverse methods where an entity can be excluded from search
 public bool canTraverse(HexData hex, EntityE entity)
 {
     return canTraverse(hex.x, hex.z, entity);
 }