Exemplo n.º 1
0
    public IEnumerator PathToRoutine(IntVector2 location)
    {
        List <IntVector2> path = Parent.FindPath(this, location);

        if (path == null)
        {
            yield break;
        }
        foreach (IntVector2 target in path)
        {
            yield return(StartCoroutine(StepRoutine(OrthoDirExtensions.DirectionOf(target - GetComponent <MapEvent>().Position))));
        }
    }
Exemplo n.º 2
0
    private OrthoDir CalculateDirection()
    {
        OrthoDir  normalDir = Parent().GetComponent <CharaEvent>().facing;
        MapCamera cam       = Application.isPlaying ? Global.Instance().Maps.Camera : FindObjectOfType <MapCamera>();

        if (!cam || !dynamicFacing)
        {
            return(normalDir);
        }

        Vector3 ourScreen    = cam.GetCameraComponent().WorldToScreenPoint(parentEvent.transform.position);
        Vector3 targetWorld  = MapEvent3D.TileToWorldCoords(parentEvent.positionXY + normalDir.XY());
        Vector3 targetScreen = cam.GetCameraComponent().WorldToScreenPoint(targetWorld);
        Vector3 delta        = targetScreen - ourScreen;

        return(OrthoDirExtensions.DirectionOf(new Vector2(delta.x, -delta.y)));
    }
Exemplo n.º 3
0
 public OrthoDir DirectionTo(MapEvent other)
 {
     return(OrthoDirExtensions.DirectionOf(other.PositionPx - PositionPx));
 }
Exemplo n.º 4
0
 public void FaceToward(IntVector2 pos)
 {
     facing = OrthoDirExtensions.DirectionOf(pos - GetComponent <MapEvent>().positionXY);
 }