Пример #1
0
    public void RpcUpdatePosition(int x, int y)
    {
        WaterHex new_tile = GameObject.Find(string.Format("Grid/{0},{1}", x, y)).GetComponent <WaterHex>();

        transform.SetParent(new_tile.transform, true);
        CurrentPosition = new_tile;
    }
Пример #2
0
    /// <summary>
    /// Server-side command to move ship along movement queue
    /// </summary>
    //[Command]
    public void CmdMoveShip()
    {
        Debug.Log(string.Format("{0} tiles in movement queue for {1}.", MovementQueue.Count, Name));

        if (MoveActionTaken || MovementQueue.Count <= 0)
        {
            return;
        }

        if (!HexGrid.MovementHex(CurrentPosition, 1).Contains(MovementQueue[0]))
        {
            ClearMovementQueue();
            return;
        }

        //transform.SetParent(MovementQueue[MovementQueue.Count - 1].transform, true);
        //CurrentPosition = MovementQueue[MovementQueue.Count - 1];

        WaterHex final = MovementQueue[MovementQueue.Count - 1];

        CmdUpdatePosition(final.HexCoord.Q, final.HexCoord.R);

        //RpcMoveShip(MovementQueue[MovementQueue.Count - 1].HexCoord.Q, MovementQueue[MovementQueue.Count - 1].HexCoord.R);

        //StopAllCoroutines();
        StartCoroutine(SmoothMove());

        MoveActionTaken = true;
    }
Пример #3
0
    public void CopyHexGridToMap()
    {
        LoadingScreenManager.Instance.SetMessage("Creating minimap...");
        LoadingScreenManager.Instance.SetProgress(40.0f);

        float camera_height = (HexGrid.Instance.GridHeight * HexGrid.Instance.HexWidth) * 0.5f / Mathf.Tan(Mathf.Deg2Rad * (GetComponent <Camera>().fieldOfView / 2.0f));

        GetComponent <Camera>().farClipPlane = camera_height + 100.0f;
        float swap;

        foreach (LandHex lh in HexGrid.Instance.LandTiles)
        {
            Vector3 current_local_pos = lh.transform.localPosition;
            swap = current_local_pos.y;
            current_local_pos = new Vector3(current_local_pos.x, current_local_pos.z, swap);

            LandHex new_hex = Instantiate(lh);
            new_hex.name = lh.name;
            new_hex.transform.SetParent(transform);
            new_hex.transform.localPosition = new Vector3(current_local_pos.x, current_local_pos.y, camera_height);
        }

        foreach (WaterHex wh in HexGrid.Instance.WaterTiles)
        {
            Vector3 current_local_pos = wh.transform.localPosition;
            swap = current_local_pos.y;
            current_local_pos = new Vector3(current_local_pos.x, current_local_pos.z, swap);

            WaterHex new_hex = Instantiate(wh);
            new_hex.name = wh.name;
            new_hex.transform.SetParent(transform);
            new_hex.transform.localPosition = new Vector3(current_local_pos.x, current_local_pos.y, camera_height);
        }
    }
Пример #4
0
    void OnTriggerExit(Collider other)
    {
        WaterHex water_hex = other.GetComponent <WaterHex>();

        if (water_hex && !water_hex.Fog)
        {
            water_hex.HideTile();
        }
    }
Пример #5
0
    /// <summary>
    /// Server-side command to add tile to movement queue
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    //[Command]
    public void CmdQueueMove(int x, int y)
    {
        WaterHex new_tile = GameObject.Find(string.Format("Grid/{0},{1}", x, y)).GetComponent <WaterHex>();

        if (new_tile)
        {
            MovementQueue.Add(new_tile);
        }
    }
Пример #6
0
    void OnTriggerStay(Collider other)
    {
        WaterHex water_hex = other.GetComponent <WaterHex>();
        LandHex  land_hex  = other.GetComponent <LandHex>();

        if (water_hex && water_hex.Fog)
        {
            water_hex.RevealTile();
        }

        if (land_hex && !land_hex.Discovered)
        {
            land_hex.DiscoverTile();
        }
    }