Exemple #1
0
    /// <summary>
    /// ターゲットに近づく
    /// </summary>
    /// <returns> 移動したか</returns>
    protected bool TowardsTarget()
    {
        var dir = GetTargetDir(_targetPos);

        if (SetDestination(dir))
        {
            return(true);
        }
        else
        {
            Dir da = dir;
            Dir ds = dir;
            do
            {
                da = da.Addition();
                if (SetDestination(da))
                {
                    return(true);
                }

                ds = ds.Subtraction();
                if (SetDestination(ds))
                {
                    return(true);
                }
            } while (da != ds);
        }

        return(false);
    }