コード例 #1
0
ファイル: CharaEvent.cs プロジェクト: psywombats/7drl2019
    private OrthoDir DirectionRelativeToCamera()
    {
        MapCamera cam = Application.isPlaying ? Global.Instance().Maps.camera : FindObjectOfType <MapCamera>();

        Vector3 ourScreen   = cam.cam.WorldToScreenPoint(transform.position);
        Vector3 targetWorld = ((MapEvent3D)parent).TileToWorldCoords(parent.location + facing.XY());

        targetWorld.y = parent.transform.position.y;
        Vector3 targetScreen = cam.cam.WorldToScreenPoint(targetWorld);
        Vector3 delta        = targetScreen - ourScreen;

        return(OrthoDirExtensions.DirectionOf2D(new Vector2(delta.x, -delta.y)));
    }
コード例 #2
0
 public override OrthoDir DirectionTo(Vector2Int position)
 {
     return(OrthoDirExtensions.DirectionOf2D(position - this.Position));
 }