예제 #1
0
 //will be filled in once the needs of placing terrain are better understood
 private void TerrainPass()
 {
     foreach (HexCell h in toBuild)
     {
         ITerrain iT = (ITerrain)h.Unit; // references to that units ITerrain implementation
         iT.SetTiles();                  // changes the tilles the terrain is covering to not passable
         iT.SetPosition();               // places the terrain at the proper location
         iT.SetCollider();               // turns on ther collider(s) and sets any other rigidbody data that needs to be changed
         h.Unit.transform.rotation = h.Unit.URotation();
     }
 }
예제 #2
0
    private void ClickHex() // checks if a valid hex was clicked
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        HexCell h;

        if (Physics.Raycast(ray, out rayHit))
        {
            h = rayHit.transform.gameObject.GetComponent <HexCell>();
            if (h != null) // it might be tempting to put this and the nested if statment together with an &&, but that'll throw an error if h is null when it check h.Unit
            {
                if (h.Unit == null && h.Passable)
                {
                    //code to place current terrain object.
                    Unit u = MapMaster.MakeTerrain(terrainArray[(int)currTerrain]);
                    u.CurrentHex = h;
                    h.Unit       = u;
                    ITerrain uIT = u.GetComponent <ITerrain>();
                    uIT.SetTiles();
                    uIT.SetPosition();
                    uIT.SetCollider();
                }
            }
        }
    }